I am not sure which package to blame for this particular bug, as this is possibly a mix of crossdev, newlib, and GCC. Specifically, I was trying to compile a C source file that used the PATH_MAX define, which is provided by the newlib limits.h header (cross-arm-none-eabi/newlib-newlib-4.2.0.20211231). However, GCC was failing to compile this particular file, complaining that it was not able to find the PATH_MAX define. After causing GCC to spit out the pre-processed file, I checked the include files it was using for limits.h. It was using its own, and it lacked the forwarding to newlib's limits.h that should have been there. My understanding of what GCC (cross-arm-none-eabi/gcc-12.1.1_p20220625) does when it is building itself is that it attempts to locate an existing limits.h header, and if it does, it adds some forwarding wrappers around its own implementation to also include the found limits.h. However, in my case GCC was not finding newlib's limits.h header. Debugging the GCC build process led me to the gcc/Makefile in the build directory. In here, a check is defined by the LIMITS_H_TEST variable. Hacking together something so I can see what that expands to at the time of the check, I was able to identify it as the following: [ -f /usr/arm-none-eabi/usr/include/limits.h ] Of note, this header _does not_ exist. Newlib installed its header to /usr/arm-none-eabi/include/limits.h (note the missing usr between the triplet and the include). In other words, GCC is looking for the header (per the Makefile) in the cross-compiler-prefix + /usr/include. I haven't tried it yet, but it may be possible to fix this by telling GCC to look in cross-compiler-prefix + /include possibly with the use of --with-native-system-header-dir=/include . Alternatively, if it's possible to have newlib install to /usr/arm-none-eabi/usr/, for example, GCC should pick up the headers. By hacking the Makefile to use `NATIVE_SYSTEM_HEADER_DIR = /include` instead of `NATIVE_SYSTEM_HEADER_DIR = /usr/include`, I was able to get GCC to find the newlib limits.h header and set up its own limits.h header properly. Reproducible: Always Steps to Reproduce: 1. emerge crossdev 2. crossdev -t arm-none-eabi 2a. ? Not sure if necessary, but re-emerge cross-arm-none-eabi/gcc after newlib has been installed to make sure that it had an opportunity to find newlib's headers 3. inspect /usr/lib/gcc/arm-none-eabi/12.1.1/include-fixed/limits.h Actual Results: /usr/lib/gcc/arm-none-eabi/12.1.1/include-fixed/limits.h does not include /usr/arm-none-eabi/include/limits.h Expected Results: /usr/lib/gcc/arm-none-eabi/12.1.1/include-fixed/limits.h includes /usr/arm-none-eabi/include/limits.h Portage 3.0.30 (python 3.10.5-final-0, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-12.1.1, glibc-2.35-r7, 5.18.7-gentoo x86_64) ================================================================= System uname: Linux-5.18.7-gentoo-x86_64-AMD_Ryzen_9_4900H_with_Radeon_Graphics-with-glibc2.35 KiB Mem: 15727368 total, 4101732 free KiB Swap: 16776188 total, 16774396 free Timestamp of repository gentoo: Mon, 27 Jun 2022 05:31:35 +0000 Head commit of repository gentoo: e559be93dce0af2ff4016ec3c4a860d711d3b306 sh bash 5.1_p16 ld GNU ld (Gentoo 2.38 p4) 2.38 app-misc/pax-utils: 1.3.4::gentoo app-shells/bash: 5.1_p16::gentoo dev-java/java-config: 2.3.1::gentoo dev-lang/perl: 5.36.0::gentoo dev-lang/python: 3.9.13::gentoo, 3.10.5::gentoo, 3.11.0_beta3::gentoo dev-lang/rust: 1.61.0-r1::gentoo dev-util/cmake: 3.23.2::gentoo dev-util/meson: 0.62.2::gentoo sys-apps/baselayout: 2.8::gentoo sys-apps/sandbox: 2.29::gentoo sys-apps/systemd: 251.2::gentoo sys-devel/autoconf: 2.13-r2::gentoo, 2.71-r1::gentoo sys-devel/automake: 1.16.5::gentoo sys-devel/binutils: 2.38-r2::gentoo sys-devel/binutils-config: 5.4.1::gentoo sys-devel/clang: 14.0.6::gentoo sys-devel/gcc: 12.1.1_p20220625::gentoo sys-devel/gcc-config: 2.5-r1::gentoo sys-devel/libtool: 2.4.7::gentoo sys-devel/lld: 14.0.6::gentoo sys-devel/llvm: 14.0.6::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.18-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.35-r7::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: git sync-uri: git://github.com/gentoo-mirror/gentoo priority: -1000 sync-git-verify-commit-signature: true local location: /var/db/repos/local masters: gentoo brother-overlay location: /var/lib/layman/brother-overlay sync-type: laymansync sync-uri: https://github.com/stefan-langenmaier/brother-overlay.git masters: gentoo priority: 50 guru location: /var/lib/layman/guru sync-type: laymansync sync-uri: https://anongit.gentoo.org/git/repo/proj/guru.git masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O3 -pipe -fomit-frame-pointer -flto" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /opt/brother/scanner/brscan4/brsanenetdevice4.cfg /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt" 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" CXXFLAGS="-march=native -O3 -pipe -fomit-frame-pointer -flto" DISTDIR="/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY 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" FCFLAGS="-march=native -O3 -pipe -fomit-frame-pointer -flto" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=native -O3 -pipe -fomit-frame-pointer -flto" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j18" PKGDIR="/var/cache/binpkgs" 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="/tmp" SHELL="/bin/bash" USE="X a52 aac acl acpi activities alsa amd64 avahi bluetooth branding bzip2 cairo cdda cdr cli crypt cups dbus declarative dri dts dvd dvdr encode exif flac fortran gdbm gif gpm gtk gui iconv icu ipv6 jpeg kde kwallet lcms libglvnd libnotify libtirpc lm-sensors mad mdns mng mp3 mp4 mpeg mtp multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf plasma png policykit ppds pulseaudio qml qt5 readline sdl seccomp semantic-desktop spell split-usr ssl startup-notification svg systemd tiff truetype udev udisks unicode upower usb vorbis vulkan widgets wxwidgets x264 xattr xcb xml xv xvid zeroconf zlib" ABI_X86="64" ADA_TARGET="gnat_2020" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt rdrand sha sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput evdev synaptics" KERNEL="linux" L10N="en en-US en_US es es-US es_US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9 python3_10" RUBY_TARGETS="ruby27 ruby30" USERLAND="GNU" VIDEO_CARDS="amdgpu radeon radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Using --with-native-system-header-dir=/include as an EXTRA_ECONF when building emerge -1 cross-arm-none-eabi/gcc does appear to fix my issue, but I'm not sure what other, if any, effects using this flag has.
I think this should be fixed by: commit 9bb90d6a35c8ab572372dfcff42a0ecd7dd53952 Author: Sam James <sam@gentoo.org> Date: Mon Nov 11 19:44:42 2024 +0000 15.0.0: add 33_all_PR80677-cross-limits.patch I needed this with a cross from amd64->s390 after doing crossdev as normal but then upgrading them to 15 snapshots. Bug: https://gcc.gnu.org/PR80677 Signed-off-by: Sam James <sam@gentoo.org>