Clang and multilib search paths

Hi again,

This is a follow up from the previous thread.

When I use crtbegin.S and crtend.S for x86_64 from OpenBSD, and
place the assembled *.o files in /usr/lib/clang/3.9.0, I can
compile a 64 bit program, and it will use crtbegin.o and crtend.o
from /usr/lib/clang/3.9.0, which I can confirm by running clang
with -v.

However, this is also a multilib system. I have 32 bit clang
runtime in /usr/lib32/clang/3.9.0. If I assemble crtbegin.S and
crtend.S for i386, and place them in the mentioned dir, clang
won't pick them up. It tries to use ones from /usr/lib/clang/3.9.0
when compiling a test program with clang -m32.

Everything's okay and it picks up gcc's 32 bit files just fine. And,
of course, it works too when I explicitly use -B/usr/lib32/clang/3.9.0.

So, the question is:

How to make clang automatically search /usr/lib32/clang/3.9.0? or
Is there another directory the 32 bit files should be placed in?

Thanks in advance!

After spending some hours on hacking the clang source, I came up
with the following patch.

clang-runtime.patch (2.44 KB)

Hi Armin,

Please upload your patch to reviews.llvm.org [1]. Be sure to add a reviewer
(perhaps Sylvestre Ledru) and subscribe cfe-commits to the review.

best
vedant

[1] http://llvm.org/docs/Phabricator.html

Hi Armin,

Please upload your patch to reviews.llvm.org [1]. Be sure to add a reviewer
(perhaps Sylvestre Ledru) and subscribe cfe-commits to the review.

best
vedant

[1] http://llvm.org/docs/Phabricator.html

Hi, I don't think patch is upstreamable, as it changes default runtime
to compiler-rt for all of linux. This was just an FYI. Also, I can't
submit it with current distro detection, as all Linux From Scratch users
would be affected, and I can't allow that.

Hi Armin,

I just sent a patch for clang a few days ago, which allows the default
runtime lib to be set at build time (either libgcc or compiler-rt). It
might be helpful to you.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160711/164903.html

BTW, I haven't got any response after sending that patch. Could
someone help reviewing it?

Thanks,
Lei

Hi Armin,

Please upload your patch to reviews.llvm.org [1]. Be sure to add a reviewer
(perhaps Sylvestre Ledru) and subscribe cfe-commits to the review.

best
vedant

[1] http://llvm.org/docs/Phabricator.html

Hi, I don't think patch is upstreamable, as it changes default runtime
to compiler-rt for all of linux. This was just an FYI. Also, I can't
submit it with current distro detection, as all Linux From Scratch users
would be affected, and I can't allow that.

Hi Armin,

I just sent a patch for clang a few days ago, which allows the default
runtime lib to be set at build time (either libgcc or compiler-rt). It
might be helpful to you.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160711/164903.html

BTW, I haven't got any response after sending that patch. Could
someone help reviewing it?

The patch looks fine to me, but I don't think I can lgtm it.

I suggest uploading the patch to Phab and adding one or two suitable reviewers.
E.g in this case, looking through the git history, Mike Spertus and/or Chris
Bieneman could be good reviewers.

vedant

Thanks for your advice :slight_smile:

Now submitted: https://reviews.llvm.org/D22663

Lei