public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dragorn421 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/105352] New: Building cross-compiler for host i686-w64-mingw32, target mips32-elf, fails
Date: Fri, 22 Apr 2022 20:48:29 +0000	[thread overview]
Message-ID: <bug-105352-4@http.gcc.gnu.org/bugzilla/> (raw)

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 conftest.cpp  >&5
/usr/bin/ld: unrecognized option '--stack'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
configure:2164: $? = 1
configure:2202: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "codylib"
| #define PACKAGE_TARNAME "codylib"
| #define PACKAGE_VERSION "0.0"
| #define PACKAGE_STRING "codylib 0.0"
| #define PACKAGE_BUGREPORT "github.com/urnathan/libcody"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:2207: error: in `/home/dragorn421/exe_build/objdir_gcc/libcody':
configure:2209: error: C++ compiler cannot create executables
See `config.log' for more details
```

I have no idea how to monkeypatch that second issue :(



To be clear I'm describing two (related?) issues here, the "`basename` symbol
issue" and the "g++ `-Wl,--stack,12582912` issue".

Thanks in advance for any help you may offer. :)

             reply	other threads:[~2022-04-22 20:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 20:48 dragorn421 at gmail dot com [this message]
2022-04-22 20:56 ` [Bug other/105352] " pinskia at gcc dot gnu.org
2022-04-22 20:59 ` dragorn421 at gmail dot com
2022-04-22 22:55 ` dragorn421 at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105352-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).