When cross-building a C++ compiler for the Aarch64 platform on a x86-64 host, the build fails while configuring libstdc++-v3. Reproducible: Always Steps to Reproduce: 1. emerge crossdev; 2.crossdev -S -t aarch64-none-elf -s4 --env 'USE="-fortran -mudflap -nls -openmp -multilib"' Actual Results: Failed build, with: checking for library containing clock_gettime... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES. Expected Results: A working cross-compiler. This problem is caused by the use of the --enable-libstdcxx-time configuration flag in the gcc ebuild. If this flag is not set when configuring gcc, the build works. That flag originates in toolchain.eclass, which sets --enable-libstdcxx-time for any compiler version 4.4 or above. Below is a patch to portage which adds a 'cxx-time' use flag, which allows one to workaround the problem by manually turning off the (default on) cxx-time flag. This does the job for me, and is low risk, but it feels very heavyhanded to add a use flag for this very obscure case. An alternative would be to explicitly disable the setting of --enable-libstdcxx-time for cross-builds with an aarch64 target (as in the second patch below). This also works for me, and has the advantages of being automatic (nobody has to figure out to use the new, obscure use flag) and doesn't pollute the use flag name space. But it hides important magic in a hard to find place (I know, because it took me most of a day to find it). I leave it to greater minds than mine to decide which fix is better (or if there is another, better one). ======== Patch 1: add cxx-time use flag ========== diff -r 189acb647526 eclass/toolchain.eclass --- a/eclass/toolchain.eclass Wed Sep 16 12:42:54 2015 -0600 +++ b/eclass/toolchain.eclass Wed Sep 16 13:05:55 2015 -0600 @@ -146,6 +146,7 @@ tc_version_is_at_least 4.1 && IUSE+=" libssp objc++" tc_version_is_at_least 4.2 && IUSE_DEF+=( openmp ) tc_version_is_at_least 4.3 && IUSE+=" fixed-point" + tc_version_is_at_least 4.4 && IUSE+=" +cxx-time" tc_version_is_at_least 4.7 && IUSE+=" go" # Note: while <=gcc-4.7 also supported graphite, it required forked ppl # versions which we dropped. Since graphite was also experimental in @@ -897,7 +898,7 @@ # allow gcc to search for clock funcs in the main C lib. # if it can't find them, then tough cookies -- we aren't # going to link in -lrt to all C++ apps. #411681 - if tc_version_is_at_least 4.4 && is_cxx ; then + if tc_version_is_at_least 4.4 && is_cxx && uses cxx-time ; then confgcc+=( --enable-libstdcxx-time ) fi diff -r 189acb647526 sys-devel/gcc/metadata.xml --- a/sys-devel/gcc/metadata.xml Wed Sep 16 12:42:54 2015 -0600 +++ b/sys-devel/gcc/metadata.xml Wed Sep 16 13:05:55 2015 -0600 @@ -6,6 +6,7 @@ <flag name="awt">Useful only when building GCJ, this enables Abstract Window Toolkit (AWT) peer support on top of GTK+</flag> <flag name="cilk">Support the Cilk Plus language (C/C++ based languages for parallel programming)</flag> + <flag name="cxx-time">Enable the gcc enable-libstdcxx-time configuration flag</flag> <flag name="d">Enable support for the D programming language</flag> <flag name="fixed-point">Enable fixed-point arithmetic support for MIPS targets in gcc (Warning: significantly increases compile time!)</flag> ====== patch 2: automagically suppress cxx-time flag for cross-compiled aarch64 compilers. ===== diff -r 189acb647526 eclass/toolchain.eclass --- a/eclass/toolchain.eclass Wed Sep 16 12:42:54 2015 -0600 +++ b/eclass/toolchain.eclass Wed Sep 16 14:44:35 2015 -0600 @@ -898,7 +898,15 @@ # if it can't find them, then tough cookies -- we aren't # going to link in -lrt to all C++ apps. #411681 if tc_version_is_at_least 4.4 && is_cxx ; then - confgcc+=( --enable-libstdcxx-time ) + if is_crosscompile ; then + # Suppress --enable-libstdcxx-time for cross-build aarch64 compilers. + case ${CTARGET} in + aarch64-*) ;; + *) confgcc+=( --enable-libstdcxx-time ) ;; + esac + else + confgcc+=( --enable-libstdcxx-time ) + fi fi # # Turn on the -Wl,--build-id flag by default for ELF targets. #525942
Created attachment 412078 [details, diff] Patch which automagically suppresses evil flag when configuring cross-compiled aarch64 compiler.
Created attachment 412080 [details, diff] Patch which adds a use flag to suppress the evil flag manually.
PS: I belatedly realize that this bug looks very similar to #515648.
jimi portage # emerge --info Portage 2.2.20.1 (python 2.7.9-final-0, default/linux/amd64/13.0, gcc-4.8.5, glibc-2.20-r2, 4.0.5-gentoo x86_64) ================================================================= System uname: Linux-4.0.5-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_960_@_3.20GHz-with-gentoo-2.2 KiB Mem: 12301620 total, 1811628 free KiB Swap: 0 total, 0 free Timestamp of repository gentoo: Wed, 16 Sep 2015 18:30:01 +0000 sh bash 4.3_p39 ld GNU ld (Gentoo 2.24 p1.4) 2.24 app-shells/bash: 4.3_p39::gentoo dev-java/java-config: 2.2.0::gentoo dev-lang/perl: 5.20.2::gentoo dev-lang/python: 2.7.9-r1::gentoo, 3.3.5-r1::gentoo, 3.4.1::gentoo dev-util/cmake: 3.2.2::gentoo dev-util/pkgconfig: 0.28-r2::gentoo sys-apps/baselayout: 2.2::gentoo sys-apps/openrc: 0.17::gentoo sys-apps/sandbox: 2.6-r1::gentoo sys-devel/autoconf: 2.13::gentoo, 2.69::gentoo sys-devel/automake: 1.11.6-r1::gentoo, 1.13.4::gentoo, 1.14.1::gentoo, 1.15::gentoo sys-devel/binutils: 2.24-r3::gentoo sys-devel/gcc: 4.6.4::gentoo, 4.8.5::gentoo sys-devel/gcc-config: 1.7.3::gentoo sys-devel/libtool: 2.4.6::gentoo sys-devel/make: 4.1-r1::gentoo sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers) sys-libs/glibc: 2.20-r2::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 arm-cross-build location: /usr/local/portage masters: gentoo priority: 0 ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="*" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.0/conf" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-march=native -O2 -pipe" DISTDIR="/usr/portage/distfiles" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://gentoo.mirrors.hoobly.com/ http://gentoo.mirrors.tds.net/gentoo http://gentoo.netnitco.net rsync://gentoo.gossamerhost.com/gentoo-distfiles/ http://gd.tuwien.ac.at/opsys/linux/gentoo/" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j 9" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" USE="X aac acl alsa amd64 bash-completion berkdb bzip2 cli cracklib crypt cxx dri fortran gdbm gif iconv icu jpeg mmx mmxext modules mp3 multilib ncurses nls nptl nvidia ogg opengl openmp pam pcre png python qt3support readline seccomp session sse sse2 ssl svg tcpd truetype unicode xcb xinerama zlib" ABI_X86="64 32" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby19 ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="nvidia vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
we're not making the configure flag into a USE flag *** This bug has been marked as a duplicate of bug 515648 ***