Skip to content

Add linker dir to bin_search_flags for lld/gold for non-Clang compilers#571

Open
sin-ack wants to merge 1 commit intobazelbuild:mainfrom
sin-ack:fix-linker-path-search-for-gcc
Open

Add linker dir to bin_search_flags for lld/gold for non-Clang compilers#571
sin-ack wants to merge 1 commit intobazelbuild:mainfrom
sin-ack:fix-linker-path-search-for-gcc

Conversation

@sin-ack
Copy link
Copy Markdown

@sin-ack sin-ack commented Jan 21, 2026

Clang allows a full path to be passed to -fuse-ld=. However, GCC (and others?) don't allow this. If gold or lld is selected, the linker is not on a standard path (e.g. Gentoo, which allows multiple versions of LLVM to be installed in /usr/lib/llvm/<major>/) and --incompatible_strict_action_env is enabled, GCC won't know where the linker is located and fail to find the linker.

Now we always return the full linker path, and pass -fuse-ld= based on the compiler identity.

Fixes bazelbuild/bazel#26527.

Clang allows a full path to be passed to -fuse-ld=. However, GCC (and
others?) don't allow this. If gold or lld is selected, the linker is not
on a standard path (e.g. Gentoo, which allows multiple versions of LLVM
to be installed in /usr/lib/llvm/<major>/) and
--incompatible_strict_action_env is enabled, GCC won't know where the
linker is located and fail to find the linker.

Now we always return the full linker path, and pass -fuse-ld= based on
the compiler identity.

Fixes bazelbuild/bazel#26527.
@sin-ack
Copy link
Copy Markdown
Author

sin-ack commented Jan 21, 2026

Build failures appear to be docs related.

@armandomontanez armandomontanez added type: bug Something that should be working isn't working P2 We'll consider working on this in future. (Assignee optional) labels Mar 26, 2026
@hvadehra hvadehra removed their request for review April 21, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: toolchains P2 We'll consider working on this in future. (Assignee optional) type: bug Something that should be working isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linker path not passed in with -B when linker is auto-selected by Bazel

2 participants