Improve linker detection for ld64.lld for Apple devices#86064
Improve linker detection for ld64.lld for Apple devices#86064tschuett wants to merge 6 commits intorust-lang:masterfrom tschuett:flavor
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
|
☔ The latest upstream changes (presumably #85086) made this pull request unmergeable. Please resolve the merge conflicts. |
| Err(e) => Err(format!("failed to get {} SDK path: {}", sdk_name, e)), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The LLVM linker requires the platform_version option. The Apple linker also supports it.
| LinkerFlavor::Gcc, | ||
| vec!["-m64".to_string(), "-arch".to_string(), "x86_64".to_string()], | ||
| ); | ||
| base.pre_link_args.insert( |
There was a problem hiding this comment.
This will be needed for other Apple devices, but I have no hardware.
| // Converts a library file-stem into a cc -l argument | ||
| fn unlib<'a>(target: &Target, stem: &'a str) -> &'a str { | ||
| if stem.starts_with("lib") && !target.is_like_windows { &stem[3..] } else { stem } | ||
| if stem.starts_with("lib") && !target.is_like_windows { |
| if self.sess.target.is_like_osx { | ||
| self.cmd.arg("-dynamiclib"); | ||
| if self.sess.target.lld_flavor != LldFlavor::Ld64 { | ||
| self.cmd.arg("-dynamiclib"); |
There was a problem hiding this comment.
This seems be only needed for gcc. -dynamiclib is an gcc option.
| }; | ||
|
|
||
| let path = format!("{}/usr/lib", &sdk_path); | ||
| cmd.args(&["-syslibroot", &sdk_path]); |
There was a problem hiding this comment.
This is an implementation of -isysroot for ld64.
This PR attempts to add support for linking directly with |
|
How do I get cargo to use ld64.lld? |
|
In other words, |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Indeed RUSTFLAGS="-C link-arg=-fuse-ld=/..../ld64.lld" cargo buildsucceeds. |
Other Apple devices will need a similar solution, but I have no hardware.
see #85938
I can now build a large workspace with 300+ crates.