Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM ld64.lld #85938

Closed
tschuett opened this issue Jun 2, 2021 · 6 comments
Closed

LLVM ld64.lld #85938

tschuett opened this issue Jun 2, 2021 · 6 comments

Comments

@tschuett
Copy link

tschuett commented Jun 2, 2021

I tried to use the new MachO linker from LLVM:

RUSTFLAGS="-C linker=/Users/tschuett/modules/clang/git/bin/ld64.lld" cargo build

  = note: ld64.lld:
          ld64.lld: error: unknown argument '-Wl,-dead_strip'
          ld64.lld: error: must specify -platform_version

First issue, rust appends -Wl, which makes the linker unhappy. Dead stripping is supported since today (https://reviews.llvm.org/D103324).

Second issue the linker requires a platform version:
https://github.com/llvm/llvm-project/blob/06e047227d71b2c1c477e280172abed0f1eed2c8/lld/MachO/Driver.cpp#L598

platform_version was introduced into clang:
https://reviews.llvm.org/D71579

Did the LinkerFlavor detection fail?

#39915

@tschuett
Copy link
Author

tschuett commented Jun 2, 2021

The full error message:

  = note: ld64.lld: error: unknown argument '-m64'
          ld64.lld: error: unknown argument '-Wl,-dead_strip'
          ld64.lld: error: unknown argument '-nodefaultlibs'
          ld64.lld: error: must specify -platform_version

@tschuett
Copy link
Author

tschuett commented Jun 2, 2021

@tschuett
Copy link
Author

tschuett commented Jun 2, 2021

I couldn't find -nodefaultlibs neither in the ld man page nor in Options.td file. It seems to be a GNU thing.

@tschuett
Copy link
Author

tschuett commented Jun 3, 2021

ld64.lld is missing here:

fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {

@tschuett
Copy link
Author

tschuett commented Jun 3, 2021

Add platform_version:

fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {

xcrun --show-sdk-platform-version -sdk macosx

@petrochenkov
Copy link
Contributor

Closing as a duplicate of #11937 since this issue is about using ld64 directly rather than through a C compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants