Open daivinhtran opened 9 months ago
Which version of lld is this?
The correct place for this would be in the toolchain. We could add feature detection to choose between -Wl
and -Xlinker
in unix_cc_toolchain_configure.bzl
.
@fmeum
$ /nix/store/8wdy19pya1n7wrn2664d2819m3pyamg4-llvm-binutils-16.0.6/bin/ld.lld --version
LLD 16.0.6 (compatible with GNU linkers)
I ended up fixing our own toolchains which, I think, used https://github.com/bazelbuild/bazel/blob/master/tools/cpp/unix_cc_toolchain_config.bzl as a guidance .
I think it's worth fixing https://github.com/bazelbuild/bazel/blob/master/tools/cpp/unix_cc_toolchain_config.bzl to not use -Xlinker
when lld
is the linker.
Okay, this is actually working as intended (although confusingly): The C++ toolchain configures linker flags for the link action, which still uses the compiler to interface with the linker. No linker will support the -Xlinker
flag as this is a compiler flag used to pass linker flags to the linker.
Can you use the C/C++ compiler as the linker in your toolchain? I think that ld.lld
just shouldn't be returned from get_tool_for_action
.
Description of the bug:
cc_common.get_memory_inefficient_command_line
returns a set of flags to pass to the cc tool given bycc_common.get_tool_for_action
.I have cc toolchain setup that uses
ld.lld
as a linker. Here, I haverpaths
pointing to a shared library path. As the result,link_args
contains"-Xlinker" "-rpath" "-Xlinker" "$ORIGIN/../bazel/toolchains/rust/aarch64-linux-android/rust_toolchain/lib/rustlib/aarch64-linux-android/lib"
. However,ld.lld
(returned fromcc_common.get_tool_for_action
) does not support the-Xlinker
flag.Ideally,
cc_common.get_memory_inefficient_command_line
should only provide flags that are valid to the corresponding tool.Which category does this issue belong to?
C++/Objective-C Rules, Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
-Xlinker
flag herecd examples/nix_cross_compiling
bazel build //rust_binary:rust_binary_aarch64-linux-android --@rules_rust//rust/settings:std_dylib=True
The error is
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 7.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response