internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spack/spack

Issue:
e4s ci: packages: prefer openssl certs=system due to binary relocation issue #31401
Prefer `openssl certs=system` since `openssl certs=mozilla` cannot be properly relocated due to https://github.com/spack/spack/issues/31401

FYI @wspear @scottwittenburg 


Discussion:
alternatively copy the pem file
> alternatively copy the pem file

instead of symlinking to the mozilla certs install path, just copy the certificates so they become part of the openssl install? sounds good to me!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openssl/package.py b/var/spack/repos/builtin/packages/openssl/package.py
--- a/var/spack/repos/builtin/packages/openssl/package.py
+++ b/var/spack/repos/builtin/packages/openssl/package.py
@@ -318,7 +318,7 @@ class Openssl(Package):  # Uses Fake Autotools, should subclass Package
 
     depends_on("zlib")
     depends_on("perl@5.14.0:", type=("build", "test"))
-    depends_on("ca-certificates-mozilla", type=("build", "run"), when="certs=mozilla")
+    depends_on("ca-certificates-mozilla", type="build", when="certs=mozilla")
     depends_on("nasm", when="platform=windows")
 
     patch(
@@ -473,7 +473,7 @@ def link_system_certs(self):
                 os.symlink(sys_certs, pkg_certs)
 
     @run_after("install")
-    def link_mozilla_certs(self):
+    def copy_mozilla_certs(self):
         if self.spec.variants["certs"].value != "mozilla":
             return
 
@@ -482,9 +482,7 @@ def link_mozilla_certs(self):
 
         mozilla_pem = self.spec["ca-certificates-mozilla"].pem_path
         pkg_cert = join_path(pkg_dir, "cert.pem")
-
-        if not os.path.exists(pkg_cert):
-            os.symlink(mozilla_pem, pkg_cert)
+        install(mozilla_pem, pkg_cert)
 
     def patch(self):
         if self.spec.satisfies("%nvhpc"):


Test patch:
Repository: spack/spack

Issue:
Duplicating variant in package to change default results in incorrect When field
### Steps to reproduce

Go to any package that inherits from CMakePackage and override the `build_type` variant. If you look at the resulting `spack info <package>`, it turns the `When` column into `[, ]` instead of the normal `--`.

### Error message

N/A

### Information on your system

N/A

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py
--- a/lib/spack/spack/cmd/info.py
+++ b/lib/spack/spack/cmd/info.py
@@ -145,10 +145,8 @@ def lines(self):
                 name = textwrap.wrap(
                     "{0} [{1}]".format(k, self.default(v)), width=self.column_widths[0]
                 )
-                if len(w) == 1:
-                    w = w[0]
-                    if w == spack.spec.Spec():
-                        w = "--"
+                if all(spec == spack.spec.Spec() for spec in w):
+                    w = "--"
                 when = textwrap.wrap(str(w), width=self.column_widths[1])
                 allowed = v.allowed_values.replace("True, False", "on, off")
                 allowed = textwrap.wrap(allowed, width=self.column_widths[2])


Test patch:
Repository: spack/spack

Issue:
libfabric: Correct develop version's GitHub branch name.
master doesn't exist.


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libfabric/package.py b/var/spack/repos/builtin/packages/libfabric/package.py
--- a/var/spack/repos/builtin/packages/libfabric/package.py
+++ b/var/spack/repos/builtin/packages/libfabric/package.py
@@ -16,7 +16,9 @@ class Libfabric(AutotoolsPackage):
 
     maintainers = ["rajachan"]
 
-    version("master", branch="master")
+    version("main", branch="main")
+    version("1.15.1", sha256="cafa3005a9dc86064de179b0af4798ad30b46b2f862fe0268db03d13943e10cd")
+    version("1.15.0", sha256="70982c58eadeeb5b1ddb28413fd645e40b206618b56fbb2b18ab1e7f607c9bea")
     version("1.14.1", sha256="6cfabb94bca8e419d9015212506f5a367d077c5b11e94b9f57997ec6ca3d8aed")
     version("1.14.0", sha256="fc261388848f3cff555bd653f5cb901f6b9485ad285e5c53328b13f0e69f749a")
     version("1.13.2", sha256="25d783b0722a8df8fe61c1de75fafca684c5fe520303180f26f0ad6409cfc0b9")
@@ -46,6 +48,7 @@ class Libfabric(AutotoolsPackage):
         "gni",
         "mlx",
         "mrail",
+        "opx",
         "psm",
         "psm2",
         "psm3",
@@ -100,6 +103,7 @@ class Libfabric(AutotoolsPackage):
     depends_on("libtool", when="@develop", type="build")
 
     conflicts("@1.9.0", when="platform=darwin", msg="This distribution is missing critical files")
+    conflicts("fabrics=opx", when="@:1.14.99")
 
     def setup_build_environment(self, env):
         if self.run_tests:


Test patch:
Repository: spack/spack

Issue:
spfft: inherit from ROCmPackage
Following https://github.com/spack/spack/pull/31207#issuecomment-1161932478 this PR adapts `spfft` the same way by inheriting from `ROCmPackage`.

Also for this one, I would ask one of the reviewer if they can test it works correctly.


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/spfft/package.py b/var/spack/repos/builtin/packages/spfft/package.py
--- a/var/spack/repos/builtin/packages/spfft/package.py
+++ b/var/spack/repos/builtin/packages/spfft/package.py
@@ -7,7 +7,7 @@
 from spack.package import *
 
 
-class Spfft(CMakePackage, CudaPackage):
+class Spfft(CMakePackage, CudaPackage, ROCmPackage):
     """Sparse 3D FFT library with MPI, OpenMP, CUDA and ROCm support."""
 
     homepage = "https://github.com/eth-cscs/SpFFT"
@@ -49,9 +49,6 @@ class Spfft(CMakePackage, CudaPackage):
     depends_on("mpi", when="+mpi")
     depends_on("cmake@3.11:", type="build")
 
-    # ROCM variants + dependencies
-    variant("rocm", default=False, description="Use ROCm backend")
-
     depends_on("cuda@:10", when="@:0.9.11 +cuda")
 
     with when("+rocm"):
@@ -59,25 +56,10 @@ class Spfft(CMakePackage, CudaPackage):
         depends_on("hip@:4.0", when="@:1.0.1")
         # Workaround for compiler bug in ROCm 4.5 added in SpFFT 1.0.6
         depends_on("hip@:4.3.1", when="@:1.0.5")
-        depends_on("hip")
         depends_on("rocfft")
         # rocFFT and hipFFT have split with latest versions
         depends_on("hipfft", when="^rocfft@4.1.0:")
 
-        amdgpu_targets = (
-            "gfx701",
-            "gfx801",
-            "gfx802",
-            "gfx803",
-            "gfx900",
-            "gfx906",
-            "gfx908",
-            "gfx1010",
-            "gfx1011",
-            "gfx1012",
-        )
-        variant("amdgpu_target", default="gfx803,gfx900,gfx906", multi=True, values=amdgpu_targets)
-
     # Fix compilation error in some cases due to missing include statement
     # before version 1.0.3
     patch("0001-fix-missing-limits-include.patch", when="@:1.0.2")


Test patch:
Repository: spack/spack

Issue:
Environment activation/deactivation issue with [t]csh
As for your initial issue in https://github.com/spack/spack/pull/25409#issuecomment-953132990:

```
$ spack env activate a
SPACK_OLD_PROMPT: Undefined variable.
```

There seems to be a problem with our generated csh commands where we don't enclose them in ``` `` ``` and they therefore are evaluated, for example:

```
if ( $?SPACK_OLD_PROMPT ) set prompt="$SPACK_OLD_PROMPT" && unsetenv SPACK_OLD_PROMPT ;
```

Appears in `spack env activate --csh <name-of-env>`, but this fails in my env when `$SPACK_OLD_PROMPT` isn't defined because it tries to evaluate the variable inside the statement (even if the statement itself isn't evaluated). So the following appears to get desirable behavior:

```
if ( $?SPACK_OLD_PROMPT ) `set prompt="$SPACK_OLD_PROMPT" && unsetenv SPACK_OLD_PROMPT` ;
```

I likewise had to make a similar edit to `pathadd.csh` to get `setup-env.csh` to work:

```
diff --git a/share/spack/csh/pathadd.csh b/share/spack/csh/pathadd.csh
index ec394e8990..7f3424518a 100644
--- a/share/spack/csh/pathadd.csh
+++ b/share/spack/csh/pathadd.csh
@@ -22,7 +22,7 @@ endif
 set _pa_old_value = ""
 eval set _pa_set = '$?'$_pa_varname
 if ($_pa_set == 1) then
-    eval set _pa_old_value='$'$_pa_varname
+    eval `set _pa_old_value = '$'$_pa_varname`
 endif
 
 # Do the actual prepending here, if it is a dir and not already in the path
```

_Originally posted by @scheibelp in https://github.com/spack/spack/issues/25409#issuecomment-953332271_


Discussion:
@haampie Is this what you meant?  It's definitely a much better comment for the issue. :grin:

Yes! Btw, we got a PR in for zsh (#26120), I created a PR for sh (#27012), Peter had this comment for csh, and then there still is this one https://github.com/spack/spack/issues/26830 about fish... Still in time for 0.17? :laughing: 
> Yes! Btw, we got a PR in for zsh (#26120), I created a PR for sh (#27012), Peter had this comment for csh, and then there still is this one #26830 about fish... Still in time for 0.17? 😆

I've never used the fish shell.  

We're trying to get `0.17` out this week.

Resolving patch:
diff --git a/lib/spack/spack/environment/shell.py b/lib/spack/spack/environment/shell.py
--- a/lib/spack/spack/environment/shell.py
+++ b/lib/spack/spack/environment/shell.py
@@ -65,8 +65,8 @@ def deactivate_header(shell):
     if shell == "csh":
         cmds += "unsetenv SPACK_ENV;\n"
         cmds += "if ( $?SPACK_OLD_PROMPT ) "
-        cmds += 'set prompt="$SPACK_OLD_PROMPT" && '
-        cmds += "unsetenv SPACK_OLD_PROMPT;\n"
+        cmds += '    eval \'set prompt="$SPACK_OLD_PROMPT" &&'
+        cmds += "          unsetenv SPACK_OLD_PROMPT';\n"
         cmds += "unalias despacktivate;\n"
     elif shell == "fish":
         cmds += "set -e SPACK_ENV;\n"


Test patch:
Repository: spack/spack

Issue:
New Package: Navi
@hyviquel moved there https://github.com/spack/spack/pull/32895


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/navi/package.py b/var/spack/repos/builtin/packages/navi/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin/packages/navi/package.py
@@ -0,0 +1,22 @@
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class Navi(Package):
+    """An interactive cheatsheet tool for the command-line"""
+
+    homepage = "https://github.com/denisidoro/navi"
+    url = "https://github.com/denisidoro/navi/archive/refs/tags/v2.20.1.tar.gz"
+
+    maintainers = ["delucca"]
+
+    version("2.20.1", sha256="92644677dc46e13aa71b049c5946dede06a22064b3b1834f52944d50e3fdb950")
+    depends_on("rust")
+
+    def install(self, spec, prefix):
+        cargo = which("cargo")
+        cargo("install", "--root", prefix, "--path", ".")


Test patch:
Repository: spack/spack

Issue:
Installation issue: nix
### Steps to reproduce the issue

```console
$ spack install nix%gcc@12.2.0
```


### Error message

<details><summary>Error message</summary><pre>
==> Installing nix-2.3.15-iotneds2ir4qyfv42ybeowj5o67ultwu
==> No binary for nix-2.3.15-iotneds2ir4qyfv42ybeowj5o67ultwu found: installing from source
==> Using cached archive: /home/sagrays/.local/share/spack/var/spack/cache/_source-cache/archive/7b/7bf04e47960e7895655ad40461f2cf8038b97e98165672db7a7ac1990fc77a22.zip
==> Applied patch /home/sagrays/.local/share/spack/var/spack/repos/builtin/packages/nix/fix-doc-build.patch
==> Ran patch() for nix
==> nix: Executing phase: 'autoreconf'
==> nix: Executing phase: 'configure'
==> nix: Executing phase: 'build'
==> nix: Executing phase: 'install'
==> Error: AttributeError: 'Nix' object has no attribute 'test_path'

/home/sagrays/.local/share/spack/var/spack/repos/builtin/packages/nix/package.py:112, in installcheck_clean:
        111    def installcheck_clean(self):
  >>    112        if self.test_path:
        113            for (root, dirs, files) in os.walk(self.test_path, topdown=True):
        114                os.chmod(root, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
        115            remove_linked_tree(self.test_path)

</pre></details>


### Information on your system

* **Spack:** 0.19.0.dev0
* **Python:** 3.6.8
* **Platform:** linux-rhel7-x86_64_v4
* **Concretizer:** clingo

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/9710314/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/9710315/spack-build-out.txt)


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/nix/package.py b/var/spack/repos/builtin/packages/nix/package.py
--- a/var/spack/repos/builtin/packages/nix/package.py
+++ b/var/spack/repos/builtin/packages/nix/package.py
@@ -16,6 +16,7 @@ class Nix(AutotoolsPackage):
 
     homepage = "https://nixos.org/nix"
     url = "https://github.com/NixOS/nix/archive/2.3.15.zip"
+    maintainers = ["charmoniumq"]
 
     version("2.3.15", sha256="7bf04e47960e7895655ad40461f2cf8038b97e98165672db7a7ac1990fc77a22")
     version("2.2.1", sha256="b591664dd1b04a8f197407d445799ece41140a3117bcbdf8e3c5e94cd3f59854")
@@ -109,7 +110,7 @@ def installcheck(self):
 
     @run_after("install")
     def installcheck_clean(self):
-        if self.test_path:
+        if hasattr(self, "test_path") and self.test_path:
             for (root, dirs, files) in os.walk(self.test_path, topdown=True):
                 os.chmod(root, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
             remove_linked_tree(self.test_path)


Test patch:
Repository: spack/spack

Issue:
Installation issue: blast-plus (missing cpio)
### Steps to reproduce the issue

```console
cat > spack.yaml << EOF
spack:
  view: true
  specs:
  - blast-plus@2.12.0
  container:
    extra_instructions:
      final: RUN (echo /opt/view/lib && echo /opt/view/lib64) > /etc/ld.so.conf.d/spack-view.conf
        && ldconfig
    images:
      os: ubuntu:22.04
      spack:
        ref: develop
EOF
spack containerize > Dockerfile
docker build -t blast:2.12.0 .
```


### Error message

```
 59307    done
     59308    /bin/bash: line 3: cpio: command not found
     59309    /bin/bash: line 3: cpio: command not found
  >> 59310    make[1]: *** [Makefile:47: install-toolkit] Error 127
     59311    make[1]: Leaving directory '/tmp/root/spack-stage/spack-stage-bla
              st-plus-2.12.0-rlog3ww57onydmbgmpbqj25nvcmayses/spack-src/c++'
  >> 59312    make: *** [Makefile:63: install] Error 2
```

### Information on your system

c7g-4x Instance

### Additional information

_No response_

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
I manually added `cpio` to the `bootstrap` part of the Dockerfile and it works.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/blast-plus/package.py b/var/spack/repos/builtin/packages/blast-plus/package.py
--- a/var/spack/repos/builtin/packages/blast-plus/package.py
+++ b/var/spack/repos/builtin/packages/blast-plus/package.py
@@ -10,10 +10,11 @@ class BlastPlus(AutotoolsPackage):
     """Basic Local Alignment Search Tool."""
 
     homepage = "https://blast.ncbi.nlm.nih.gov/"
-    url = "https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.12.0/ncbi-blast-2.12.0+-src.tar.gz"
+    url = "https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/2.13.0/ncbi-blast-2.13.0+-src.tar.gz"
 
     maintainers = ["weijianwen"]
 
+    version("2.13.0", sha256="89553714d133daf28c477f83d333794b3c62e4148408c072a1b4620e5ec4feb2")
     version("2.12.0", sha256="fda3c9c9d488cad6c1880a98a236d842bcf3610e3e702af61f7a48cf0a714b88")
     version("2.11.0", sha256="d88e1858ae7ce553545a795a2120e657a799a6d334f2a07ef0330cc3e74e1954")
     version("2.9.0", sha256="a390cc2d7a09422759fc178db84de9def822cbe485916bbb2ec0d215dacdc257")
@@ -45,6 +46,8 @@ def patch(self):
     # No...
     # depends_on :mysql => :optional
 
+    depends_on("cpio", type="build")
+
     variant("static", default=False, description="Build with static linkage")
     variant("jpeg", default=True, description="Build with jpeg support")
     variant("png", default=True, description="Build with png support")


Test patch:
Repository: spack/spack

Issue:
spack external find curl emits an empty file
### Steps to reproduce

```console
$ spack external find curl
```

### Error message

This command works as expected, but afterwards, an empty file named `str` appears in the directory where I ran the command.

### Information on your system

```console
$ spack debug report
* **Spack:** 0.18.1
* **Python:** 3.6.8
* **Platform:** linux-rhel7-zen3
* **Concretizer:** clingo
```

### General information

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


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/curl/package.py b/var/spack/repos/builtin/packages/curl/package.py
--- a/var/spack/repos/builtin/packages/curl/package.py
+++ b/var/spack/repos/builtin/packages/curl/package.py
@@ -129,7 +129,7 @@ def determine_variants(cls, exes, version):
         for exe in exes:
             variants = ""
             curl = Executable(exe)
-            output = curl("--version", output=str, error="str")
+            output = curl("--version", output=str, error=str)
             if "nghttp2" in output:
                 variants += "+nghttp2"
             protocols_match = re.search(r"Protocols: (.*)\n", output)


Test patch:
Repository: spack/spack

Issue:
Package missing attribute legacy_buildsystem
Hi there! We do nightly builds for all of the flux packages, and flux-pmix just failed:

https://github.com/flux-framework/spack/actions/runs/3334569875/jobs/5517664275

With:

```console
==> Error: AttributeError: 'LuaLuaposix' object has no attribute 'legacy_buildsystem'

The 'flux-core' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure

/opt/spack/lib/spack/spack/build_environment.py:1075, in _setup_pkg_and_run:
       1072        tb_string = traceback.format_exc()
       1073
       1074        # build up some context from the offending package so we can
  >>   1075        # show that, too.
       1076        package_context = get_package_context(tb)
       1077
       1078        logfile = None
```

I believe as (possibly) a result of this large changeset?

https://github.com/spack/spack/pull/30738/files#diff-a84edde530c6ead1a43248bba686526c1a19670976147ec8638a20d3adb47bbd

Could you please let us know how to best fix this up? Pinging @grondo to stay in the loop - and since this is the first detected failure, remember that we can make the change to the package https://github.com/flux-framework/spack to re-test the build before we open a PR here. Our automation will handle the testing and follow up PR etc. I volunteer to do this fix as soon as I know what the resolution is, given that it's not an issue in spack (in which case we just need to have that fixed and do another nightly test!)


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/build_systems/lua.py b/lib/spack/spack/build_systems/lua.py
--- a/lib/spack/spack/build_systems/lua.py
+++ b/lib/spack/spack/build_systems/lua.py
@@ -20,6 +20,9 @@ class LuaPackage(spack.package_base.PackageBase):
     #: system base class
     build_system_class = "LuaPackage"
 
+    #: Legacy buildsystem attribute used to deserialize and install old specs
+    legacy_buildsystem = "lua"
+
     list_depth = 1  # LuaRocks requires at least one level of spidering to find versions
 
     build_system("lua")


Test patch:
Repository: spack/spack

Issue:
Installation issue: ncurses
### Steps to reproduce the issue

```console
$ spack spec -I ncurses

Input spec
--------------------------------
 -   ncurses

Concretized
--------------------------------
 -   ncurses@6.3%gcc@9.4.0~symlinks+termlib abi=none build_system=autotools arch=linux-ubuntu20.04-broadwell
[+]      ^pkgconf@1.8.0%gcc@9.4.0 build_system=autotools arch=linux-ubuntu20.04-broadwell

...
```


### Error message

<details><summary>Error message</summary><pre>
==> Error: AttributeError: 'str' object has no attribute 'propagate'

The 'ncurses' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure
</pre></details>


### Information on your system

* **Spack:** 0.19.0.dev0 (d4ea74bf80bde99a5d96ec0bbe9e872961f4679b)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-broadwell
* **Concretizer:** clingo


### Additional information

_No response_

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:

Resolving patch:
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -346,7 +346,7 @@ def set_compiler_environment_variables(pkg, env):
                 handler = pkg.flag_handler.__func__
             else:
                 handler = pkg.flag_handler.im_func
-        injf, envf, bsf = handler(pkg, flag, spec.compiler_flags[flag])
+        injf, envf, bsf = handler(pkg, flag, spec.compiler_flags[flag][:])
         inject_flags[flag] = injf or []
         env_flags[flag] = envf or []
         build_system_flags[flag] = bsf or []


Test patch:
diff --git a/lib/spack/spack/test/flag_handlers.py b/lib/spack/spack/test/flag_handlers.py
--- a/lib/spack/spack/test/flag_handlers.py
+++ b/lib/spack/spack/test/flag_handlers.py
@@ -135,3 +135,15 @@ def test_ld_libs_cmake(self, temp_env):
             "-DCMAKE_CXX_STANDARD_LIBRARIES=-lfoo",
             "-DCMAKE_Fortran_STANDARD_LIBRARIES=-lfoo",
         }
+
+    def test_flag_handler_no_modify_specs(self, temp_env):
+        def test_flag_handler(self, name, flags):
+            flags.append("-foo")
+            return (flags, None, None)
+
+        s = spack.spec.Spec("cmake-client").concretized()
+        s.package.flag_handler = test_flag_handler
+        spack.build_environment.setup_package(s.package, False)
+
+        assert not s.compiler_flags["cflags"]
+        assert os.environ["SPACK_CFLAGS"] == "-foo"