diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-19 13:22:37 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-19 17:38:14 +0100 |
commit | 2c1e0733981fc3fc7531530f13f56e9c28d457f5 (patch) | |
tree | a832ac556419d675f49388b7c297d16a0c6524a0 /src | |
parent | b727fce66b3601bddf4f37d64a620caba5e8a786 (diff) | |
download | bootstrappable-toolchain-2c1e0733981fc3fc7531530f13f56e9c28d457f5.tar.gz |
Support wrapping bootstrap CC for autotools
During the initial bootstrap phase, an old autotools project (gcc
4.7.4) is built and this potentially with a new compiler. For some
of the tests carried out by the autotools, the compiler is used
without the CFLAGS provided. Therefore, offer to wrap the compiler
with the given flags to avoid that the autotools draw incorrect
conclusions if the compile attempt fails for a different reason,
e.g., because implicit declarations are now considered errors by
default by modern C compilers.
Diffstat (limited to 'src')
-rw-r--r-- | src/bootstrap/stage-0-gcc.TARGETS | 256 |
1 files changed, 158 insertions, 98 deletions
diff --git a/src/bootstrap/stage-0-gcc.TARGETS b/src/bootstrap/stage-0-gcc.TARGETS index 26fbfa3..ffebd86 100644 --- a/src/bootstrap/stage-0-gcc.TARGETS +++ b/src/bootstrap/stage-0-gcc.TARGETS @@ -53,114 +53,174 @@ , "localbase": [["@", "busybox", "", "bootstrap"], ["@", "make", "", "bootstrap"]] , "cmds": - [ { "type": "join" - , "$1": - [ "HOST_SYSTEM_HDR_DIR='" - , { "type": "lookup" - , "key": "HOST_SYSTEM_HDR_DIR" - , "map": - { "type": "var" - , "name": "TOOLCHAIN_CONFIG" - , "default": {"type": "empty_map"} - } - , "default": "" + { "type": "++" + , "$1": + [ [ { "type": "join" + , "$1": + [ "HOST_SYSTEM_HDR_DIR='" + , { "type": "lookup" + , "key": "HOST_SYSTEM_HDR_DIR" + , "map": + { "type": "var" + , "name": "TOOLCHAIN_CONFIG" + , "default": {"type": "empty_map"} + } + , "default": "" + } + , "'" + ] } - , "'" - ] - } - , { "type": "join" - , "$1": - [ "HOST_SYSTEM_LIB_DIR='" - , { "type": "lookup" - , "key": "HOST_SYSTEM_LIB_DIR" - , "map": - { "type": "var" - , "name": "TOOLCHAIN_CONFIG" - , "default": {"type": "empty_map"} - } - , "default": "" + , { "type": "join" + , "$1": + [ "HOST_SYSTEM_LIB_DIR='" + , { "type": "lookup" + , "key": "HOST_SYSTEM_LIB_DIR" + , "map": + { "type": "var" + , "name": "TOOLCHAIN_CONFIG" + , "default": {"type": "empty_map"} + } + , "default": "" + } + , "'" + ] + } + , { "type": "join" + , "$1": + [ "HOST_DYNAMIC_LINKER='" + , { "type": "lookup" + , "key": "HOST_DYNAMIC_LINKER" + , "map": + { "type": "var" + , "name": "TOOLCHAIN_CONFIG" + , "default": {"type": "empty_map"} + } + , "default": "" + } + , "'" + ] } - , "'" + , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)" + , "export MAKEINFO=missing" + , "export MAKE=${LOCALBASE}/bin/make" + , "export PATH=$(pwd)/binutils/bin:${LOCALBASE}/bin:$PATH" + , "export BUILD_ROOT_DIR=${ACTION_DIR}" + , "export SHELL=${LOCALBASE}/bin/sh" + , "export CONFIG_SHELL=${LOCALBASE}/bin/sh" + , "export CXX=no" + , "unset LDFLAGS" + , "CONF_ARGS=" + , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then" + , " CONF_ARGS=\"$CONF_ARGS --with-sysroot=/ --with-native-system-header-dir=$HOST_SYSTEM_HDR_DIR\"" + , "fi" + , "LINK_ARGS=" + , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then" + , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\"" + , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\"" + , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\"" + , "fi" + , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then" + , " mv src/gcc/config src/gcc/config.orig" + , " cp -r src/gcc/config.orig src/gcc/config" + , " chmod -R +w src/gcc/config" + , " for h in src/gcc/config/*/*.h; do" + , " grep -q _DYNAMIC_LINKER \"$h\" || continue" + , " sed -i 's|\\(^#define [A-Z]*_DYNAMIC_LINKER[A-Z0-9]* *\"\\).*\"|\\1'$HOST_DYNAMIC_LINKER'\"|g' \"$h\"" + , " done" + , "fi" + , "export LDFLAGS_FOR_TARGET=\"${LINK_ARGS}\"" + , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then" + , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd" + , " export PATH=$PATH:${TMPDIR}" + , "fi" + , "cp -r binutils/. ${DESTDIR}/." + , "chmod -R +w ${DESTDIR}/*" ] - } - , { "type": "join" - , "$1": - [ "HOST_DYNAMIC_LINKER='" - , { "type": "lookup" - , "key": "HOST_DYNAMIC_LINKER" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "BOOTSTRAP_WRAP_CC" , "map": { "type": "var" , "name": "TOOLCHAIN_CONFIG" , "default": {"type": "empty_map"} } - , "default": "" } - , "'" + , "then": + [ "echo \"#!${SHELL}\" > wrapped-cc" + , { "type": "join" + , "separator": " " + , "$1": + [ "echo" + , { "type": "join_cmd" + , "$1": + [ "exec" + , { "type": "join_cmd" + , "$1": + { "type": "++" + , "$1": + [ [ { "type": "lookup" + , "key": "BOOTSTRAP_CC" + , "map": + { "type": "var" + , "name": "TOOLCHAIN_CONFIG" + , "default": {"type": "empty_map"} + } + , "default": "cc" + } + ] + , { "type": "lookup" + , "key": "BOOTSTRAP_CFLAGS" + , "map": + { "type": "var" + , "name": "TOOLCHAIN_CONFIG" + , "default": {"type": "empty_map"} + } + , "default": [] + } + ] + } + } + , "\"$@\"" + ] + } + , ">> wrapped-cc" + ] + } + , "chmod 755 wrapped-cc" + , "export CC=$(pwd)/wrapped-cc" + ] + } + , [ "cd src" + , "for f in $(find . -type f -exec grep -q '#! */bin/sh' {} \\; -print)" + , "do" + , " cp $f $f.__work" + , " rm $f" + , " chmod 755 $f.__work" + , " sed -i 's|#! */bin/sh|#!'\"${SHELL}\"'|g' $f.__work" + , " mv $f.__work $f" + , "done" + , "for f in mpfr/get_patches.c # Source modified in place" + , "do" + , " cp $f $f.__work" + , " rm $f" + , " chmod 755 $f.__work" + , " mv $f.__work $f" + , "done" + , "export check_msgfmt=no # do not use system's msgfmt, if available" + , "${SHELL} ./configure --prefix=/ --enable-languages=c,c++ --disable-multilib --disable-shared --disable-lto --disable-gcov --disable-libmudflap --disable-libgomp --disable-libssp --disable-nls --disable-libitm ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)" + , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)" + , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)" + , "cd ${DESTDIR}" + , "for f in $(find . -type f | grep '\\.o$'); do strip -g $f; done" + , "for f in $(find . -type f | grep '\\.a$'); do strip -g $f; done" + , "GCC_LIBDIR=\"lib/gcc/$(./bin/gcc -dumpmachine)/$(./bin/gcc -dumpfullversion -dumpversion)\"" + , "mv ${GCC_LIBDIR}/include-fixed ${TMPDIR}/" + , "cp -rL ${TMPDIR}/include-fixed ${GCC_LIBDIR}/. # resolve symlinks" + , "cd ${DESTDIR}/bin" ] - } - , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)" - , "export MAKEINFO=missing" - , "export MAKE=${LOCALBASE}/bin/make" - , "export PATH=$(pwd)/binutils/bin:${LOCALBASE}/bin:$PATH" - , "export BUILD_ROOT_DIR=${ACTION_DIR}" - , "export SHELL=${LOCALBASE}/bin/sh" - , "export CONFIG_SHELL=${LOCALBASE}/bin/sh" - , "export CXX=no" - , "unset LDFLAGS" - , "CONF_ARGS=" - , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then" - , " CONF_ARGS=\"$CONF_ARGS --with-sysroot=/ --with-native-system-header-dir=$HOST_SYSTEM_HDR_DIR\"" - , "fi" - , "LINK_ARGS=" - , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then" - , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\"" - , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\"" - , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\"" - , "fi" - , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then" - , " mv src/gcc/config src/gcc/config.orig" - , " cp -r src/gcc/config.orig src/gcc/config" - , " chmod -R +w src/gcc/config" - , " for h in src/gcc/config/*/*.h; do" - , " grep -q _DYNAMIC_LINKER \"$h\" || continue" - , " sed -i 's|\\(^#define [A-Z]*_DYNAMIC_LINKER[A-Z0-9]* *\"\\).*\"|\\1'$HOST_DYNAMIC_LINKER'\"|g' \"$h\"" - , " done" - , "fi" - , "export LDFLAGS_FOR_TARGET=\"${LINK_ARGS}\"" - , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then" - , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd" - , " export PATH=$PATH:${TMPDIR}" - , "fi" - , "cp -r binutils/. ${DESTDIR}/." - , "chmod -R +w ${DESTDIR}/*" - , "cd src" - , "for f in $(find . -type f -exec grep -q '#! */bin/sh' {} \\; -print)" - , "do" - , " cp $f $f.__work" - , " rm $f" - , " chmod 755 $f.__work" - , " sed -i 's|#! */bin/sh|#!'\"${SHELL}\"'|g' $f.__work" - , " mv $f.__work $f" - , "done" - , "for f in mpfr/get_patches.c # Source modified in place" - , "do" - , " cp $f $f.__work" - , " rm $f" - , " chmod 755 $f.__work" - , " mv $f.__work $f" - , "done" - , "export check_msgfmt=no # do not use system's msgfmt, if available" - , "${SHELL} ./configure --prefix=/ --enable-languages=c,c++ --disable-multilib --disable-shared --disable-lto --disable-gcov --disable-libmudflap --disable-libgomp --disable-libssp --disable-nls --disable-libitm ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)" - , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)" - , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)" - , "cd ${DESTDIR}" - , "for f in $(find . -type f | grep '\\.o$'); do strip -g $f; done" - , "for f in $(find . -type f | grep '\\.a$'); do strip -g $f; done" - , "GCC_LIBDIR=\"lib/gcc/$(./bin/gcc -dumpmachine)/$(./bin/gcc -dumpfullversion -dumpversion)\"" - , "mv ${GCC_LIBDIR}/include-fixed ${TMPDIR}/" - , "cp -rL ${TMPDIR}/include-fixed ${GCC_LIBDIR}/. # resolve symlinks" - , "cd ${DESTDIR}/bin" - ] + ] + } , "out_dirs": ["."] } , "link_args.h": |