Specify GCC prefix in LLVM-based compilers#33146
Conversation
We currently don't really have something that gives the GCC install path, which is used by many LLVM-based compilers (llvm, llvm-amdgpu, nvhpc, ...) to fix the GCC toolchain once and for all. This `prefix` property is dynamic in the sense that it queries the compiler itself. This is necessary because it's not easy to deduce the install path from the `cc` property (might be a symlink, might be a filename like `gcc` which works by having the compiler load a module that sets the PATH variable, might be a generic compiler wrapper based on environment variables like on cray...). With this property introduced, we can clean up some recipes that have the logic repeated for GCC.
|
Notice that we're still picking up the wrong Also note that intel-oneapi-compilers's In principle we can just use |
| # cannot express that properly. For now, add conflicts for non-gcc compilers | ||
| # instead. | ||
| for __compiler in spack.compilers.supported_compilers(): | ||
| if __compiler != "gcc": |
There was a problem hiding this comment.
I see where you're coming from, this may be the best we can do for now, but is it that gcc is a direct dependency or that we need the system toolchain that's in use? The latter might let us propagate it transitively through other compilers as long as we can query them for the appropriate thing.
There was a problem hiding this comment.
More concretely, for clang-based compilers for example we could use the Selected GCC installation from clang -v, or the result of dirname $(clang -print-libgcc-file-name).
There was a problem hiding this comment.
It's also a direct dependency of the runtime libraries, although that's not covered by this PR:
$ readelf -d ./compiler/2022.2.0/linux/lib/libsycl.so | grep 'libgcc_s.so'
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
There was a problem hiding this comment.
So, I was thinking to submit another PR that would patchelf --add-rpath <gcc compiler support library dir> <intel oneapi compiler support library>
There was a problem hiding this comment.
That makes sense, but all the places this is happening only add the GCC stuff if the compiler is gcc, so compiling with clang we still don't get a toolchain set right?
There was a problem hiding this comment.
Yeah, in the PR I've added conflicts to only ever allow GCC as a "compiler" for intel-oneapi-compilers (just s.t. we can express the dependency on GCC support libs).
There was a problem hiding this comment.
Regarding llvm%clang, we could introspect clang and have it report its chosen gcc toolchain, and use that to fix GCC_INSTALL_PREFIX once and for all too... but that would another PR.
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
* spack.compiler.Compiler: introduce prefix property We currently don't really have something that gives the GCC install path, which is used by many LLVM-based compilers (llvm, llvm-amdgpu, nvhpc, ...) to fix the GCC toolchain once and for all. This `prefix` property is dynamic in the sense that it queries the compiler itself. This is necessary because it's not easy to deduce the install path from the `cc` property (might be a symlink, might be a filename like `gcc` which works by having the compiler load a module that sets the PATH variable, might be a generic compiler wrapper based on environment variables like on cray...). With this property introduced, we can clean up some recipes that have the logic repeated for GCC. * intel-oneapi-compilers: set --gcc-sysroot to %gcc prefix
|
This PR breaks Output: The cmake checks for |
|
Does #33281 (comment) fix it? I can't reproduce the problem. I guess it depends on the system gcc available. |
Unfortunately no.
Yes, you are probably right. This is gcc-7.3.1 |
|
I expected that your PR would undo the problem that this PR caused for icc and restore old behavior, but something else seems to be happening. I am installing old compilers so I can try to reproduce the problem. Can you upload the logs and env files for the cmake build that failed? |
|
I'll get to it right away. I am installing |
|
I get the same error for : here are the logs: |
|
I think I understand the problem: It is trying to test for c++17 support and failing. The --gcc-toolchain would have helped, but it works for icpx and not icpc. It needs to use a different option when the compiler is icpc. To work around it, I think you can |
|
You are right. I added this use case to #33281. |
spack.compiler.Compiler: introduce prefix propertyWe currently don't really have something that gives the GCC install path, which
is used by many LLVM-based compilers (llvm, llvm-amdgpu, nvhpc, ...) to fix the
GCC toolchain once and for all.
This
prefixproperty is dynamic in the sense that it queries the compileritself. This is necessary because it's not easy to deduce the install path from
the spack compiler
ccproperty (might be a symlink, might be a filename likegccwhich works by having the compiler load a module that sets the PATHvariable, might be a generic compiler wrapper based on environment variables
like on cray...).
With this new property, we can clean up some recipes that have the logic
repeated for GCC.
Also makes
intel-oneapi-compilersbehave likellvmandnvhpc, it nowfixes the GCC toolchain based on what
%gccwas used, instead of doing asystem search.