Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

[Solved] Cross-emerge fail, portage use host CFLAGS on targe

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
ivan2k
n00b
n00b
User avatar
Posts: 59
Joined: Fri Sep 10, 2010 12:59 pm
Location: TV, Italy

[Solved] Cross-emerge fail, portage use host CFLAGS on targe

  • Quote

Post by ivan2k » Thu Feb 26, 2026 6:39 pm

Hello all,
i have a systemd-nspawn machine with a stage3 + crossdev, used to build for an arm SBC. In this machine, portage is configured with the host CFLAGS (in my case an AMD FX-8350 CPU).
The destination root filesystem of the SBC is mounted at /usr/aarch64-unknown-linux-gnu and inside portage is configured with the target CFLAGS.

I have emerged all @system set using aarch64-unknown-linux-gnu-emerge with success, and the SBC boot.
Now i have tried to install u-boot-tools with:

Code: Select all

aarch64-unknown-linux-gnu-emerge u-boot-tools
But failed with this message (full command line included for reference):

Code: Select all

aarch64-unknown-linux-gnu-gcc -Wp,-MD,tools/env/.crc32.o.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer  -O2 -pipe -march=bdver2 -mno-lwp --param l1-cache-size=16 --param l1-cache-line-size=64 --param l2-cache-size=2048    -std=gnu11   -I./tools -idirafterinclude -idirafter./arch/sandbox/include -idirafter./dts/upstream/include -idirafter ./tools/env -DUSE_HOSTCC -DTEXT_BASE=  -c -o tools/env/crc32.o tools/env/crc32.c
aarch64-unknown-linux-gnu-gcc: error: unrecognized command-line option ‘-mno-lwp’
It call the cross-compiler passing the CFLAGS of the build system !!
This behavior is similar to what i have reported here: https://forums.gentoo.org/viewtopic-t-1176946.html

In the log there are more traslation unit compiled with the build system compiler x86_64-pc-linux-gnu-gcc with the same CFLAGS, which I think is correct. But it is not correct that these flags are passed to the cross-compiler.

EDIT: Solution in https://forums.gentoo.org/viewtopic-p-8 ... ml#8881060
Last edited by ivan2k on Sat Feb 28, 2026 9:03 am, edited 1 time in total.
Top
sam_
Developer
Developer
User avatar
Posts: 2814
Joined: Fri Aug 14, 2020 12:33 am

  • Quote

Post by sam_ » Thu Feb 26, 2026 7:01 pm

Please share the full build.log and emerge --info, as Portage tells you to do upon failure.
Top
ivan2k
n00b
n00b
User avatar
Posts: 59
Joined: Fri Sep 10, 2010 12:59 pm
Location: TV, Italy

  • Quote

Post by ivan2k » Thu Feb 26, 2026 7:15 pm

The build.log is very long, do you have any advice on how I can post this so as not to create a very long message?

Output of emerge --info:

Code: Select all

Portage 3.0.77 (python 3.13.11-final-0, default/linux/amd64/23.0/systemd, gcc-15, glibc-2.42-r5, 6.18.12-gentoo_zeruel x86_64)
=================================================================
System uname: Linux-6.18.12-gentoo_zeruel-x86_64-AMD_FX-tm-8350_Eight-Core_Processor-with-glibc2.42
KiB Mem:    31750228 total,  13866620 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 26 Feb 2026 17:00:55 +0000
sh bash 5.3_p9
ld GNU ld (Gentoo 2.45.1 p1) 2.45.1
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.3_p9::gentoo
dev-build/autoconf:        2.72-r6::gentoo
dev-build/automake:        1.18.1::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r102::gentoo
dev-build/meson:           1.9.2::gentoo
dev-lang/perl:             5.42.0-r1::gentoo
dev-lang/python:           3.13.11::gentoo, 3.14.0_p1::gentoo
sys-apps/baselayout:       2.18::gentoo
sys-apps/sandbox:          2.46::gentoo
sys-apps/systemd:          258.3::gentoo
sys-devel/binutils:        2.45.1::gentoo
sys-devel/binutils-config: 5.6::gentoo
sys-devel/gcc:             15.2.1_p20251122::gentoo
sys-devel/gcc-config:      2.12.2::gentoo
sys-kernel/linux-headers:  6.18::gentoo (virtual/os-headers)
sys-libs/glibc:            2.42-r5::gentoo
Repositories:

gentoo
location: /var/db/repos/gentoo
sync-type: rsync
sync-uri: rsync://rsync.gentoo.org/gentoo-portage
priority: -1000
volatile: False
sync-rsync-extra-opts:
sync-rsync-verify-jobs: 1
sync-rsync-verify-max-age: 3
sync-rsync-verify-metamanifest: yes

crossdev
location: /var/db/repos/crossdev
masters: gentoo
volatile: False

Binary Repositories:

gentoo
location: /var/cache/binhost/gentoo
priority: 1
sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64
verify-signature: True

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=bdver2 -mno-lwp --param l1-cache-size=16 --param l1-cache-line-size=64 --param l2-cache-size=2048"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d"
CXXFLAGS="-O2 -pipe -march=bdver2 -mno-lwp --param l1-cache-size=16 --param l1-cache-line-size=64 --param l2-cache-size=2048"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" -j2 -l9"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=bdver2 -mno-lwp --param l1-cache-size=16 --param l1-cache-line-size=64 --param l2-cache-size=2048"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live compress-index config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=bdver2 -mno-lwp --param l1-cache-size=16 --param l1-cache-line-size=64 --param l2-cache-size=2048"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
MAKEOPTS="-j8 -l9"
PKGDIR="/var/cache/binpkgs"
PORTAGE_COMPRESS="bzip2"
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 --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RUSTFLAGS=" -C target-cpu=bdver2"
SHELL="/bin/bash"
USE="acl amd64 bzip2 cet crypt gdbm iconv ipv6 libtirpc multilib ncurses nls openmp pam pcre readline seccomp ssl systemd test-rust udev unicode xattr zlib"ABI_X86="64" ADA_TARGET="gcc_15" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3 sse4_1 sse4_2 sse4a popcnt aes avx f16c xop fma3 fma4 bmi1 pclmul" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oncore skytraq superstar2 tsip tripmate tnt" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LLVM_TARGETS="X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-3" POSTGRES_TARGETS="postgres17" PYTHON_SINGLE_TARGET="python3_13" PYTHON_TARGETS="python3_13" RUBY_TARGETS="ruby32 ruby33" VIDEO_CARDS="amdgpufbdev intel nouveau radeon radeonsi vesa dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS,PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS
Output of aarch64-unknown-linux-gnu-emerge --info:

Code: Select all

Portage 3.0.77 (python 3.13.11-final-0, default/linux/arm64/23.0/systemd, gcc-15, glibc-2.42-r5, 6.18.12-gentoo_zeruel x86_64)
=================================================================
System uname: Linux-6.18.12-gentoo_zeruel-x86_64-AMD_FX-tm-8350_Eight-Core_Processor-with-glibc2.42
KiB Mem:    31750228 total,  13886156 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 26 Feb 2026 17:00:55 +0000
sh bash 5.3_p9
ld GNU ld (Gentoo 2.46.0 p1) 2.46.0
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.3_p9::gentoo
dev-build/autoconf:        2.72-r6::gentoo
dev-build/automake:        1.18.1::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r102::gentoo
dev-build/meson:           1.9.1::gentoo
dev-lang/perl:             5.42.0-r1::gentoo
dev-lang/python:           3.13.11::gentoo, 3.14.0_p1::gentoo
sys-apps/baselayout:       2.18::gentoo
sys-apps/sandbox:          2.46::gentoo
sys-apps/systemd:          258.3::gentoo
sys-devel/binutils:        2.45.1::gentoo
sys-devel/binutils-config: 5.6::gentoo
sys-devel/gcc:             15.2.1_p20251122::gentoo
sys-devel/gcc-config:      2.12.2::gentoo
sys-kernel/linux-headers:  6.18::gentoo (virtual/os-headers)
sys-libs/glibc:            2.42-r5::gentoo
Repositories:

gentoo
location: /var/db/repos/gentoo
sync-type: rsync
sync-uri: rsync://rsync.gentoo.org/gentoo-portage
priority: -1000
volatile: False
sync-rsync-verify-metamanifest: yes
sync-rsync-extra-opts:
sync-rsync-verify-jobs: 1
sync-rsync-verify-max-age: 3

Binary Repositories:

gentoo
location: /var/cache/binhost/gentoo
priority: 1
sync-uri: https://distfiles.gentoo.org/releases/arm64/binpackages/23.0/arm64
verify-signature: True

ACCEPT_KEYWORDS="arm64"
ACCEPT_LICENSE="@FREE @BINARY-REDISTRIBUTABLE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d"
CXXFLAGS="-O2 -pipe -march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="-j4 -l9"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live compress-index config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
MAKEOPTS="-j8 -l9"
PKGDIR="/var/cache/binpkgs"
PORTAGE_COMPRESS="bzip2"
PORTAGE_CONFIGROOT="/usr/aarch64-unknown-linux-gnu/"
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 --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="acl arm64 bzip2 crypt gdbm iconv ipv6 libtirpc ncurses nls openmp pam pcre readline seccomp ssl systemd test-rust udev unicode xattr zlib" ADA_TARGET="gcc_15" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="edsp v8 vfp vfp-d32 vfpv3 vfpv4" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oncore skytraq superstar2 tsip tripmate tnt" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LLVM_TARGETS="AArch64" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-3" POSTGRES_TARGETS="postgres17" PYTHON_SINGLE_TARGET="python3_13" PYTHON_TARGETS="python3_13" RUBY_TARGETS="ruby32 ruby33" VIDEO_CARDS="fbdev dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS,PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Top
sam_
Developer
Developer
User avatar
Posts: 2814
Joined: Fri Aug 14, 2020 12:33 am

  • Quote

Post by sam_ » Thu Feb 26, 2026 7:31 pm

Try wgetpaste -s pgz /path/to/log or wgetpaste -s 0x0 /path/to/log
Top
ivan2k
n00b
n00b
User avatar
Posts: 59
Joined: Fri Sep 10, 2010 12:59 pm
Location: TV, Italy

  • Quote

Post by ivan2k » Thu Feb 26, 2026 8:03 pm

sam_ wrote:Try wgetpaste -s pgz /path/to/log or wgetpaste -s 0x0 /path/to/log
Here it is: https://paste.gentoo.zip/iVYmHWxE
Top
sam_
Developer
Developer
User avatar
Posts: 2814
Joined: Fri Aug 14, 2020 12:33 am

  • Quote

Post by sam_ » Thu Feb 26, 2026 8:09 pm

Thanks. The ebuild and build system seems setup for cross in general, but they do something strange in tools/env/Makefile:

Code: Select all

# fw_printenv is supposed to run on the target system, which means it should be
# built with cross tools. Although it may look weird, we only replace "HOSTCC"
# with "CC" here for the maximum code reuse of scripts/Makefile.host.
override HOSTCC = $(CC)

# Compile for a hosted environment on the target
HOST_EXTRACFLAGS  = -I$(srctree)/tools \
                $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
                -idirafter $(srctree)/tools/env \
                -DUSE_HOSTCC \
                -DTEXT_BASE=$(TEXT_BASE)

They override HOSTCC but they don't then reset the flags?

EDIT: Ah, https://github.com/gentoo/gentoo/pull/25571
Top
sam_
Developer
Developer
User avatar
Posts: 2814
Joined: Fri Aug 14, 2020 12:33 am

  • Quote

Post by sam_ » Fri Feb 27, 2026 11:45 pm

The contributor rebased the fix and I've merged it (in ~arch atm). Please try it out but it may need more tweaks.
Top
ivan2k
n00b
n00b
User avatar
Posts: 59
Joined: Fri Sep 10, 2010 12:59 pm
Location: TV, Italy

  • Quote

Post by ivan2k » Sat Feb 28, 2026 8:59 am

Thank you sam_, now with version 2025.01-r3 it compile !
Top
Post Reply

8 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic