spack: Spack environment: cannot combine spec cflags with compiler cflags

Steps to reproduce

Using the following spack.yaml:

spack:
  # add package specs to the `specs` list
  specs:
  - zlib cflags=-O3
  view: true
  concretizer:
    unify: true
  'compilers:':
  - compiler:
      spec: gcc@=9.4.0
      paths:
        cc: /usr/bin/gcc
        cxx: /usr/bin/g++
        f77: null
        fc: null
      flags:
        cflags: "-What"
      operating_system: ubuntu20.04
      target: x86_64
      modules: []
      environment: {}
      extra_rpaths: []

(in my case I did this on an Ubuntu 20 docker image)

and do

spack env create t1 spack.yaml 
spack -e t1 concretize -f -U

(nothing happens)

Error message

There is no error message, but nothing is concretized, and no spack.lock appears.

If I remove the flag from either the spec in the spec list, or set cflags to “” in the compiler entry, then the concretization succeeds.

If I run in debug mode (spack -d...) then most of the output looks like normal config loading, although the following unusual message appears (not reported as an error and doesn’t show up without -d):

==> [2023-06-30-23:22:35.561111] UNKNOWN SYMBOL: attr("node_compiler", zlib, gcc)

Information on your system

$ spack debug report
* **Spack:** 0.21.0.dev0 (0c2b98ca7044588d56e9e4c9c178f411b6dc15c1)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-skylake
* **Concretizer:** clingo

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 23 (23 by maintainers)

Commits related to this issue

Most upvoted comments

Since I don’t see a workaround mentioned in this thread, here’s one that I’ve found useful in the meantime.

From the original issue, this fails:

  specs:
    - zlib cflags="-O3"

but using a require: statement to set the needed cflags does concretize and the concretized spec concatenates the flags from the compiler and package configurations:

  packages:
    zlib:
      require: 'cflags="-O3"'
  specs:
    - zlib

This doesn’t take care of any flag conflicts or ordering. It seems it also can’t propagate flags to dependencies automatically like you could with an abstract spec (with cflags==...). However, it’s been good enough for what I need to do.

@alalazo I understand what you’re saying, but still, by asking for this compiler (defined with the additional flag -What) the user is asking for -O3 -What even if that is done implicitly.

To reuse your point above, if we had 2 compilers, one with no flags and one with -fno-tree-pre, by choosing the second one, the user is expecting “slightly less than -O3”.

I am not saying I am right to think that way, but to me, it looks like you are debating defining “satisfies” in a way that will either suppose full knowledge of how compilers deal with flags, or accept compromise, while I think the solution might be to have the compilers flags applied to the abstract spec because that’s what the users asked (knowingly or not).

I can look into this next week