summaryrefslogtreecommitdiff
path: root/src/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/stage-0-binutils.TARGETS74
-rw-r--r--src/bootstrap/stage-0-busybox.TARGETS63
-rw-r--r--src/bootstrap/stage-0-gcc.TARGETS150
-rw-r--r--src/bootstrap/stage-0-make.TARGETS54
-rw-r--r--src/bootstrap/stage-1-gcc.TARGETS156
5 files changed, 497 insertions, 0 deletions
diff --git a/src/bootstrap/stage-0-binutils.TARGETS b/src/bootstrap/stage-0-binutils.TARGETS
new file mode 100644
index 0000000..3a42b4a
--- /dev/null
+++ b/src/bootstrap/stage-0-binutils.TARGETS
@@ -0,0 +1,74 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-ar"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "binutils"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "flag_files":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "cmds":
+ [ "echo 'int main() {int i=1; return *((char*)&i) == 1;}' > endian_test.c"
+ , "${CC} -o endian_test endian_test.c"
+ , "CFLAGS=\"-D__$(./endian_test && echo BIG || echo LITTLE)_ENDIAN__=1\""
+ , "echo \"${CFLAGS}\" > ${DESTDIR}/cflags"
+ ]
+ , "outs": ["cflags"]
+ }
+, "staged_bootstrap_sources_and_flags":
+ { "type": "install"
+ , "dirs":
+ [ ["files", "src"]
+ , ["flag_files", "flags"]
+ , [["@", "scripts", "", "bootstrap-ar"], "."]
+ ]
+ }
+, "bootstrap-ar":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources_and_flags"]
+ , "localbase":
+ [["@", "busybox", "", "bootstrap"], ["@", "make", "", "bootstrap"]]
+ , "cmds":
+ [ "export LD=${CC}"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export CFLAGS=\"$(cat flags/cflags)\""
+ , "./bootstrap-ar.sh src >build.log 2>&1 || (cat build.log && exit 1)"
+ , "mv ar ${DESTDIR}/bin/"
+ ]
+ , "outs": ["bin/ar"]
+ }
+, "binutils":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources_and_flags"]
+ , "localbase":
+ [ ["@", "busybox", "", "bootstrap"]
+ , ["@", "make", "", "bootstrap"]
+ , "bootstrap"
+ ]
+ , "cmds":
+ [ "export LD=${CC}"
+ , "export RANLIB=true"
+ , "export AR=${LOCALBASE}/bin/ar"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export CFLAGS=\"$(cat flags/cflags)\""
+ , "unset LDFLAGS"
+ , "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"
+ , "mkdir build"
+ , "cd build"
+ , "../src/configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j1 MAKEINFO=true >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j1 MAKEINFO=true DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "for f in $(find ${DESTDIR} -type f -name '*.la'); do sed -i 's|'$(pwd)'|/build|g' $f; done"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-busybox.TARGETS b/src/bootstrap/stage-0-busybox.TARGETS
new file mode 100644
index 0000000..3d0c315
--- /dev/null
+++ b/src/bootstrap/stage-0-busybox.TARGETS
@@ -0,0 +1,63 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-essentials"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "busybox"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "staged_bootstrap_sources":
+ { "type": "install"
+ , "dirs":
+ [["files", "src"], [["@", "scripts", "", "bootstrap-busybox"], "."]]
+ }
+, "bootstrap-essentials":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources"]
+ , "cmds":
+ [ "cd bootstrap-busybox"
+ , "./bootstrap.sh ../src editors awk >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors cmp >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors sed >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors diff >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors patch >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src archival tar >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src archival bzip2 >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src findutils grep >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src findutils find >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "mv awk cmp sed diff patch tar bzip2 grep find ${DESTDIR}/bin/"
+ ]
+ , "outs":
+ [ "bin/awk"
+ , "bin/cmp"
+ , "bin/sed"
+ , "bin/diff"
+ , "bin/patch"
+ , "bin/tar"
+ , "bin/bzip2"
+ , "bin/grep"
+ , "bin/find"
+ ]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "gcc"]]}
+, "busybox":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": ["bootstrap", ["@", "make", "", "bootstrap"], "staged-gcc"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export PATH=${LOCALBASE}/bin:${LOCALBASE}/gcc/bin:$PATH"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export CC=${LOCALBASE}/gcc/bin/gcc"
+ , "export CXX=${LOCALBASE}/gcc/bin/g++"
+ , "${MAKE} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" defconfig >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" CONFIG_PREFIX=${DESTDIR} install >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-gcc.TARGETS b/src/bootstrap/stage-0-gcc.TARGETS
new file mode 100644
index 0000000..8a86620
--- /dev/null
+++ b/src/bootstrap/stage-0-gcc.TARGETS
@@ -0,0 +1,150 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-4.7.4"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "separate_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [ ["files", "gcc"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ , [["@", "patches", "", "gcc-4.7.4"], "patches"]
+ ]
+ }
+, "combined_patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["separate_sources_and_patches"]
+ , "localbase": [["@", "busybox", "", "bootstrap"]]
+ , "cmds":
+ [ "export PATCH=${LOCALBASE}/bin/patch"
+ , "mv gmp mpc mpfr gcc/."
+ , "cp -r gcc/. ${DESTDIR}/. && chmod -R +w ${DESTDIR}/*"
+ , "cd ${DESTDIR}"
+ , "echo '#include <sys/ucontext.h>\nucontext_t foo;' > ${TMPDIR}/test.c"
+ , "if \"${CC}\" -c ${TMPDIR}/test.c -o ${TMPDIR}/test.o >/dev/null 2>&1; then"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/use-ucontext_t.patch >/dev/null"
+ , "fi"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/various-fixes/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/various-fixes/$p >/dev/null"
+ , "done"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/musl-support/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/musl-support/$p >/dev/null"
+ , "done"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/reproducibility/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/reproducibility/$p >/dev/null"
+ , "done"
+ ]
+ , "out_dirs": ["."]
+ }
+, "staged_sources_and_binutils":
+ { "type": "install"
+ , "dirs":
+ [ ["combined_patched_sources", "src"]
+ , [["@", "binutils", "", "toolchain"], "binutils"]
+ ]
+ }
+, "gcc-4.7.4":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["staged_sources_and_binutils"]
+ , "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": "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}"
+ , "unset CFLAGS 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"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "./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"
+ , "cd ${DESTDIR}/bin"
+ , "mv gcc gcc.real"
+ , "mv g++ g++.real"
+ , "printf '#!/bin/sh\\nexport PATH=\"$(dirname $0):$PATH\"\\nexec gcc.real %s \"$@\"' \"${LINK_ARGS}\" >gcc"
+ , "printf '#!/bin/sh\\nexport PATH=\"$(dirname $0):$PATH\"\\nexec g++.real %s \"$@\"' \"${LINK_ARGS}\" >g++"
+ , "chmod +x gcc g++"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-make.TARGETS b/src/bootstrap/stage-0-make.TARGETS
new file mode 100644
index 0000000..3a38240
--- /dev/null
+++ b/src/bootstrap/stage-0-make.TARGETS
@@ -0,0 +1,54 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-make"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "make"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "bootstrap-make":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": [["@", "busybox", "", "bootstrap"]]
+ , "cmds":
+ [ "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export LD=${CC}"
+ , "export AR=true"
+ , "export RANLIB=true"
+ , "cd ${TMPDIR}"
+ , "${WORKDIR}/configure --prefix=/ --disable-nls --disable-rpath --disable-load --disable-dependency-tracking >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "./build.sh >build.log 2>&1 || true"
+ , "${CC} -o make $(ls src/*.o lib/*.o | LC_ALL=C sort) >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "mv make ${DESTDIR}/bin/"
+ ]
+ , "outs": ["bin/make"]
+ }
+, "staged-localbase":
+ { "type": "install"
+ , "dirs":
+ [ [["@", "busybox", "", "toolchain"], "busybox"]
+ , ["bootstrap", "make"]
+ , [["@", "gcc", "", "toolchain"], "gcc"]
+ ]
+ }
+, "make":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": ["staged-localbase"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset CFLAGS LDFLAGS"
+ , "export PATH=${LOCALBASE}/busybox/bin:${LOCALBASE}/busybox/usr/bin:${LOCALBASE}/make/bin:${LOCALBASE}/gcc/bin:$PATH"
+ , "export MAKE=${LOCALBASE}/make/bin/make"
+ , "export CC=${LOCALBASE}/gcc/bin/gcc"
+ , "export CXX=unused"
+ , "./configure --prefix=/ --disable-rpath --disable-load >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-1-gcc.TARGETS b/src/bootstrap/stage-1-gcc.TARGETS
new file mode 100644
index 0000000..42282ca
--- /dev/null
+++ b/src/bootstrap/stage-1-gcc.TARGETS
@@ -0,0 +1,156 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-10.2.0"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [[["TREE", null, "."], "src"], [["@", "patches", "", "gcc-10"], "patches"]]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/gcc-10/detect-glibc-via-__GLIBC__.patch >/dev/null"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-10/reproducibility/series); do"
+ , " patch -p1 < ${WORKDIR}/patches/gcc-10/reproducibility/$p >/dev/null"
+ , "done"
+ ]
+ , "out_dirs": ["."]
+ }
+, "patched_separate_sources":
+ { "type": "install"
+ , "dirs":
+ [ ["patched_sources", "src"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ ]
+ }
+, "binutils":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["@", "binutils", "", "files"]]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset LDFLAGS"
+ , "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"
+ , "mkdir build"
+ , "cd build"
+ , "../configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "find ${DESTDIR} -type f -name '*.la' -exec sed -i 's|'$(pwd)'|/build|g' {} \\;"
+ ]
+ , "out_dirs": ["."]
+ }
+, "gcc-10.2.0":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_separate_sources"]
+ , "localbase": ["binutils"]
+ , "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": "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 PATH=${LOCALBASE}/bin:$PATH"
+ , "export BUILD_ROOT_DIR=${ACTION_DIR}"
+ , "unset CFLAGS 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 ${LOCALBASE}/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mv gmp mpc mpfr src/."
+ , "cd src"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "./configure --prefix=/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --disable-libsanitizer ${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}"
+ , "strip ./bin/*"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "if [ -n \"${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv gcc gcc.real"
+ , " mv g++ g++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/gcc.real %s \"$@\"' \"${LINK_ARGS}\" >gcc"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/g++.real %s \"$@\"' \"${LINK_ARGS}\" >g++"
+ , " chmod +x gcc g++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+}