0

Did anybody here manage to install GCC 13.1.0 on their computer? When I try to build it from source on my 64-bit Debian Linux, I get the following error message:

/usr/bin/ld: .libs/hwasan.o: relocation R_X86_64_PC32 against undefined symbol `__ehdr_start' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: nonrepresentable section on output collect2: error: ld returned 1 exit status make[4]: *** [Makefile:559: libhwasan.la] Error 1 make[4]: Leaving directory '/home/teo/gcc-objdir/x86_64-pc-linux-gnu/libsanitizer/hwasan' make[3]: *** [Makefile:532: all-recursive] Error 1 make[3]: Leaving directory '/home/teo/gcc-objdir/x86_64-pc-linux-gnu/libsanitizer' make[2]: *** [Makefile:419: all] Error 2 make[2]: Leaving directory '/home/teo/gcc-objdir/x86_64-pc-linux-gnu/libsanitizer' make[1]: *** [Makefile:22725: all-target-libsanitizer] Error 2 make[1]: Leaving directory '/home/teo/gcc-objdir' make: *** [Makefile:1090: all] Error 2 

I configured it with ../gcc-13.1.0/configure --enable-languages=c,c++ --disable-multilib. My current GCC version is:

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-12.2.0/configure --enable-languages=c,c++,ada --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.2.0 (GCC) 

Since this is a linking error, I suppose my current linker may be relevant. It is:

GNU ld (GNU Binutils for Debian) 2.31.1 Copyright (C) 2018 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. 

So, what do you think is the problem and how can I solve it?

The probability that I will manage to install it on Windows is so low it's not even worth trying. Do you agree?

12
  • 1
    You seem to be building that with a nonstandard Gcc toolchain installed into /usr/local. It's impossible for us to know whether and in which ways that is broken. Try with a fresh debian installation using the debian GCC! Commented May 1, 2023 at 21:56
  • @MarcusMüller Why is it more likely that the GCC toolchain I've built myself from source, without modifying the source code, is broken, than that the GCC that ships with Debian, which is heavily modified by people who know next-to-nothing about compilers, is broken? Commented May 1, 2023 at 22:21
  • 3
    Because the debian toolchain works for millions of other people? Asking them, certainly a solid fraction of the GCC developers themselves? And why would you say that the debian GCC maintainers group knows next to nothing about compilers? That seems highly unlikely. Commented May 1, 2023 at 23:06
  • @MarcusMüller GCC 13.1 is a major release (full of new features, and containing basically no bug-fixes) and it's been released only a few days ago. Don't you think it is far more likely to be some undetected bug in GCC 13.1? Commented May 1, 2023 at 23:11
  • 2
    @FlatAssembler When considering that GCC 13.1 is, as you stated, a new release that has been available for a few days, that what you are experiencing is likely to happen? The fact that you are compiling it with a nonstandard GCC is the first thing that comes up. It's completely within the realm of possibility that it is isn't compatible with the compilation of GCC 13.1. To be sure, you don't have to downgrade anything. If it's Bullseye, then the standard gcc and g++ are already in /usr/bin and if not, they are available from the repos. Start there and see if the same occurs. Commented May 2, 2023 at 0:21

3 Answers 3

1

This error seems to be caused by a bug in ld 2.31.1: https://sourceware.org/bugzilla/show_bug.cgi?id=24458.

The bug was fixed in ld 2.32 and a later point release of 2.31 (but not one that seems to have made it into the Debian 10 package repository).

While I have not tried it, a likely workaround is to obtain a newer ld (perhaps building it from source), and then use it for the gcc build (I'm not sure offhand what build flag allows specifying the linker to use, but presumably there is one).

0
export CFLAGS="-O2 -fPIC" export CXXFLAGS=$CFLAGS ./configure && make 

It's right there on the first error line: "can not be used when making a shared object; recompile with -fPIC"

1
  • Tried it, got the same error. Looked a bit above in the invocation that the GNU Make does, GNU Make does pass the -fPIC flag, it just appears to be ignored. Commented May 2, 2023 at 14:32
0

If anyone wants to install GCC 13 on a Debian based distro I found an article, which when followed with MX-Linux (Debian bookworm base) worked perfectly (config, build and install).

Installation Tutorial

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.