[PATCH] binutils: Use AC_TRY_COMPILE to check target clang/gcc

Sam James sam@gentoo.org
Mon Oct 13 14:14:29 GMT 2025


Sam James <sam@gentoo.org> writes:

> Alan Modra <amodra@gmail.com> writes:
>
>> On Thu, Oct 02, 2025 at 04:33:17PM +0800, H.J. Lu wrote:
>>> On Thu, Oct 2, 2025 at 4:18 PM Alan Modra <amodra@gmail.com> wrote:
>>> > Also, can someone tell me why we need to invoke llvm-config?  Are
>>> > there versions or installations of clang where
>>> >   clang --print-file-name LLVMgold.so
>>> > does not find/print the path to LLVMgold.so, but
>>> >   `llvm-config --libdir`/LLVMgold.so
>>> > will?  If it is only old versions or broken installations of clang,
>>> > then should we bother?
>>> >
>>> 
>>> See:
>>> 
>>> https://sourceware.org/bugzilla/show_bug.cgi?id=33198
>>> 
>>> for why llvm-config is used.
>>
>> That tells me Sam found that clang --print-file-name LLVMgold.so
>> didn't work.  Sam, do you know why?
>
> I'll check it out more.

OK, building on https://sourceware.org/bugzilla/show_bug.cgi?id=33470#c1:

On my system, I get:

$ clang --print-file-name LLVMgold.so
LLVMgold.so

Clang searches under /usr/lib/clang/21 (and so on) but the plugin is
installed at /usr/lib/llvm/21/lib64/LLVMgold.so because it's part of the
LLVM component(s), rather than the Clang component(s).

Neither of Clang's --print-file-name, nor --print-search-dirs look at
LLVM directories.

Looking at the LLVM testsuite, I see a bunch of llvmshlibdir = ... =
LLVM_LIBRARY_OUTPUT_INTDIR, and eventually:
 llvm/CMakeLists.txt:set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir

In a Debian stable container, I see:

checking for clang for target... yes
checking for clang plugin file for target... /usr/lib/llvm-19/lib/clang/19/../../LLVMgold.so

which is /usr/lib/llvm-19/lib/LLVMgold.so.

Anyway, in the end, TL;DR:
* On Gentoo, we search last
access("/usr/lib/llvm/21/bin/../../../../lib/clang/21/../../LLVMgold.so",
F_OK) = -1 ENOENT (No such file or directory)

* On Debian, we search last
access("/usr/lib/llvm-19/lib/clang/19/../../LLVMgold.so", F_OK) = 0
and succeed (same if we move it away).

I filed https://bugs.gentoo.org/964282 on our end in Gentoo for it but
it looks like it's related to a patch they're reverting in Debian:
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/blob/snapshot/debian/patches/D148945-revert.diff.

I don't see an obvious sign that we're doing anything wrong in our
packaging of LLVM, or any other proper way of getting the path than
llvm-config right now.

I've asked some people for input though.


More information about the Binutils mailing list