gcc: write builtin specs before modifications (#43956)

This commit is contained in:
Harmen Stoppels 2024-05-02 14:40:10 +02:00 committed by GitHub
parent a9fea9f611
commit 2eb7add8c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -980,17 +980,18 @@ def write_specs_file(self):
specs_file = join_path(self.spec_dir, "specs")
with open(specs_file, "w") as f:
# can't extend the builtins without dumping them first
f.write(self.spec["gcc"].command("-dumpspecs", output=str, error=os.devnull).strip())
f.write("\n\n# Generated by Spack\n\n")
# rpath
if rpath_dir:
print("*link_libgcc:", file=f)
print(f"+ -rpath={rpath_dir}", file=f)
print(file=f)
f.write(f"*link_libgcc:\n+ -rpath={rpath_dir}\n\n")
# programs search path
if self.spec.satisfies("+binutils"):
print("*self_spec:", file=f)
print(f"+ -B{self.spec['binutils'].prefix.bin}", file=f)
print(file=f)
f.write(f"*self_spec:\n+ -B{self.spec['binutils'].prefix.bin}\n\n")
set_install_permissions(specs_file)
tty.info(f"Wrote new spec file to {specs_file}")
@ -1210,6 +1211,4 @@ def _post_buildcache_install_hook(self):
if relocation_args:
with open(specs_file, "a") as f:
print("*self_spec:", file=f)
print(f"+ {' '.join(relocation_args)}", file=f)
print(file=f)
f.write(f"*self_spec:\n+ {' '.join(relocation_args)}\n\n")