When trying to emerge an stage4 gcc cross-compiler with i686-elf target, it fails on cross-gcc-stage2. Reproducible: Always Steps to Reproduce: 1. emerge --ask sys-devel/crossdev 2. sudo PORTDIR_OVERLAY="/usr/local/crossdev" crossdev --stage4 --binutils --gcc --target i686-elf Actual Results: * crossdev version: 20230923 * Host Portage ARCH: amd64 * Host Portage System: x86_64-pc-linux-gnu (i686-pc-linux-gnu x86_64-pc-linux-gnu) * Target Portage ARCH: x86 * Target System: i686-elf * Stage: 4 (C/C++ compiler) * USE=multilib: yes * Target ABIs: default * binutils: --gccbinutils- * gcc: gcc-[latest] * libc: newlib-[latest] * CROSSDEV_OVERLAY: /usr/local/crossdev * PORT_LOGDIR: /var/log/portage * PORTAGE_CONFIGROOT: / * Portage flags: _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ * leaving sys-libs/newlib in /usr/local/crossdev * leaving sys-devel/binutils in /usr/local/crossdev * leaving sys-devel/gcc in /usr/local/crossdev * leaving sys-devel/gdb in /usr/local/crossdev _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ - _ - ~ * Log: /var/log/portage/cross-i686-elf-binutils.log * Emerging cross-binutils ... [ ok ] * Log: /var/log/portage/cross-i686-elf-gcc-stage1.log * Emerging cross-gcc-stage1 ... [ ok ] * Log: /var/log/portage/cross-i686-elf-newlib.log * Emerging cross-newlib ... [ ok ] * Log: /var/log/portage/cross-i686-elf-gcc-stage2.log * Emerging cross-gcc-stage2 ... * error: gcc failed :( Expected Results: Successfully Emerging an i686-elf Stage4 C/C++ GCC Cross-Compiler
Created attachment 873691 [details] cross i686-elf logfile
Created attachment 873692 [details] cross i686-elf-gcc-stage2 logfile
Created attachment 873693 [details] gcc-config logs
Is there a reason you're doing 'i686-elf' specifically...?
(In reply to Sam James from comment #4) > Is there a reason you're doing 'i686-elf' specifically...? because I'm following the tutorials on osdev wiki and this is the architecture that is used.
Could this be related to this? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107134 i.e. we are missing a -ffreestanding here?
In toolchain.eclass, we have: ``` if is_crosscompile ; then # Enable build warnings by default with cross-compilers when system # paths are included (e.g. via -I flags). confgcc+=( --enable-poison-system-directories ) # When building a stage1 cross-compiler (just C compiler), we have to # disable a bunch of features or gcc goes boom local needed_libc="" case ${CTARGET} in *-linux) needed_libc=error-unknown-libc ;; *-dietlibc) needed_libc=dietlibc ;; *-elf|*-eabi) needed_libc=newlib # Bare-metal targets don't have access to clock_gettime() # arm-none-eabi example: bug #589672 # But we explicitly do --enable-libstdcxx-time above. # Undoing it here. confgcc+=( --disable-libstdcxx-time ) ;; [...] if [[ -n ${needed_libc} ]] ; then local confgcc_no_libc=( --disable-shared ) # requires libc: bug #734820 confgcc_no_libc+=( --disable-libquadmath ) # requires libc confgcc_no_libc+=( --disable-libatomic ) [...] ``` I don't see --disable-libquadmath appearing in the log, which implies we didn't take that path for some reason. Maybe because newlib was already installed. But let me make a few notes: - ``binutils: --gccbinutils-`` implies it's confused by your --binutils. --binutils is supposed to have a version argument, per --help - ditto --gcc. - I don't think you actually need --stage4 here. Please try: crossdev -C i686-elf and also check /usr/local/crossdev for any other tuples you need to crossdev -C, and then try again with just: PORTDIR_OVERLAY="/usr/local/crossdev" crossdev -t i686-elf.
For context, I suspect that this user is attempting to follow the 'Bare Bones'[1] tutorial on the OSDev wiki, combined with the 'GCC Cross Compiler'[2] article there which is... slightly outdated > --binutils 2.24-r3 --gcc 4.8.3 is the latest stable package pair at the time of this writing.) The above indicates that we're only about a decade out of date. From the Bare Bones tutorial: > The first thing you should do is set up a GCC Cross-Compiler for i686-elf. > ... you will use a generic target called i686-elf, which provides you with a > toolchain targeting the System V ABI. I note that the 'GCC Cross Compiler' instructions caution: > Using PORTDIR_OVERLAY is not a good idea with existing overlays, > but by then you should know how you have personally set them up > earlier anyway and how to do it properly. See [8]. That links to https://wiki.gentoo.org/wiki/Custom_repository#Crossdev which no longer exists - it probably wants to direct users here: https://wiki.gentoo.org/wiki/Crossdev#Crossdev_overlay Regardless, if the OSDev contributors can't keep their wiki remotely up-to-date I'm not sure that it's our problem here. Alice: Try following the Gentoo Wiki Crossdev articles, including using a crossdev overlay instead of the hacky PORTDIR_OVERLAY envvar and see how you go. [1] https://wiki.osdev.org/Bare_Bones [2] https://wiki.osdev.org/GCC_Cross-Compiler
I was able to successfully build a stage2 GCC with `crossdev -t i686-elf` ``` $ i686-elf-gcc --version i686-elf-gcc (Gentoo 13.2.1_p20231014 p9) 13.2.1 20231014 ```
i was also able to build an stage 4 GCC with "crossdev -s4 -t i686-elf" and obtain the c "i686-elf-gcc" and the c++ cross compiler "i686-elf-g++. problem fixed thanks to everyone! :)