-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
untriagedTeam member has to triage this issue - assign priority, type, and owner (if possible).Team member has to triage this issue - assign priority, type, and owner (if possible).
Description
The path to lld is detected by invoking clang empty.cc -v and inspect the last line of the output:
rules_cc/cc/private/toolchain/unix_cc_configure.bzl
Lines 200 to 201 in 30977f2
| linker_command = result.stderr.splitlines()[-1] | |
| return linker_command.strip().split(" ")[0].strip("\"'") |
However lld may emit warnings (see below) building empty.cc and subsequently breaks the detection logic resulting in an argument of the form -fuse-ld=ld64.lld: (note the colon at the end) being passed to the compiler.
Here is one situation when lld emits a warning.
- Apple Clang is detected as the compiler and
ld64.lldis present in PATH (for example installed by homebrew). - Apple Clang then calls
ld64.lldwith-L/usr/local/libin the flags. - If the directory
/usr/local/libdoes not exist, then lld emits a warning.
In this situation, the last lines ofresult.stderris
... (omitted)
End of search list.
"/opt/homebrew/bin/ld64.lld" -demangle -no_deduplicate -dynamic -arch arm64 -platform_version macos 15.0.0 15.2 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mllvm -enable-linkonceodr-outlining -o /dev/null -L/usr/local/lib /var/folders/0v/nn5rkhrs3r72b72dfbrlwfbh0000gn/T/empty-da6fa5.o --start-lib --end-lib -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/lib/darwin/libclang_rt.osx.a
ld64.lld: warning: directory not found for option -L/usr/local/lib
How to reproduce
MODULE.bazel
bazel_dep(name = "rules_cc", version = "0.2.10")
BUILD.bazel
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary(
name = "hello-world",
srcs = ["main.cc"],
)
main.cc
int main() { return 0; }
Command:
bazel build //:hello-world
Metadata
Metadata
Assignees
Labels
untriagedTeam member has to triage this issue - assign priority, type, and owner (if possible).Team member has to triage this issue - assign priority, type, and owner (if possible).