Is there any difference if I use this on Windows
In the docs, there are description of behaviour if only one of them set (e.g. if I set
-Clinker=rust-lld.exe or if I set
-Clinker-flavor=link-lld) but no description of how they interact if both set.
Is linker-flavor ignored if I set linker? Or it somehow affects the linker specified?
If you look at an up-to-date version of the rustc documentation, you see:
If a linker is given with the
-C linker flag, then the linker flavor is inferred from the value provided. If no linker is given then the linker flavor is used to determine the linker to use. Every
rustc target defaults to some linker flavor.
Which implies that
-C linker has priority over
As I understood,
-C linker-flavor=flavor leads to adding addition
-flavor=mapped_flavor to linker invokation.
E.g., if I specify
-Clinker=rust-lld.exe -Clinker-flavor=ld.lld, it results as calling
rust-lld.exe -flavor=gnu <other link args> during linkage.
Yes, it is confirmed.
Here is code in rustc: rust/mod.rs at 50f2c292007f9364908e4b8344886797f0144648 · rust-lang/rust · GitHub
And rust/msvc_base.rs at 50f2c292007f9364908e4b8344886797f0144648 · rust-lang/rust · GitHub
So, process is following.
-Clinker is specified but it is not rust-lld or lld, it used as is.
-Clinker is specfied and it is rust-lld or lld, and no flavor specified, it uses default lld-flavor for toolchain, e.g.
-flavor=gnu for x86_64-pc-windows-gnu or
-flavor=link if it is x86_64-pc-windows-msvc.
-Clinker-flavor specified, this flavor passed to linker (even if linker is not lld). This way, it is possible to use gnu linkage on msvc target.
From practical POV, there is no need to specify
-Clinker=rust-lld because there is default flavor already.
Hmm, sounds like the rustc documentation is not quite accurate then.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.