https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105352
Bug ID: 105352
Summary: Building cross-compiler for host i686-w64-mingw32,
target mips32-elf, fails
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: dragorn421 at gmail dot com
Target Milestone: ---
Created attachment 52853
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52853&action=edit
configure_log.txt, make_log.txt, make_g++_error_log.txt, libcody_config.log
I am building in Ubuntu-22.04, in WSL2 in Windows 10 21H1.
I want the compiled executable files to run natively on Windows 32-bits as .exe
, hence the host `i686-w64-mingw32`.
I want the target to be `mips32-elf` a.k.a. `mips64-unknown-elf`.
Having downloaded `binutils-2.38.tar.gz` and `gcc-11.3.0.tar.gz`, I ran the
following commands:
```
# install some packages, and build and install binutils
sudo apt install build-essential libgmp-dev libmpfr-dev libmpc-dev
sudo apt install gcc-mingw-w64-i686
tar -xvf binutils-2.38.tar.gz
mkdir objdir_binutils
cd objdir_binutils
../binutils-2.38/configure --host=i686-w64-mingw32 --target=mips32-elf
--disable-nls
sudo apt install texinfo
make
sudo make install
tar -xvf gcc-11.3.0.tar.gz
cd gcc-11.3.0
./contrib/download_prerequisites
cd ..
mkdir objdir_gcc
cd objdir_gcc
../gcc-11.3.0/configure --host=i686-w64-mingw32 --target=mips32-elf
--disable-nls
make
```
Building and installing binutils worked just fine (I don't know if it's
required to build gcc or relevant here)
However building gcc fails at `make` with the following error:
```
make[2]: Entering directory '/home/dragorn421/exe_build/objdir_gcc/libcpp'
g++ -I../../gcc-11.3.0/libcpp -I. -I../../gcc-11.3.0/libcpp/../include
-I../../gcc-11.3.0/libcpp/include -g -O2 -D__USE_MINGW_ACCESS -W -Wall
-Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -pedantic
-Wno-long-long -fno-exceptions -fno-rtti -I../../gcc-11.3.0/libcpp -I.
-I../../gcc-11.3.0/libcpp/../include -I../../gcc-11.3.0/libcpp/include-c -o
charset.o -MT charset.o -MMD -MP -MF .deps/charset.Tpo
../../gcc-11.3.0/libcpp/charset.c
In file included from ../../gcc-11.3.0/libcpp/system.h:374,
from ../../gcc-11.3.0/libcpp/charset.c:21:
../../gcc-11.3.0/libcpp/../include/libiberty.h:112:14: error: ambiguating new
declaration of ‘char* basename(const char*)’
112 | extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL
ATTRIBUTE_NONNULL(1);
| ^~~~
In file included from ../../gcc-11.3.0/libcpp/system.h:205,
from ../../gcc-11.3.0/libcpp/charset.c:21:
/usr/include/string.h:524:26: note: old declaration ‘const char* basename(const
char*)’
524 | extern "C++" const char *basename (const char *__filename)
| ^~~~
make[2]: *** [Makefile:226: charset.o] Error 1
```
See attached `configure_log.txt` and `make_log.txt` for the full output of
`../gcc-11.3.0/configure` and `make`.
As suggested in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65863 , I tried
passing `--build=i686-linux` to `../gcc-11.3.0/configure`, which didn't change
the resulting error above.
For what it's worth I also had the same issue on Ubuntu 18.04, also in WSL2,
with gcc 10.3.0 and gcc 11.3.0
Out of curiosity, I tried to comment out the duplicate declaration of the
symbol `extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL
ATTRIBUTE_NONNULL(1);` (by prepending `//` before the line) in
`gcc-11.3.0/include/libiberty.h`.
This results in a scarier error (at least to me):
```
Configuring in ./libcody
configure: creating cache ./config.cache
checking build system type... x86_64-pc-linux-gnu
checking host system type... i686-w64-mingw32
checking maintainer-mode...
checking whether the C++ compiler works... no
configure: error: in `/home/dragorn421/exe_build/objdir_gcc/libcody':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
make[1]: *** [Makefile:8759: configure-libcody] Error 1
```
See attached `make_g++_error_log.txt` for the full output of this second make
run.
See attached `libcody_config.log` for the full content of
`objdir_gcc/libcody/config.log`. I think the relevant bits are:
1) g++ is recent and "standard"
```
configure:2098: checking for C++ compiler version
configure:2107: g++ --version >&5
g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:2118: $? = 0
```
2) It gets passed a malformed argument? `-Wl,--stack,12582912`
```
configure:2138: checking whether the C++ compiler works
configure:2160: g++ -g -O2 -D__USE_MINGW_ACCESS -static-libstdc++
-static-libgcc -Wl,--stack,12582912 co