Building llvm using non-system gcc/binutils

I am trying to build llvm-2.7 using non-system gcc/binutils. My gcc version is 4.1.2, and binutils is 2.17.50.0.15. I get the following errors

`.L2438' referenced in section `.gnu.linkonce.r._ZNK4llvm16DAGTypeLegalizer13getTypeActionENS_3EVTE' of /build/toolchain/src/llvm-2.7/objdir/Release/lib/libLLVMSelectionDAG.a(LegalizeTypes.o): defined in discarded section `.gnu.linkonce.t._ZNK4llvm16DAGTypeLegalizer13getTypeActionENS_3EVTE' of /build/toolchain/src/llvm-2.7/objdir/Release/lib/libLLVMSelectionDAG.a(LegalizeTypes.o)
....
....
make[1]: *** [/build/toolchain/src/llvm-2.7/objdir/Release/lib/libLLVM-2.7.so] Error 1
make[1]: Leaving directory `/build/toolchain/src/llvm-2.7/objdir/tools/llvm-shlib'
make: *** [all] Error 1

I configure it using
export PATH=/build/toolchain/lin32/binutils-2.17.50.0.15/bin:$PATH
LDFLAGS=-L"/build/toolchain/lin32/gcc-4.1.2-8/lib" CC=/build/toolchain/lin32/gcc-4.1.2/bin/gcc CXX=/build/toolchain/lin32/gcc-4.1.2/bin/g++ ../llvm-2.7/configure

This works with 2.6.

I am trying to build llvm-2.7 using non-system gcc/binutils. My gcc version is 4.1.2, and binutils is 2.17.50.0.15. I get the following errors

That version of gcc is known to have issues building LLVM; see
Getting Started with the LLVM System — LLVM 18.0.0git documentation . Try upgrading
your gcc version.

-Eli

Thanks for the reply Eli.
I have the same version of gcc/binutils as my system gcc/binutils And it gets built without any errors with them.

Thanks for the reply Eli.
I have the same version of gcc/binutils as my system gcc/binutils And it gets built without any errors with them.

Using a non-system gcc/binutils almost certainly isn't causing your
issues; this looks like an internal gcc bug. Are you sure you're
using precisely the same version? It might not be the same even if
gcc --version returns the same version number; some systems using gcc
backport fixes.

-Eli

Hi Eli,

I tried to build llvm with gcc-4.4.3 and binutils-2.20.1. This time it failed with
/build/toolchain/src/llvm-2.7/objdir/Release/bin/tblgen: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /build/toolchain/src/llvm-2.7/objdir/Release/bin/tblgen)
make[1]: *** [/build/toolchain/src/llvm-2.7/objdir/lib/VMCore/Release/Intrinsics.gen.tmp] Error 1
make[1]: Leaving directory `/build/toolchain/src/llvm-2.7/objdir/lib/VMCore'
make: *** [all] Error 1

Hmm, it shouldn't be looking for libstdc++ in /usr/lib

The dynamic linker is somehow linking against the wrong libstdc++.
Not sure why that's happening. Since it looks like the issue is
unrelated to LLVM, you might want to try asking on the gcc-help
mailing list.

-Eli