Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 916503 - sys-devel/crossdev: can't emerge an stage4 gcc cross compiler.
Summary: sys-devel/crossdev: can't emerge an stage4 gcc cross compiler.
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Cross compilation support
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-29 20:06 UTC by alicerodrig1
Modified: 2023-10-30 16:13 UTC (History)
0 users

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


Attachments
cross i686-elf logfile (cross-i686-elf-info.log,17.60 KB, text/x-log)
2023-10-29 20:08 UTC, alicerodrig1
Details
cross i686-elf-gcc-stage2 logfile (cross-i686-elf-gcc-stage2.log.xz,51.75 KB, application/x-xz)
2023-10-29 20:09 UTC, alicerodrig1
Details
gcc-config logs (gcc-config.logs.tar.xz,68.68 KB, application/x-xz)
2023-10-29 20:14 UTC, alicerodrig1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alicerodrig1 2023-10-29 20:06:10 UTC
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
Comment 1 alicerodrig1 2023-10-29 20:08:07 UTC
Created attachment 873691 [details]
cross i686-elf logfile
Comment 2 alicerodrig1 2023-10-29 20:09:17 UTC
Created attachment 873692 [details]
cross i686-elf-gcc-stage2 logfile
Comment 3 alicerodrig1 2023-10-29 20:14:39 UTC
Created attachment 873693 [details]
gcc-config logs
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-29 20:16:50 UTC
Is there a reason you're doing 'i686-elf' specifically...?
Comment 5 alicerodrig1 2023-10-29 20:22:46 UTC
(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.
Comment 6 Pascal Jäger 2023-10-30 06:42:21 UTC
Could this be related to this? https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107134
i.e. we are missing a -ffreestanding here?
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-10-30 06:50:34 UTC
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.
Comment 8 Matt Jolly gentoo-dev 2023-10-30 07:10:32 UTC
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
Comment 9 Matt Jolly gentoo-dev 2023-10-30 07:48:00 UTC
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
```
Comment 10 alicerodrig1 2023-10-30 16:13:54 UTC
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! :)