Linking fails while compiling Intel TBB 2019 U6 for IA32 target with Clang/LD and LLD

Hi,

I do see another issue while trying to compile TBB 2019 U6 for the Intel 32 bit target with Clang. Compilation seems fine, but at the linking stage it errors out. All is fine if I compile with Clang for the Intel 64 bit target. Unfortunately I need the 32 bit binaries. >:(

If I use LLD, I get the following (snippet):

ld.lld: **error: **/usr/bin/…/lib64/gcc/x86_64-suse-linux/10/32/crtbeginS.o is incompatible with elf_i386
ld.lld: **error: **concurrent_hash_map.o is incompatible with elf_i386

and if I use the default LD I get:

/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/libdl.so when searching for -ldl
/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/libpthread.so when searching for
-lpthread
/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/librt.so when searching for -lrt
/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/libc++.so.1 when searching for l
ibc++.so.1
/usr/bin/ld: cannot find libc++.so.1
/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/libc++abi.so when searching for
-lc++abi
/usr/bin/ld: cannot find -lc++abi
/usr/bin/ld: skipping incompatible /usr/bin/…/lib64/gcc/x86_64-suse-linux/10/…/…/…/libm.so when searching for -lm
clang-9.0: **error: **linker command failed with exit code 1 (use -v to see invocation)

Clang version is the following:
clang version 9.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/…/lib64/gcc/x86_64-suse-linux/10
Found candidate GCC installation: /usr/bin/…/lib64/gcc/x86_64-suse-linux/8
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/10
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/8
Selected GCC installation: /usr/bin/…/lib64/gcc/x86_64-suse-linux/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

Any clues how to solve this? The selected m64 multilib seems suspicious to me.

Googling around for bug entries and workarounds, I’ve stumbled on thus bugzilla entry from Clang upstream: https://bugs.llvm.org/show_bug.cgi?id=12108 and here specifically for OpenSuse: https://bugzilla.novell.com/show_bug.cgi?id=804088#c0

As my issue seems to be the same and still persists with Tumbleweed from May 14th 2019 and Clang 9.0 (older versions were also affected), I wouldn’t call it resolved. I’ll try the mentioned workaround there and report back.

After some experiments I got it to compile and work:

With the workaround mentioned in https://bugzilla.novell.com/show_bug.cgi?id=804088#c5 (unsure if it had any effect) and

LIB_LINK_FLAGS += -m32 -target i386 

using

make -j5 compiler=clang stdver=c++17 arch=ia32


This was achieved while using LD. I still get undefined symbol errors in my application if I try to link with LLD.