* Building gcc for C and C++ with a custom glibc
@ 2021-01-17 21:04 Tom Honermann
2021-01-17 21:08 ` H.J. Lu
0 siblings, 1 reply; 3+ messages in thread
From: Tom Honermann @ 2021-01-17 21:04 UTC (permalink / raw)
To: gcc
Hi all. I've been trying to build a custom gcc (trunk) with a custom
glibc (trunk) with support for C and C++ on x86_64 Linux and have so far
been unsuccessful at identifying a sequence of configure/make
invocations that completes successfully. I'm not trying to build a
cross compiler.
The scenario I'm trying to satisfy is testing some changes to gcc, and
additional changes to libstdc++ that have new autoconf and header
dependencies on the presence of new functions in existing glibc headers.
The glibc installation I'm trying to use was built with:
mkdir glibc-build
cd glibc-build
../glibc/configure \
CC=gcc \
CXX=g++ \
--prefix /.../glibc
make && make install
For gcc, I've tried numerous variants of the following:
mkdir gcc-build
cd gcc-build
../gcc/configure \
CC=gcc \
CXX=g++ \
--prefix /.../gcc \
--disable-multilib \
--enable-languages=c,c++ \
--enable-checking=release \
--disable-bootstrap \
--disable-lto
Things I've tried include setting CFLAGS, CXXFLAGS, and LDFLAGS to
specify additional glibc paths, to specify alternate paths (via
-nostdinc/-nostdinc++), setting LIBRARY_PATH and CPATH, passing
--with-sysroot, passing --with-headers and --with-libs, passing
--with-native-system-header-dir, some of those in conjunction with
removing --disable-bootstrap, and wrapping gcc in a script that attempts
to substitute certain include paths.
The problem I'm having is that, in every attempt, the glibc headers and
libraries from under /usr end up getting used instead of the custom
glibc ones at some point leading to build failures.
Does anyone have a recipe available for doing this?
Tom.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Building gcc for C and C++ with a custom glibc
2021-01-17 21:04 Building gcc for C and C++ with a custom glibc Tom Honermann
@ 2021-01-17 21:08 ` H.J. Lu
2021-01-23 17:49 ` Tom Honermann
0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2021-01-17 21:08 UTC (permalink / raw)
To: Tom Honermann; +Cc: GCC Development
On Sun, Jan 17, 2021 at 1:06 PM Tom Honermann via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi all. I've been trying to build a custom gcc (trunk) with a custom
> glibc (trunk) with support for C and C++ on x86_64 Linux and have so far
> been unsuccessful at identifying a sequence of configure/make
> invocations that completes successfully. I'm not trying to build a
> cross compiler.
>
> The scenario I'm trying to satisfy is testing some changes to gcc, and
> additional changes to libstdc++ that have new autoconf and header
> dependencies on the presence of new functions in existing glibc headers.
>
> The glibc installation I'm trying to use was built with:
>
> mkdir glibc-build
> cd glibc-build
> ../glibc/configure \
> CC=gcc \
> CXX=g++ \
> --prefix /.../glibc
> make && make install
>
> For gcc, I've tried numerous variants of the following:
>
> mkdir gcc-build
> cd gcc-build
> ../gcc/configure \
> CC=gcc \
> CXX=g++ \
> --prefix /.../gcc \
> --disable-multilib \
> --enable-languages=c,c++ \
> --enable-checking=release \
> --disable-bootstrap \
> --disable-lto
>
> Things I've tried include setting CFLAGS, CXXFLAGS, and LDFLAGS to
> specify additional glibc paths, to specify alternate paths (via
> -nostdinc/-nostdinc++), setting LIBRARY_PATH and CPATH, passing
> --with-sysroot, passing --with-headers and --with-libs, passing
> --with-native-system-header-dir, some of those in conjunction with
> removing --disable-bootstrap, and wrapping gcc in a script that attempts
> to substitute certain include paths.
>
> The problem I'm having is that, in every attempt, the glibc headers and
> libraries from under /usr end up getting used instead of the custom
> glibc ones at some point leading to build failures.
>
> Does anyone have a recipe available for doing this?
Try scripts/build-many-glibcs.py in glibc source.
--
H.J.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Building gcc for C and C++ with a custom glibc
2021-01-17 21:08 ` H.J. Lu
@ 2021-01-23 17:49 ` Tom Honermann
0 siblings, 0 replies; 3+ messages in thread
From: Tom Honermann @ 2021-01-23 17:49 UTC (permalink / raw)
To: H.J. Lu; +Cc: GCC Development
On 1/17/21 4:08 PM, H.J. Lu wrote:
> On Sun, Jan 17, 2021 at 1:06 PM Tom Honermann via Gcc <gcc@gcc.gnu.org> wrote:
>> Hi all. I've been trying to build a custom gcc (trunk) with a custom
>> glibc (trunk) with support for C and C++ on x86_64 Linux and have so far
>> been unsuccessful at identifying a sequence of configure/make
>> invocations that completes successfully. I'm not trying to build a
>> cross compiler.
>>
>> The scenario I'm trying to satisfy is testing some changes to gcc, and
>> additional changes to libstdc++ that have new autoconf and header
>> dependencies on the presence of new functions in existing glibc headers.
>>
>> The glibc installation I'm trying to use was built with:
>>
>> mkdir glibc-build
>> cd glibc-build
>> ../glibc/configure \
>> CC=gcc \
>> CXX=g++ \
>> --prefix /.../glibc
>> make && make install
>>
>> For gcc, I've tried numerous variants of the following:
>>
>> mkdir gcc-build
>> cd gcc-build
>> ../gcc/configure \
>> CC=gcc \
>> CXX=g++ \
>> --prefix /.../gcc \
>> --disable-multilib \
>> --enable-languages=c,c++ \
>> --enable-checking=release \
>> --disable-bootstrap \
>> --disable-lto
>>
>> Things I've tried include setting CFLAGS, CXXFLAGS, and LDFLAGS to
>> specify additional glibc paths, to specify alternate paths (via
>> -nostdinc/-nostdinc++), setting LIBRARY_PATH and CPATH, passing
>> --with-sysroot, passing --with-headers and --with-libs, passing
>> --with-native-system-header-dir, some of those in conjunction with
>> removing --disable-bootstrap, and wrapping gcc in a script that attempts
>> to substitute certain include paths.
>>
>> The problem I'm having is that, in every attempt, the glibc headers and
>> libraries from under /usr end up getting used instead of the custom
>> glibc ones at some point leading to build failures.
>>
>> Does anyone have a recipe available for doing this?
> Try scripts/build-many-glibcs.py in glibc source.
>
Thank you for the suggestion. I studied the script and tried using it,
but it also encountered errors during the 2nd stage gcc build. I didn't
delve into those errors.
This is what ended up working for me:
mkdir -p "$BINUTILS_BUILD_DIR"
cd "$BINUTILS_BUILD_DIR"
"../$BINUTILS_SOURCE_DIR/configure" \
CC=gcc \
CXX=g++ \
--prefix "$INSTALL_DIR" \
--with-sysroot="$INSTALL_DIR" \
--disable-multilib \
;
make -j 4 && make install
cd -
cd "$LINUX_SOURCE_DIR"
make INSTALL_HDR_PATH="$INSTALL_DIR" headers_install
cd -
mkdir -p "$GLIBC_BUILD_DIR"
cd "$GLIBC_BUILD_DIR"
"../$GLIBC_SOURCE_DIR/configure" \
CC=gcc \
CXX=g++ \
--prefix "$INSTALL_DIR" \
--disable-multilib \
--with-headers="$INSTALL_DIR/include" \
;
make -j 4 && make install
cd -
# Fixup paths in libc.so and libm.so. I wasn't able to find a
combination of
# 'configure --prefix' and 'make prefix=... DESTIDIR=...' that did
the right thing.
cp "$INSTALL_DIR/lib/libc.so" "$INSTALL_DIR/lib/libc.so.orig"
sed -e "s%$INSTALL_DIR%%g" "$INSTALL_DIR/lib/libc.so.orig" >
"$INSTALL_DIR/lib/libc.so"
rm -f "$INSTALL_DIR/lib/libc.so.orig"
cp "$INSTALL_DIR/lib/libm.so" "$INSTALL_DIR/lib/libm.so.orig"
sed -e "s%$INSTALL_DIR%%g" "$INSTALL_DIR/lib/libm.so.orig" >
"$INSTALL_DIR/lib/libm.so"
rm -f "$INSTALL_DIR/lib/libm.so.orig"
mkdir -p "$GCC_BUILD_DIR"
cd "$GCC_BUILD_DIR"
"../$GCC_SOURCE_DIR/configure" \
CC=gcc \
CXX=g++ \
--prefix "$INSTALL_DIR" \
--with-sysroot="$INSTALL_DIR" \
--with-native-system-header-dir="/include" \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-multilib \
--enable-checking=release \
--disable-lto \
;
make -j 4 && make install
cd -
Tom.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-23 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 21:04 Building gcc for C and C++ with a custom glibc Tom Honermann
2021-01-17 21:08 ` H.J. Lu
2021-01-23 17:49 ` Tom Honermann
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).