Skip to content

Compatibility of Xcode 16+ ld and Spack's compiler wrappers #46506

@adamjstewart

Description

@adamjstewart

Steps to reproduce

It's possible there is a compatibility issue between Spack's compiler wrappers and the ld provided by Xcode 16+. Xcode 15 introduced a new linker that is much more strict than previous versions. Xcode 16 (released this week) updated this linker to be even more strict, disallowing duplicate RPATHs.

If I understand correctly, Spack's compiler wrappers add RPATHs for all <prefix>/lib directories regardless of whether or not RPATH linker args are already present on the command line. If this is correct, I think we just need to prevent duplicate RPATHs in the compiler wrappers.

Error message

After upgrading to Xcode 16, I see a number of issues like the following affecting packages like cgns, hdf5, py-h5py, VTK, py-torchvision, etc.

ld: warning: duplicate -rpath '/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/cgns-4.4.0-hyx7mtf6mxo7h7gz5rx4lthyrypp4u7h/lib' ignored
ld: warning: duplicate -rpath '/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/hdf5-1.14.3-emur2bgnslki3qnnmeqoo5ehaeyeseq5/lib' ignored
ld: duplicate LC_RPATH '/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/hdf5-1.14.3-emur2bgnslki3qnnmeqoo5ehaeyeseq5/lib' in '/Users/Adam/spack/opt/spack/darwin-sequoia-m2/apple-clang-16.0.0/cgns-4.4.0-hyx7mtf6mxo7h7gz5rx4lthyrypp4u7h/lib/libcgns.4.4.dylib'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

My best guess is that the build system adds RPATH on its own, and Spack's compiler wrappers also add RPATH, and the new ld fails with duplicate RPATHs.

The current workaround is to add -Wl,-ld_classic to the compiler flags. However, this has a warning message saying that ld_classic is deprecated and will be removed in the future.

Information on your system

  • Spack: 0.23.0.dev0 (28e3295)
  • Python: 3.11.9
  • Platform: darwin-sequoia-m2

General information

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

Related to #46460, #46462, and #46463

Metadata

Metadata

Labels

bugSomething isn't workingmacOStriageThe issue needs to be prioritized

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions