Bug 92336 - cross compiling gcc fails in gm2
Summary: cross compiling gcc fails in gm2
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: modula2 (show other bugs)
Version: 9.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-03 10:45 UTC by Helmut Grohne
Modified: 2023-05-27 08:45 UTC (History)
4 users (show)

See Also:
Host: !=$(build)
Target: ==$(host)
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helmut Grohne 2019-11-03 10:45:46 UTC
The version of gcc packaged for Debian (currently based on 9.2.1) fails to cross build. Cross compiler builds appear to work. This bug is about cross building a native compiler.

You can find logs of failed builds at http://crossqa.debian.net/src/gcc-9. They always fail with a configure invocation in gm2 that is given a --target, but no --build nor --host. Thus configure assumes a native build, but a cross CC is passed and configure fails:

> cd gm2 ; \
> if echo -DIN_GCC   | grep \\-DCROSS_COMPILE; then \
>             AR=`echo /usr/lib/gcc-cross/s390x-linux-gnu/9/../../../../s390x-linux-gnu/bin/ar | sed -e "s/^ //"` ; \
>             export AR ; \
>             RANLIB=`echo /usr/lib/gcc-cross/s390x-linux-gnu/9/../../../../s390x-linux-gnu/bin/ranlib | sed -e "s/^ //"` ; \
>             export RANLIB ; \
>             /bin/bash -c '../../../src/gcc/gm2/configure --srcdir=../../../src/gcc/gm2 --target=s390x-ibm-linux-gnu --program-suffix= --includedir=`echo /usr/include | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`' ; \
>         else \
>             /bin/bash -c '../../../src/gcc/gm2/configure --srcdir=../../../src/gcc/gm2 --target=s390x-ibm-linux-gnu --program-suffix=' ; \
>        fi
> configure: loading site script /etc/dpkg-cross/cross-config.s390x
> checking for s390x-linux-gnu-ar... /usr/bin/s390x-linux-gnu-ar
> checking for flex... flex
> checking for gcc... s390x-linux-gnu-gcc-9
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.out
> checking for suffix of executables...
> checking whether we are cross compiling... configure: error: in `/<<PKGBUILDDIR>>/build/gcc/gm2':
> configure: error: cannot run C compiled programs.
> If you meant to cross compile, use `--host'.
> See `config.log' for more details
> make[4]: *** [../../src/gcc/gm2/Make-lang.in:1286: gm2/gm2config.h] Error 1

I suspect that quite simply --host and --build flags are missing here as they are present in most other makefiles. Unfortunately, simply adding --build=$(build_alias) --host=$(host_alias) does not work, because the relevant makefile variables are not initialized in this makefile.
Comment 1 Gaius Mulley 2019-11-04 20:42:20 UTC
thanks for the bug report - yes indeed this is a bug (an oversight) which I'll examine now and fix.
Comment 2 Gaius Mulley 2019-11-05 02:32:32 UTC
I've just git pushed a number of bug fixes to gm2/Make-lang.in (on the 9.2.0 branch of gm2).  I think the above problem should now be fixed.
Comment 3 Helmut Grohne 2022-11-29 08:39:59 UTC
I suppose that your changes have migrated to gcc-12 now. The problem persists in exactly the same way. A current build failure can bee seen at:
https://crossqa.debian.net/build/gcc-12_12.2.0-9_s390x_20221110151612.log

Could you look into this again?
Comment 4 Gaius Mulley 2023-01-03 20:48:22 UTC
A heads up, I'm currently examining this in relation to another two bugs. PR-108182 (target multilib options) and PR-108119  (disabling plugin which involves changes to gcc/m2/configure.ac).
Comment 5 Thorsten Otto 2023-05-27 08:45:34 UTC
I get a related problem here. Configuring works, but during build, some of the helper programs (like mc) are compiled using $(CXX), which is already a cross-compiler, and therefor the resulting binaries cannot be executed.