fix[bazel]: Use ld (and other tools) from binutils
Upstream bazel resorts to looking for tools in /usr/bin/
otherwise.
Merge request reports
Activity
@andreasmueller reported a failing build of py-jaxlib on JSC:
283 /usr/bin/ld: /p/software/jurecadc/stages/2023/software/GCCcore/11.3.0/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libgcc.a(_divdi3.o): unable to initialize decompress status for section .debug_info >> 284 /p/software/jurecadc/stages/2023/software/GCCcore/11.3.0/lib/gcc/x86_64-pc-linux-gnu/11.3.0/libgcc.a: error adding symbols: File format not recognized
→ the build tool (bazel) seems to select the bare-metal linker, instead of the one from the loaded module →
/p/software/jurecadc/stages/2023/software/binutils/2.38-GCCcore-11.3.0
(corresponding gcc is/p/software/jurecadc/stages/2023/software/GCCcore/11.3.0/bin
).My guess ⇒ that is always the case, but in other cases the linker is still capable of linking the libraries provided by gcc — here it seems to much older, so it fails → my proposed fix: make
bazel
behave like any other tool and try to findld
in thePATH
(or viaLD
).added 1 commit
- f9f37ba3 - fix[bazel]: Use ld from LD or search in path
just in case it helps:
I did a test installation on jusuf (with exactly the same site-config, only changed the system name) and py-jaxlib build failed (I'm not 100% sure it's the same thing as in jureca: I didn't see this error anywhere, but tbh I didn't look closely)
I tried setting
GCC_HOST_COMPILER_PREFIX
as suggested here and it worked:def setup_build_environment(self, env): env.prepend_path("GCC_HOST_COMPILER_PREFIX", "/path/to/binutils/bin")
Edited by Eleni MathioulakiIs there a reason not to do this in all systems? Since it works, I would say to just fix the
py-jaxlib
package in master directly.(btw the reason I haven't already done that is that I'm not sure how to get the binutils prefix from the spec, and haven't had the time to look.. does any of you know how to do this? it's a dependency of the compiler, not the package, so can't do
self.spec['binutils']
)Unfortunately, I haven't managed to get the compiler dependencies in python at all. What I did for
pynn-brainscales
was this, but that's not abin
path either.
In thesetup_build_environment
-step, there were not even all environment variables available.My suggestion would be to set the variable for systems where it's needed, like this: https://gitlab.ebrains.eu/technical-coordination/project-internal/devops/platform/ebrains-spack-builds/-/commit/5aa05f6e2aa81b94dd4fd93cdbcb304d0e7acc37
Interesting, I would have expected
GCC_HOST_COMPILER_PREFIX
to also have effects on non-binutils executables, i.e.GCC_HOST_COMPILER_PREFIX
should be more of a merged set of paths, instead of just one… however, if it works, it works :) .I.e. having an external package for binutils in case of, e.g., JSC — but this would not go well with the
compilers.yaml
as there is already a module loaded, I guess?@andreasmueller I think the suggestion would be to have the JSC binutils module in the "external" packages list, i.e. the depends_on on this would basically just load the same variables as the module itself. Ah, you mean you would still need the env var explicitly set → yes, at least building C++ with bazel is a mess — it is very hard to inject custom paths (and settings too; so it's also fun to build old stuff that fails with more modern compilers, but which would accept it with some
-Wno-option
…). However, you could then derive the content ofGCC_HOST_COMPILER_PREFIX
by looking atspec['binutils'].prefix.bin
.Edited by Eric MüllerAbout
GCC_HOST_COMPILER_PREFIX
, see here - it should probably have a different nameAbout
depends_on('binutils')
, I just meant that if we add this we can usespec['binutils'].prefix.bin
to setGCC_HOST_COMPILER_PREFIX
insetup_build_environment()
spec['binutils'].prefix.bin
Commit/branch updated…
Edited by Eric MüllerAbout
GCC_HOST_COMPILER_PREFIX
, see here - it should probably have a different name…and it should be a list of search paths and there should be an actual lookup of the tool in the order of items in the list…
@emuller The changes should be in
py-jaxlib
, notbazel
updated :D (and afk for IRL meeting ;))
Edited by Eric MüllerHmm, but technically you are right… this is only needed for C++ builds via bazel — but it is still a "bazel problem" and changing all bazel-based packages seems ugly :/.
Edited by Eric Müller@emuller:
The changes you proposed work on jurecadc
added 1 commit
- d5064817 - fix[bazel]: Use ld (and other tools) from binutils
added 1 commit
- cfb2b120 - fix[bazel]: Use ld (and other tools) from binutils
mentioned in commit 2374cdd6
mentioned in issue #52 (closed)