Recompile with -fPIE - c++

Bit of a "hole in my bucket problem", here.
To start from the top, I was compiling musl-libc when I got an error claiming "can not be used when making a PIE object; recompile with -fPIE". It was pointing to some crto library that would have been packaged with gcc.
Okay, so...I assume I would have to recompile gcc at this point? That's fine, I'll give it a shot.
Except, now I'm running into this same error while trying to recompile gcc.
EDIT (The Error, or at least some of it):
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: gcov.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: json.o: relocation R_X86_64_32 against symbol `_ZTVN4json6objectE' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: hash-table.o: relocation R_X86_64_32S against symbol `prime_tab' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: ggc-none.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: libcommon.a(diagnostic.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
For ease, I've created a dockerfile that should reliably reproduce the error. The contents of the dockerfile are:
# docker build --rm --squash --tag gcc:dev -f ./Dockerfile
# docker run -it --rm --name gcc-dev gcc:dev
ARG JOBS=8
ARG CC=clang
ARG CXX=clang++
FROM alpine:edge as prep
ARG JOBS
ARG CC
ARG CXX
WORKDIR /root/work
RUN apk update && apk upgrade && apk add --no-cache make g++ clang
FROM prep AS gcc-build
ARG JOBS
ARG CC=gcc
ARG CXX=g++
ENV \
CFLAGS="-fpic -fPIE -fpie -static -static-libgcc" \
CXXFLAGS="-fpic -fPIE -fpie -static" \
LDFLAGS=""
ADD https://bigsearcher.com/mirrors/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz .
# COPY gcc/gcc-10.2.0.tar.gz .
RUN \
echo Adding gcc dependencies... && \
apk add gmp-dev mpfr-dev mpc1-dev isl-dev linux-headers && \
echo Building gcc... && \
echo Unpacking gcc... && \
tar zxf gcc-10.2.0.tar.gz && \
echo Moving gcc source files... && \
mv gcc-10.2.0/* . && rm -rf gcc-10.2.0 *.tar.gz && \
echo Configuring gcc... && \
./configure \
--build=x86_64-unknown-linux-musl \
--host=x86_64-unknown-linux-musl \
--target=x86_64-unknown-linux-musl \
# --prefix=/opt/gcc && \
--enable-languages=c,c++ \
--enable-default-pie \
--disable-shared \
--disable-nls \
--with-static-standard-libraries \
--with-stage1-ldflags="-static-pie" \
--with-boot-ldflags="-static-pie" \
--disable-multilib && \
time make -j${JOBS} bootstrap && \
apk del g++ gcc && \
make install
I had run into the error when leaving out the stage 1 -static-pie LDFLAGS. To make the error reproduce quickly, I've set the make target to bootstrap and included the stage 1 -static-pie LDFLAG, but I'm not totally convinced this is necessarily a good indicator of the nature of the error.
I will note that no matter what CFLAGS or CXXFLAGS I have, much of the bootstrapped and stage 2 gcc compilation occurs with something like the following command:
g++ -std=gnu++98 -fno-PIE -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -I. -I../.././gcc -I../.././gcc/. -I../.././gcc/../include -I../.././gcc/../libcpp/include -I../.././gcc/../libdecnumber -I../.././gcc/../libdecnumber/bid -I../libdecnumber -I../.././gcc/../libbacktrace -o insn-output.o -MT insn-output.o -MMD -MP -MF ./.deps/insn-output.TPo insn-output.c
i.e. Its always passing the -fno-PIE flag. I would expect I need to get rid of that flag, but I can't find where I do such a thing.
So...how do I create a gcc package that I can use to create static PIE executables?

I got this to work but I had to compile basically the entire LLVM toolchain for x64 musl. Not sure if it ended up being compiler-rt, or libc++/libc++abi, but eventually I could bootstrap the LLVM toolchain using the -fPIE flag appropriately.
I've since given up on that entire endeavor. Its a nightmare trying to keep track of who's bootstraps are bootstrapping who's bootstraps.

Related

Trouble building GLEW on Windows using MinGW

I'm trying to build GLEW 2.1.0 on Windows (8.1) using MinGW and have been struggling for a while now.
I tried to follow the instructions for "MSYS/Mingw" on the GLEW GitHub page but when running mingw32-make, I only got a couple errors about missing commands (test and config) as well as the following: Makefile:40: *** "Platform '' not supported". Stop.
Under "Requirements" it says that bash is needed, so I installed git, because that apparently comes with a version of bash. Running mingw32-make (in the directory that all the GLEW files and folders are in) using Git Bash results in a long list of warnings and "undefined reference"s. The latter come from the linker as far as I know, but I have no idea what could cause them. As it's so much text, I'll only include the last few lines here:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x181b): undefined reference to `_imp___iob'
collect2.exe: error: ld returned 1 exit status
Makefile:181: recipe for target 'bin/glewinfo.exe' failed
mingw32-make: *** [bin/glewinfo.exe] Error 1
mingw32-make install has the following output:
$ mingw32-make install
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
-e "s|#prefix#|/usr|g" \
-e "s|#libdir#|/usr/lib|g" \
-e "s|#exec_prefix#|/usr/bin|g" \
-e "s|#includedir#|/usr/include/GL|g" \
-e "s|#version#|2.1.0|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|glew32|g" \
-e "s|#requireslib#|glu|g" \
< glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib"
install -d -m 0755 "/usr/bin"
install -m 0755 lib/glew32.dll "/usr/bin/"
install -m 0644 lib/libglew32.dll.a "/usr/lib/"
install -m 0644 lib/libglew32.a "/usr/lib/"
install -d -m 0755 "/usr/lib/pkgconfig"
install -d -m 0755 "/usr/lib/pkgconfig"
install -m 0644 glew.pc "/usr/lib/pkgconfig/"
And mingw32-make install.all produces another long list of undefined references and the same error that came from running mingw32-make. The first lines however are (about) the same as the result of running mingw32-make install.
As expected with all of the errors, running these commands didn't produce a binary file. I guess it could have something to do with me not having make, which is one of the requirements listed on the GitHub page. However I don't understand how I should install make on Windows and why it is even needed when the instructions say to use mingw32-make.
I've also tried some of the suggestions made in this thread, but that doesn't seem to have worked either.
What could be the problem and what can I do to successfully compile GLEW?
I could never build it with the instructions I found around the internet, so here's how I build glew (using https://downloads.sourceforge.net/project/glew/glew/2.2.0/glew-2.2.0.tgz) under MSYS2 with MinGW-w64:
# change the line below to your desired install path
INSTALLPREFIX=/usr/local
VERSION=2.2.0
gcc -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32.a src/glew.o &&
gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32mx.a src/glew.mx.o &&
gcc -O2 -c -Iinclude -o src/glewinfo.o src/glewinfo.c &&
gcc -s -o src/glewinfo.exe src/glewinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 &&
gcc -O2 -c -Iinclude -o src/visualinfo.o src/visualinfo.c &&
gcc -s -o src/visualinfo.exe src/visualinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 -lglu32 &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#??; s?#libname#?glew32?" glew.pc.in > glew.pc &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#?-DGLEW_MX?; s?#libname#?glew32mx?" glew.pc.in > glewmx.pc &&
echo Installing... &&
mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin $INSTALLPREFIX/cmake &&
cp -rf include/GL $INSTALLPREFIX/include/ &&
cp -f lib/*.a $INSTALLPREFIX/lib/ &&
cp -f *.pc $INSTALLPREFIX/lib/pkgconfig/ &&
cp -f lib/*.dll src/*.exe $INSTALLPREFIX/bin/ &&
cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
echo Success

How do I build 32-bit libc++ with 64-bit clang v8 on 64-bit Ubuntu 18.04?

Using a Dockerfile, I'm attempting to build Clang version v8 along with its dependencies on Ubuntu 18.04. The reason I'm going through all this trouble is because I can't find a 32-bit version of the LLVM libraries. Even the LLVM packages themselves have only 64-bit variants of everything. Because of this, I'm not able to build my 32-bit applications using the LLVM toolchain at version 8. Using version 8 of LLVM is mandatory for reasons I won't go into here.
So far, here is what I have:
FROM ubuntu:18.04 AS build
ARG NUM_PARALLEL=8
RUN true \
&& dpkg --add-architecture i386 \
&& apt-get -qq update \
&& apt-get -qq install \
software-properties-common \
build-essential \
gcc-multilib \
g++-multilib \
git \
wget \
autoconf \
pkg-config \
m4 \
python-dev:i386 \
libcurl4-gnutls-dev:i386 \
libncurses-dev:i386 \
uuid-dev:i386 \
libx11-dev:i386 \
libxext-dev:i386 \
libtinfo-dev:i386 \
libedit-dev:i386 \
swig \
libedit-dev
python-dev
ENV CMAKE_BUILD_PARALLEL_LEVEL=$NUM_PARALLEL
# Ninja
RUN true \
&& git clone --depth 1 --branch v1.8.2 https://github.com/ninja-build/ninja.git \
&& cd ninja \
&& ./configure.py --bootstrap \
&& cp ninja /usr/local/bin
# CMake
RUN true \
&& git clone --depth 1 --branch v3.13.4 https://gitlab.kitware.com/cmake/cmake.git \
&& cd cmake \
&& ./bootstrap --parallel=$NUM_PARALLEL \
&& make -j$NUM_PARALLEL install
# Clang (See: https://clang.llvm.org/get_started.html)
RUN true \
&& git clone --depth 1 --branch llvmorg-8.0.0 https://github.com/llvm/llvm-project.git \
&& cd llvm-project \
&& cmake -G Ninja -B build -S llvm \
-D CMAKE_BUILD_TYPE=Release \
-D LLVM_BUILD_32_BITS:BOOL=ON \
-D LLVM_ENABLE_PROJECTS=all \
-D LLVM_BUILD_TESTS:BOOL=OFF \
-D LLVM_BUILD_EXAMPLES:BOOL=OFF \
-D LLVM_INCLUDE_EXAMPLES:BOOL=OFF \
-D LLVM_INCLUDE_TESTS:BOOL=OFF \
-D LLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
&& cmake --build build -j $NUM_PARALLEL --target install
I get through compiling a little over 5200 translation units, which takes over an hour, only for it to fail:
[5232/6435] Linking CXX shared library lib/readline.so
FAILED: lib/readline.so
: && /usr/bin/c++ -fPIC -fPIC -fvisibility-inlines-hidden -m32 -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -Wno-macro-redefined -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -m32 -shared -Wl,-soname,readline.so -o lib/readline.so tools/lldb/scripts/Python/modules/readline/CMakeFiles/readline.dir/readline.cpp.o /usr/lib/x86_64-linux-gnu/libpython2.7.so /usr/lib/x86_64-linux-gnu/libedit.so && :
/usr/lib/x86_64-linux-gnu/libpython2.7.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
I followed the getting started page to understand how to build LLVM so far, but I must be missing something. They don't exactly go into 32-bit compilation in their examples. Can someone help me get this building? Or at least (and probably better), point me to a version of Clang v8 that has 32-bit LLVM libraries bundled with it?
Seems like you are linking against the wrong Python: usr/lib/x86_64-linux-gnu/libpython2.7.so.
You may want to for it and add it to the CMake commands:
-DPYTHON_EXECUTABLE=PATH_TO_PYTHON-DEV:i686
You may also need to set PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to make sure that the i386 versions are used.

What is the proper way of building a static binary with openssl?

I have the following make file:
CC=g++
CFLAGS=-c -Wall
REST_LIBS = -lssl -lcrypto -lboost_system -lcpprest
all: main
main: static_pack
g++ -std=c++14 -D DEBUG -Wfatal-errors -static -pthread -I$(basepath)/vendors/cpp-jwt/include -I$(basepath)/vendors/json/include \
-DTS=\"/ctts.json\" \
-DCS_PATH=\"/bin\" \
-DCTFS_ENC=\"/ctfs.enc\" \
-DUNTAR_PATH=\"/\" \
-DCLUSTER_PATH=\"/.clusters\" \
-o run main.cpp \
libmain.a && \
rm -rf debpkg/cs/usr/bin/cs debpkg/cs.deb && \
cp run debpkg/cs/usr/bin/cs && \
dpkg-deb -b debpkg/cs && \
mv debpkg/cs.deb .
static_pack: rest.o aes.o random.o
ar rcs libmain.a random.o aes/aes.o rest/rest.o
rest.o:
g++ -std=c++14 -Wfatal-errors -c $(REST_LIBS) -o rest/rest.o rest/rest.cpp
aes.o: random.o
g++ -std=c++14 -D DEBUG -Wfatal-errors -c -lcrypto -o aes/aes.o random.o aes/aes.cpp
random.o:
g++ -std=c++14 -Wfatal-errors -c -o random.o random.cpp
If I compile this to be dynamically linked I have no problems. However, when I try static compilation I get tons of errors such as:
aes.cpp:(.text+0x706): undefined reference to `EVP_DecryptInit_ex'
aes.cpp:(.text+0x732): undefined reference to `EVP_DecryptUpdate'
aes.cpp:(.text+0x763): undefined reference to `EVP_CIPHER_CTX_ctrl'
aes.cpp:(.text+0x792): undefined reference to `EVP_DecryptFinal_ex'
aes.cpp:(.text+0x7a1): undefined reference to `EVP_CIPHER_CTX_free'
Essentially none of the symbols are being found. I'm not sure what I need to do now. I've tried build my object files as static to but that fails. I've looked into linking order, but that seems right.
My question boils down to two things:
When static linking other objects, do those objects need to be statically compiled as well + archived?
What is wrong with my setup?
You don't need REST_LIBS for your rest.o rule, as it only compiles a source file. You need to pass those libraries to g++ in main rule - as part of it, g++ will call linker.
Ok so apparently linking happens in the opposite order than I thought... and I think it's possible I might have not been linking either originally as a fufu mistake.
REST_LIBS = -lboost_filesystem -lboost_system -lcpprest -lssl -lcrypto -ldl
# /usr/local/lib/libyaml-cpp.a
all: main
main: static_pack
g++ -std=c++14 -D DEBUG -Wfatal-errors -I$(basepath)/vendors/cpp-jwt/include -I$(basepath)/vendors/json/include \
-DTS=\"/ctts.json\" \
-DCS_PATH=\"/bin\" \
-DCTFS_ENC=\"/ctfs.enc\" \
-DUNTAR_PATH=\"/\" \
-DCLUSTER_PATH=\"/.clusters\" \
-o run main.cpp \
libmain.a $(REST_LIBS) -pthread && \
rm -rf debpkg/cs/usr/bin/cs debpkg/cs.deb && \
cp run debpkg/cs/usr/bin/cs && \
dpkg-deb -b debpkg/cs && \
mv debpkg/cs.deb .

Compiling GCC 6.1 on Ubuntu 16.04

Command I have used the following commands to build GCC 6.1:
sudo apt-get -y install libmpfr-dev libgmp3-dev libgmp-dev libmpc-dev flex bison libisl-dev
wget http://nl.mirror.babylon.network/gcc/releases/gcc-6.1.0/gcc-6.1.0.tar.bz2 -O - | tar xjvf -
cd gcc-6.1.0
./configure --enable-shared --disable-checking --enable-languages=c,c++ --disable-multilib
make -j4
When trying to compile GCC 6.1 on Ubuntu 16.04 / x86_64 I get the following error.
libtool: link: /home/user/build/gcc-6.1.0/host-x86_64-pc-linux-gnu/gcc/xgcc -shared-libgcc -B/home/user/build/gcc-6.1.0/host-x86_64-pc-linux-gnu/gcc -nostdinc++ -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/src -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include -fPIC -DPIC -D_GLIBCXX_SHARED -shared -nostdlib /usr/lib/x86_64-linux-gnu/crti.o /home/user/build/gcc-6.1.0/host-x86_64-pc-linux-gnu/gcc/crtbeginS.o .libs/compatibility.o .libs/compatibility-debug_list.o .libs/compatibility-debug_list-2.o .libs/compatibility-c++0x.o .libs/compatibility-atomic-c++0x.o .libs/compatibility-thread-c++0x.o .libs/compatibility-chrono.o .libs/compatibility-condvar.o -Wl,--whole-archive ../libsupc++/.libs/libsupc++convenience.a ../src/c++98/.libs/libc++98convenience.a ../src/c++11/.libs/libc++11convenience.a -Wl,--no-whole-archive -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/src -L/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -lm -L/home/user/build/gcc-6.1.0/host-x86_64-pc-linux-gnu/gcc -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -lc -lgcc_s /home/user/build/gcc-6.1.0/host-x86_64-pc-linux-gnu/gcc/crtendS.o /usr/lib/x86_64-linux-gnu/crtn.o -Wl,-O1 -Wl,-z -Wl,relro -Wl,-soname -Wl,libstdc++.so.6 -o .libs/libstdc++.so.6.0.22
/usr/bin/ld: ../src/c++11/.libs/libc++11convenience.a(cow-sstream-inst.o): relocation R_X86_64_PC32 against symbol `_ZTCSt18basic_stringstreamIwSt11char_traitsIwESaIwEE16_St13basic_ostreamIwS1_E' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Makefile:606: recipe for target 'libstdc++.la' failed
make[6]: *** [libstdc++.la] Error 1
make[6]: Leaving directory '/home/user/build/gcc-6.1.0/x86_64-pc-linux-gnu/libstdc++-v3/src'
The problematic line seems to be this one:
/usr/bin/ld:
../src/c++11/.libs/libc++11convenience.a(cow-sstream-inst.o):
relocation R_X86_64_PC32 against symbol
`_ZTCSt18basic_stringstreamIwSt11char_traitsIwESaIwEE16_St13basic_ostreamIwS1_E'
can not be used when making a shared object; recompile with -fPIC
It says recompile with -fPIC, but I can't seem to find the ./configure flag which makes sure libc++11convenience gets built with -fPIC.
I have been searching for a solution, but couldn't find anything. What should I do at this point to successfully compile gcc6.1?
Read carefully the GCC install instructions. GCC should not be built inside its source tree:
First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree.
You should try again, perhaps something like:
wget \
http://nl.mirror.babylon.network/gcc/releases/gcc-6.1.0/gcc-6.1.0.tar.bz2 -O - \
| tar xjvf -
mkdir Gcc6BuildTree
cd Gcc6BuildTree
../gcc-6.1.0/configure --enable-shared --disable-checking \
--enable-languages=c,c++ --disable-multilib --program-suffix=-6
make -j4
BTW, try first /usr/bin/gcc -v; that will give you how the system compiler was configured & built. And it is inspirational.
Also, I strongly recommend using --program-suffix= (and I would recommend configuring also the GCCJIT)
And you might try first to run aptitude build-dep gcc-6 (or gcc-5) to get the useful dependencies (dependencies for GCC 6 have much in common with dependencies for GCC 5).
Perhaps your Ubuntu already ships with some gcc-6? Did you try aptitude install gcc-6 ? See also this answer.
Also GCC 6.2 was released a few weeks ago (in august 2016). You'll better build gcc 6.2 instead of gcc 6.1
Notice also that the source tarball has a contrib/download_prerequisites script which you might find useful.
NB: gcc-help#gcc.gnu.org might be a better place to ask your question.

Libtool version mismatch

I have downloaded the source of some old project. I'm trying to build it now:
./bootstrap && ./configure
It works fine, but:
make
/bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -W -g -O2 -DDEBUG -MT rcclexer.lo -MD -MP -MF .deps/rcclexer.Tpo -c -o rcclexer.lo rcclexer.cpp
../libtool: line 415: CDPATH: command not found
libtool: Version mismatch error. This is libtool 2.4.2, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2
libtool: and run autoconf again.
p.s. that small project page: http://sourceforge.net/projects/rccparser/
Any help?
Something like:
autoreconf -fvi
maybe? I'd hope bootstrap would take care of that though, but it looks like it doesn't.