Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 667108 - sys-devel/llvm:6 cannot be crosscompiled via cross-emerge, unless host binutils is built with USE="-multitarget"
Summary: sys-devel/llvm:6 cannot be crosscompiled via cross-emerge, unless host binuti...
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-26 09:15 UTC by tt_1
Modified: 2019-09-17 19:41 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
compressed build.log (llvm-6.0.1-failed-cross-compile.log.gz,98.45 KB, application/gzip)
2018-09-26 09:18 UTC, tt_1
Details
output of emerge --info (host-emerge-info,6.80 KB, text/plain)
2018-09-26 09:21 UTC, tt_1
Details
Chewi's build info (chewi.txt,7.21 KB, text/plain)
2018-09-26 20:29 UTC, James Le Cuirot
Details
output of emerge --info (hosts-build-info,6.08 KB, text/plain)
2018-09-26 20:58 UTC, tt_1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2018-09-26 09:15:14 UTC
Before I start to explain this - do we all agree that first of all the host has to have sys-devel/binutils with USE="multitarget" installed, and that crossdev -S armv7a-unkown-linux-gnueabihf with USE="-multitarget" for cross-binutils is the proper way to setup a cross-compile toolchain? 

Ok, here's the problem: using emerge-armv7a-unknown-hardfloat-gnueabihf, or whatever your desired target may be, is a pure joy for a target as @system. Only python stuff is a bit whacky. However, it fails for the case of llvm with an error which seeems to be related to llvm-config perhaps? 



[106/113] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o
[107/113] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/YAMLParser.cpp.o
[108/113] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o
[109/113] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o
[110/113] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Path.cpp.o
[111/113] Building CXX object tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
[112/113] Linking CXX static library lib/libLLVMSupport.a
[113/113] Linking CXX executable bin/llvm-config
FAILED: bin/llvm-config 
: && /usr/bin/armv7a-unknown-linux-gnueabihf-g++  -O2 -pipe -fomit-frame-pointer -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wl,-O1 -Wl,--as-needed -Wl,-allow-shlib-undefined    -Wl,-rpath-link,/usr/armv7a-unknown-linux-gnueabihf/tmp/portage/sys-devel/llvm-6.0.1/work/llvm-6.0.1.src-.arm/NATIVE/./lib  -Wl,-O3 -Wl,--gc-sections tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o  -o bin/llvm-config  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.a -lpthread -lz -lrt -ldl -lcurses -lpthread -lm lib/libLLVMDemangle.a && :
lib/libLLVMSupport.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


I'll add the full build log
Comment 1 tt_1 2018-09-26 09:18:51 UTC
Created attachment 547952 [details]
compressed build.log

this is for llvm-6.0.1, but it's the same error for llvm-6.0.1-r1
Comment 2 tt_1 2018-09-26 09:21:48 UTC
Created attachment 547954 [details]
output of emerge --info

this is the emerge --info from the host
Comment 3 tt_1 2018-09-26 09:31:50 UTC
these are the useflags for the host cross compiler: 

[ebuild   R   ~] cross-armv7a-unknown-linux-gnueabihf/binutils-2.30-r4:2.30::own  USE="cxx nls -doc -multitarget -static-libs -test" 0 KiB

[ebuild   R    ] cross-armv7a-unknown-linux-gnueabihf/glibc-2.26-r7:2.2::own  USE="-audit -caps -debug -doc -gd -hardened -headers-only -multilib -nscd -profile (-selinux) -suid -systemtap -vanilla" 0 KiB

cross-armv7a-unknown-linux-gnueabihf/gcc-7.3.0-r5:7.3.0::own  USE="cxx fortran nls nptl openmp pch pie sanitize ssp (-altivec) -cilk -debug -doc (-fixed-point) -go -graphite -hardened -jit -libssp -mpx -multilib -objc -objc++ -objc-gc -pgo -regression-test -vanilla -vtv" 0 KiB


these are the useflags for the hosts sys-devel/binutils: 

[ebuild   R    ] sys-devel/binutils-2.30-r2:2.30::gentoo  USE="cxx multitarget nls -doc -static-libs -test" 0 KiB


If it matters, I have included ARM into LLVM_TARGETS on the machine:

[ebuild   R   ~] sys-devel/llvm-6.0.1-r1:6::gentoo  USE="gold libffi ncurses xml -debug -doc -libedit -test -xar" ABI_X86="32 (64) (-x32)" LLVM_TARGETS="AMDGPU ARM (X86) -AArch64 -BPF -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore" 0 KiB
Comment 4 James Le Cuirot gentoo-dev 2018-09-26 13:53:25 UTC
First of all, I've never enabled USE="multitarget" and I didn't even know what it did until now. I gather it allows your "native" binutils to target every supported CPU and OS combination. In practise, this would not be used when building our packages because your cross gcc will use your cross binutils and not touch your native binutils at all.

Regarding the Python stuff, I have done good work on that but it's not quite ready yet.

I'm not convinced that the LLVM problem is cross-related. I found a similar report here although it doesn't look like you've explicitly enabled LTO anywhere.

https://bugs.llvm.org/show_bug.cgi?id=35153
Comment 5 James Le Cuirot gentoo-dev 2018-09-26 18:55:50 UTC
Did you try LLVM 7 yet? I just cross-built it for ARM with no problems.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-09-26 18:58:12 UTC
@Chewi, could you test without -DLLVM_TABLEGEN, please?  I think this should be unnecessary, and it would be helpful to confirm that.
Comment 7 James Le Cuirot gentoo-dev 2018-09-26 19:11:18 UTC
(In reply to Michał Górny from comment #6)
> @Chewi, could you test without -DLLVM_TABLEGEN, please?  I think this should
> be unnecessary, and it would be helpful to confirm that.

That's still required but it would be good to solve that the other way.

/bin/sh: /var/tmp/portage/sys-devel/llvm-7.0.0/work/llvm-7.0.0.src-.arm/NATIVE/bin/llvm-tblgen: cannot execute binary file: Exec format error
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-09-26 19:20:52 UTC
I'm guessing you need to tell CMake about the native compiler somehow ;-).
Comment 9 tt_1 2018-09-26 19:59:08 UTC
@Chewi no I haven't, actually got stuck with llvm:6 for the last couple of days. But I may try straight away. Could you please post your hosts emerge --info and useflags for binutils, cross-binutils and cross-gcc?
Comment 10 James Le Cuirot gentoo-dev 2018-09-26 20:29:57 UTC
Created attachment 548002 [details]
Chewi's build info

Here you go.
Comment 11 tt_1 2018-09-26 20:58:00 UTC
Created attachment 548004 [details]
output of emerge --info

You don't seems to have nls in your cross compiler, don't use multitarget for the system-binutils and are on unstable glibc/gcc. Is 2.30-r2 your active binutils, since you're having 2.31.1 as well? The ebuilds are the usual symlinks to the tree from an overlay, no modification, right? 

[ebuild   R    ] sys-devel/binutils-2.30-r2:2.30::gentoo  USE="cxx multitarget nls -doc -static-libs -test" 0 KiB
[ebuild   R   ~] cross-armv7a-unknown-linux-gnueabihf/binutils-2.30-r4:2.30::own  USE="cxx nls -doc -multitarget -static-libs -test" 0 KiB
[ebuild   R   ~] cross-armv7a-unknown-linux-gnueabihf/gcc-7.3.0-r5:7.3.0::own  USE="cxx fortran nls nptl openmp pch pie sanitize ssp (-altivec) -cilk -debug -doc (-fixed-point) -go -graphite -hardened -jit -libssp -mpx -multilib -objc -objc++ -objc-gc -pgo -regression-test -vanilla -vtv" 0 KiB

Needless to say that my cross-emerge of llvm-7 failed with the same error. And I had to emerge llvm-7 on my hosts machine first, for llvm-tblgen. And even though I kind of like the idea to get rid of it, the llvm/clang cross-compile reference states that tblgen-llvm (from the host) is mandantory, and both tblgen-clang + tblgen-llvm to cross-compile clang. 

https://llvm.org/docs/HowToCrossCompileLLVM.html

The different sys-gcc and sys-glibc shouldn't be relevant. So guess I'm going to flipp around some useflags of my crossdev toolchain, but won't make it before the weekend for results to share.
Comment 12 James Le Cuirot gentoo-dev 2018-09-26 21:05:57 UTC
(In reply to tt_1 from comment #11)
> You don't seems to have nls in your cross compiler, don't use multitarget
> for the system-binutils and are on unstable glibc/gcc. Is 2.30-r2 your
> active binutils, since you're having 2.31.1 as well? The ebuilds are the
> usual symlinks to the tree from an overlay, no modification, right? 

nls is irrelevant. I would definitely disable multitarget, it would not surprise me if that were the issue. I did realise as I was generating that info that I hadn't yet selected the latest installed. Now fixed. :) Although I do some strange things in my cross-boss project, what you see here is plain crossdev and toolchain packages with no modifications or hacks.
Comment 13 tt_1 2018-09-26 22:13:21 UTC
So yeah, I was able to cross-emerge =llvm-6.0.1-r1 for armv7a as I removed the multitarget useflag from sys-devel/binutils. 

Shall I open a new bug for sys-devel/binutils then?

We may continue our discussion about llvm-tblegen here?
Comment 14 James Le Cuirot gentoo-dev 2018-09-27 09:09:53 UTC
(In reply to tt_1 from comment #13)
> So yeah, I was able to cross-emerge =llvm-6.0.1-r1 for armv7a as I removed
> the multitarget useflag from sys-devel/binutils. 

Woo!

> Shall I open a new bug for sys-devel/binutils then?

I doubt the problem is with binutils itself. It may be specific to llvm or it could affect many more packages, how many have you tried? If it's the latter, it probably isn't worth fixing and we should clarify the multitarget USE flag description.

> We may continue our discussion about llvm-tblegen here?

May as well.
Comment 15 tt_1 2019-01-28 21:31:36 UTC
this is confusing: 

llvm fails to build with USE=gold, but there are two errors - one if binutils is built with USE="-multitarget", and another on if binutils is built with USE="multitarget"

since all USE="gold" does is adding a second include directory: 
-DLLVM_BINUTILS_INCDIR="/"${EPREFIX}/usr/include" I wonder if there is some sort of missmatch going on. 

I'll upload logs within a few days, too busy at the moment.
Comment 16 tt_1 2019-01-29 14:25:28 UTC
I just learnt that the symlinks for libbfd and libopcodes libararies are slightly different, to reflect abi breakage. Does this mean, the cross-binutils built by crossdev, the hosts binutils and possibly the cross-emerged binutils in /usr/armv7a-unknown-linux-gnueabihf/ should be in sync?

its either: 
libbfd-2.30.0.gentoo-sys-devel-binutils-st.so
libopcodes-2.30.0.gentoo-sys-devel-binutils-st.so

or: 
libbfd-2.30.0.gentoo-sys-devel-binutils-mt.so
libopcodes-2.30.0.gentoo-sys-devel-binutils-mt.so
Comment 17 tt_1 2019-03-05 07:53:23 UTC
I tried to sync the multitarget use flag:

hosts binutils+binutils-libs: +multitarget
crossdev toolchain binutils: +multitarget
cross-emerged binutils-libs: +multitarget

but it still fails the same way, and works if all is reverted to -multitarget.
Comment 18 tt_1 2019-09-17 19:41:55 UTC
I can't reproduce anymore with current llvm-9