[cfe-dev] Possible mismatch between compiler-rt library naming and clang library search (on Linux)

Michał Górny via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 14 06:10:37 PST 2016


Hello,

One of our users recently (well, it is not that recent anymore)
reported that our clang install is unable to find compiler-rt libraries
on 32-bit x86. As I suspected, the problem is that our default CHOST is
i686-pc-linux-gnu, while the compiler-rt libraries are built with i386
suffix.

I can easily reproduce this on multilib x86_64 system as well, using
the -target option:

  clang -v -m32 hello.c              # works, uses i386
  clang -v -target i386-pc-linux-gnu # works
  clang -v -target i686-pc-linux-gnu # fails, looks for i686
  clang -v -target i586-pc-linux-gnu # fails, looks for i586

I think the relevant function is ToolChain::getCompilerRT() from
lib/Driver/ToolChain.cpp. It seems to use arch name straight from
the triple, with some special cases.

On the other hand, compiler-rt seems to allow only a few very specific
names:

  set(X86 i386 i686)
  set(X86_64 x86_64)

while I don't know the rationale for allowing both i386 and i686, this
is certainly much narrower than what clang looks for.

Do you have any suggestions how we could improve this? I was thinking
of making the clang driver use Triple::getArchTypeName() rather than
the raw arch string but I don't know if I wouldn't break somebody's use
case.

Alternatively, I could add compiler-rt symlinks for i486..i686 but that
seems like a very non-pretty solution. And clang seems to accept
triples up to i986.

Thanks in advance.

[1]:https://bugs.gentoo.org/show_bug.cgi?id=592964

-- 
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 931 bytes
Desc: OpenPGP digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161114/e496d662/attachment.sig>


More information about the cfe-dev mailing list