Repository: spack/spack

Issue:
Installation issue: binutils default variants lead to conflicts in concretization
<!-- Thanks for taking the time to report this build failure. To proceed with the report please:

1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively! -->

The changes from #23065 lead to a conflict with the default variants of `binutils` and so as a side product seem to break the conretization for some packages that do not explicitly specify the `binutils` variants they want. I am using `gcc +binutils` below here. But there are others as well.

### Steps to reproduce the issue

<!-- Fill in the exact spec you are trying to build and the relevant part of the error message -->
```console
$ spack spec gcc +binutils
```
Results in
```console
Input spec
--------------------------------
gcc+binutils

Concretized
--------------------------------
==> Error: Conflicts in concretized spec "gcc@10.3.0%gcc@9.3.0+binutils~bootstrap~graphite~nvptx~piclibs~strip languages=c,c++,fortran patches=2c18531a23623596e1daf6f0dd963cf72c208945ecad90515640c3ab23991159 arch=linux-ubuntu20.04-broadwell/euriv7d"

List of matching conflicts for spec:

    binutils@2.36.1%gcc@9.3.0~gas+gold~headers~interwork+ld~libiberty~lto+nls+plugins arch=linux-ubuntu20.04-broadwell
        ^diffutils@3.7%gcc@9.3.0 arch=linux-ubuntu20.04-broadwell
            ^libiconv@1.16%gcc@9.3.0 arch=linux-ubuntu20.04-broadwell
        ^gettext@0.21%gcc@9.3.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-ubuntu20.04-broadwell
            ^bzip2@1.0.8%gcc@9.3.0+shared arch=linux-ubuntu20.04-broadwell
            ^libxml2@2.9.10%gcc@9.3.0~python arch=linux-ubuntu20.04-broadwell
                ^pkgconf@1.7.4%gcc@9.3.0 arch=linux-ubuntu20.04-broadwell
                ^xz@5.2.4%gcc@9.3.0~pic arch=linux-ubuntu20.04-broadwell
                ^zlib@1.2.11%gcc@9.3.0+optimize+pic+shared arch=linux-ubuntu20.04-broadwell
            ^ncurses@6.2%gcc@9.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-broadwell
            ^tar@1.30%gcc@9.3.0 arch=linux-ubuntu20.04-broadwell

1. "~gas" conflicts with "binutils+ld" [Linker and assembler should be the same version]
2. "~gas" conflicts with "binutils+gold" [Linker and assembler should be the same version]
```

### Information on your system

<!-- Please include the output of `spack debug report` -->

<!-- If you have any relevant configuration detail (custom `packages.yaml` or `modules.yaml`, etc.) you can add that here as well. -->

```console
* **Spack:** 0.16.1-2269-2d5f519d9b
* **Python:** 3.8.5
* **Platform:** linux-ubuntu20.04-skylake
* **Concretizer:** original
```

### Additional information

A quick check for dependents of `binutils`:

```bash
for s in $(spack dependents binutils); do spack spec $s > /dev/null 2>&1 || echo $s; done
```

yields the following list of packages:
```console
abi-compliance-checker
abi-dumper
apex
cbtf-krell
dropwatch
extrae
hpctoolkit
kcov
ldc
ldc-bootstrap
llvm-doe
mesa
mesa18
nvptx-tools
openspeedshop
openspeedshop-utils
pnmpi
py-llvmlite
sollve
srilm
sst-macro
tau
```

<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [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:
This also breaks llvm:
```
# spack spec llvm
Input spec
--------------------------------
llvm

Concretized
--------------------------------
==> Error: Conflicts in concretized spec "llvm@12.0.0%gcc@7.5.0~all_targets+clang~code_signing+compiler-rt~cuda~flang+gold+internal_unwind~ipo+libcxx+lld+lldb~llvm_dylib~mlir~omp_debug~omp_tsan+polly~python~shared_libs~split_dwarf build_type=Release cuda_arch=none arch=linux-ubuntu18.04-haswell/p5ghocc"

List of matching conflicts for spec:

    binutils@2.36.1%gcc@7.5.0~gas+gold~headers~interwork~ld~libiberty~lto+nls+plugins arch=linux-ubuntu18.04-haswell
        ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
            ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
        ^gettext@0.21%gcc@7.5.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-ubuntu18.04-haswell
            ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-haswell
            ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-haswell
                ^pkgconf@1.7.4%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
                ^xz@5.2.5%gcc@7.5.0~pic arch=linux-ubuntu18.04-haswell
                ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-haswell
            ^ncurses@6.2%gcc@7.5.0~symlinks+termlib abi=none arch=linux-ubuntu18.04-haswell
            ^tar@1.34%gcc@7.5.0 arch=linux-ubuntu18.04-haswell

1. "~gas" conflicts with "binutils+gold" [Linker and assembler should be the same version]
```
In fact, just the default `binutils` spec on linux now generates a conflict:
```
# spack spec binutils
Input spec
--------------------------------
binutils

Concretized
--------------------------------
==> Error: Conflicts in concretized spec "binutils@2.36.1%gcc@7.5.0~gas+gold~headers~interwork~ld~libiberty~lto+nls~plugins arch=linux-ubuntu18.04-haswell/q4ri76u"

List of matching conflicts for spec:

    binutils@2.36.1%gcc@7.5.0~gas+gold~headers~interwork~ld~libiberty~lto+nls~plugins arch=linux-ubuntu18.04-haswell
        ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
            ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
        ^gettext@0.21%gcc@7.5.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-ubuntu18.04-haswell
            ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-haswell
            ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-haswell
                ^pkgconf@1.7.4%gcc@7.5.0 arch=linux-ubuntu18.04-haswell
                ^xz@5.2.5%gcc@7.5.0~pic arch=linux-ubuntu18.04-haswell
                ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-haswell
            ^ncurses@6.2%gcc@7.5.0~symlinks+termlib abi=none arch=linux-ubuntu18.04-haswell
            ^tar@1.34%gcc@7.5.0 arch=linux-ubuntu18.04-haswell

1. "~gas" conflicts with "binutils+gold" [Linker and assembler should be the same version]
```
Ugh... can we default to the new concretizer already :s. My bad, I didn't test this with the old one.

Can somebody knowledgeable about GCC/LLVM tell me whether you would always want to have the binutils assembler when building gold or ld?

The reason for the conflict with `ld` is valid, as I ended up with a broken combination of system linker & spack provided assembler. The previous default was to not build `ld` but to actually build `(g)as`.

Let me test if the other (spack provided linker & system assembler) conflict is actually strictly necessary

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/binutils/package.py b/var/spack/repos/builtin/packages/binutils/package.py
--- a/var/spack/repos/builtin/packages/binutils/package.py
+++ b/var/spack/repos/builtin/packages/binutils/package.py
@@ -61,14 +61,13 @@ class Binutils(AutotoolsPackage, GNUMirrorPackage):
     conflicts('+gold', when='platform=darwin',
               msg="Binutils cannot build linkers on macOS")
 
-    # When you build binutils with ~ld and +gas and load it in your PATH, you may
-    # end up with an incompatibility between linker and assembler, in particular:
-    # "unable to initialize decompress status for section .debug_info" is the error
-    # I've encountered.
-    conflicts('~gas', '+ld', msg="Linker and assembler should be the same version")
-    conflicts('+gas', '~ld', msg="Linker and assembler should be the same version")
-    conflicts('~gas', '+gold', msg="Linker and assembler should be the same version")
-    conflicts('+gas', '~gold', msg="Linker and assembler should be the same version")
+    # When you build binutils with ~ld and +gas and load it in your PATH, you
+    # may end up with incompatibilities between a potentially older system ld
+    # and a recent assembler. For instance the linker on ubuntu 16.04 from
+    # binutils 2.26 and the assembler from binutils 2.36.1 will result in:
+    # "unable to initialize decompress status for section .debug_info"
+    # when compiling with debug symbols on gcc.
+    conflicts('+gas', '~ld', msg="Assembler not always compatible with system ld")
 
     def configure_args(self):
         spec = self.spec


Test patch: