Is there any difference if I use this on Windows -Clinker=rust-lld.exe -Clinker-flavor=link-lld
or -Clinker=rust-lld.exe?
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 -C linker-flavor.
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.
So, process is following.
If -Clinker is specified but it is not rust-lld or lld, it used as is.
If -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.
If both -Clinker and -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-flavor if -Clinker=rust-lld because there is default flavor already.