|
| 1 | +# Note that this script can accept some limited command-line arguments, run |
| 2 | +# `julia build_tarballs.jl --help` to see a usage message. |
| 3 | +using BinaryBuilder, Pkg |
| 4 | + |
| 5 | +name = "GCCBootstrap" |
| 6 | +version = v"9.4.0" |
| 7 | + |
| 8 | +# Collection of sources required to complete build |
| 9 | +sources = [ |
| 10 | + # crosstool-ng will provide the build script |
| 11 | + ArchiveSource("http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.25.0_rc1.tar.bz2", |
| 12 | + "8a839df71bea7b2c411447b41b917f2142482df171733ddb92d615cec2f0f43a"), |
| 13 | + |
| 14 | + # We provide some configs for crostool-ng |
| 15 | + DirectorySource("./bundled"), |
| 16 | + |
| 17 | + # crosstool-ng can download the files, but we'd rather download them ourselves |
| 18 | + FileSource("http://mirrors.kernel.org/gnu/gcc/gcc-9.4.0/gcc-9.4.0.tar.xz", |
| 19 | + "c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e"), |
| 20 | + FileSource("https://mirrors.kernel.org/gnu/mpfr/mpfr-4.1.0.tar.xz", |
| 21 | + "0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f"), |
| 22 | + FileSource("https://mirrors.kernel.org/gnu/mpc/mpc-1.2.1.tar.gz", |
| 23 | + "17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459"), |
| 24 | + FileSource("https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2", |
| 25 | + "fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"), |
| 26 | + FileSource("https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz", |
| 27 | + "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2"), |
| 28 | + FileSource("http://mirrors.kernel.org/pub/linux/kernel/v4.x/linux-4.1.49.tar.xz", |
| 29 | + "ff2e0ea5c536650aef64447c3aaa49c1a25e8f1db4ec4f7da700d3176f512ba8"), |
| 30 | + FileSource("https://mirrors.kernel.org/gnu/glibc/glibc-2.19.tar.xz", |
| 31 | + "2d3997f588401ea095a0b27227b1d50cdfdd416236f6567b564549d3b46ea2a2"), |
| 32 | + FileSource("https://musl.libc.org/releases/musl-1.2.2.tar.gz", |
| 33 | + "9b969322012d796dc23dda27a35866034fa67d8fb67e0e2c45c913c3d43219dd"), |
| 34 | + FileSource("https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v9.0.0.tar.bz2", |
| 35 | + "1929b94b402f5ff4d7d37a9fe88daa9cc55515a6134805c104d1794ae22a4181"), |
| 36 | + FileSource("https://github.com/madler/zlib/archive/refs/tags/v1.2.11.tar.gz", |
| 37 | + "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", |
| 38 | + filename="zlib-1.2.11.tar.gz"), |
| 39 | + FileSource("http://mirrors.kernel.org/gnu/ncurses/ncurses-6.2.tar.gz", |
| 40 | + "30306e0c76e0f9f1f0de987cf1c82a5c21e1ce6568b9227f7da5b71cbea86c9d"), |
| 41 | + FileSource("http://mirrors.kernel.org/gnu/libiconv/libiconv-1.16.tar.gz", |
| 42 | + "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04"), |
| 43 | + FileSource("http://mirrors.kernel.org/gnu/gettext/gettext-0.21.tar.xz", |
| 44 | + "d20fcbb537e02dcf1383197ba05bd0734ef7bf5db06bdb241eb69b7d16b73192"), |
| 45 | + FileSource("http://mirrors.kernel.org/gnu/binutils/binutils-2.29.1.tar.xz", |
| 46 | + "e7010a46969f9d3e53b650a518663f98a5dde3c3ae21b7d71e5e6803bc36b577"), |
| 47 | + FileSource("http://mirrors.kernel.org/gnu/binutils/binutils-2.38.tar.xz", |
| 48 | + "e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024"), |
| 49 | +] |
| 50 | + |
| 51 | +# Bash recipe for building across all platforms |
| 52 | +script = raw""" |
| 53 | +cd ${WORKSPACE}/srcdir/crosstool-ng*/ |
| 54 | +
|
| 55 | +# These tools will help us to bootstrap |
| 56 | +apk add build-base texinfo help2man ncurses-dev |
| 57 | +
|
| 58 | +# Copy in our extra patches for all packages |
| 59 | +for package in ${WORKSPACE}/srcdir/patches/*; do |
| 60 | + package="$(basename "${package}")" |
| 61 | + for version in ${WORKSPACE}/srcdir/patches/${package}/*; do |
| 62 | + version="$(basename "${version}")" |
| 63 | + if [ ! -d packages/${package}/${version} ]; then |
| 64 | + continue |
| 65 | + fi |
| 66 | + cp -v ${WORKSPACE}/srcdir/patches/${package}/${version}/* packages/${package}/${version}/ |
| 67 | + done |
| 68 | +done |
| 69 | +
|
| 70 | +# Disable some checks that ct-ng performs |
| 71 | +export CT_ALLOW_BUILD_AS_ROOT_SURE=1 |
| 72 | +
|
| 73 | +# Unset some things that BB automatically inserts into the environment, |
| 74 | +# but which crosstool-ng rightfully complains about. |
| 75 | +unset LD_LIBRARY_PATH |
| 76 | +for TOOL in CC CXX LD AS AR FC OBJCOPY OBJDUMP RANLIB STRIP LIPO MESON NM READELF; do |
| 77 | + unset "${TOOL}" "BUILD_${TOOL}" "${TOOL}_BUILD" "${TOOL}_FOR_BUILD" "HOST${TOOL}" |
| 78 | +done |
| 79 | +PATH="$(printf "%s" "$(echo -n "${PATH}" | tr ':' '\n' | grep -v "/opt")" | tr '\n' ':')" |
| 80 | +
|
| 81 | +
|
| 82 | +# Build crosstool-ng for the current host |
| 83 | +./configure --enable-local |
| 84 | +make -j${nproc} |
| 85 | +
|
| 86 | +# Generate the appropriate crosstool-ng config file for our current target |
| 87 | +${WORKSPACE}/srcdir/gen_config.sh > .config |
| 88 | +cat .config |
| 89 | +
|
| 90 | +# This takes our stripped-down config and fills out all the other options |
| 91 | +./ct-ng upgradeconfig |
| 92 | +
|
| 93 | +# Do the actual build! |
| 94 | +./ct-ng build |
| 95 | +
|
| 96 | +# Fix case-insensitivity problems in netfilter headers |
| 97 | +if [[ "${target}" == *linux* ]]; then |
| 98 | + NF="${prefix}/${target}/sysroot/usr/include/linux/netfilter" |
| 99 | + for NAME in CONNMARK DSCP MARK RATEEST TCPMSS; do |
| 100 | + mv "${NF}/xt_${NAME}.h" "${NF}/xt_${NAME}_.h" |
| 101 | + done |
| 102 | + for NAME in ECN TTL; do |
| 103 | + mv "${NF}_ipv4/ipt_${NAME}.h" "${NF}_ipv4/ipt_${NAME}_.h" |
| 104 | + done |
| 105 | + mv "${NF}_ipv6/ip6t_HL.h" "${NF}_ipv6/ip6t_HL_.h" |
| 106 | +fi |
| 107 | +
|
| 108 | +# Move licenses to the right spot |
| 109 | +mkdir -p /tmp/GCCBootstrap |
| 110 | +mv ${prefix}/share/licenses/* /tmp/GCCBootstrap |
| 111 | +mv /tmp/GCCBootstrap ${prefix}/share/licenses/ |
| 112 | +
|
| 113 | +[[ -f "${bindir}/${target}-gcc" ]] |
| 114 | +""" |
| 115 | + |
| 116 | +# These are the platforms we will build for by default, unless further |
| 117 | +# platforms are passed in on the command line |
| 118 | +platforms = filter(p -> Sys.islinux(p) || Sys.iswindows(p), supported_platforms()) |
| 119 | + |
| 120 | +# The products that we will ensure are always built |
| 121 | +products = Product[ |
| 122 | + #ExecutableProduct("gcc", :gcc) |
| 123 | +] |
| 124 | + |
| 125 | +# Dependencies that must be installed before this package can be built |
| 126 | +dependencies = Dependency[ |
| 127 | +] |
| 128 | + |
| 129 | +# Build the tarballs, and possibly a `build.jl` as well. |
| 130 | +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") |
0 commit comments