Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / taskcluster / scripts / misc / build-cctools-port.sh
blob203d4c85ffaea3f9916860f45ac0b2f5b3f62ee7
1 #!/bin/bash
3 # cctools sometimes needs to be rebuilt when clang is modified.
4 # Until bug 1471905 is addressed, increase the following number
5 # when a forced rebuild of cctools is necessary: 1
7 set -x -e -v
9 # This script is for building cctools (Apple's binutils) for Linux using
10 # cctools-port (https://github.com/tpoechtrager/cctools-port).
11 WORKSPACE=$HOME/workspace
13 # Set some crosstools-port and libtapi directories
14 CROSSTOOLS_SOURCE_DIR=$MOZ_FETCHES_DIR/cctools-port
15 CROSSTOOLS_CCTOOLS_DIR=$CROSSTOOLS_SOURCE_DIR/cctools
16 CROSSTOOLS_BUILD_DIR=$WORKSPACE/cctools
17 LIBTAPI_SOURCE_DIR=$MOZ_FETCHES_DIR/apple-libtapi
18 LIBTAPI_BUILD_DIR=$WORKSPACE/libtapi-build
19 LDID_SOURCE_DIR=$MOZ_FETCHES_DIR/ldid
20 CLANG_DIR=$MOZ_FETCHES_DIR/clang
22 # Create our directories
23 mkdir -p $CROSSTOOLS_BUILD_DIR $LIBTAPI_BUILD_DIR
25 cd $GECKO_PATH
27 # Common setup for libtapi and cctools
28 export CC=$CLANG_DIR/bin/clang
29 export CXX=$CLANG_DIR/bin/clang++
30 # We also need this LD_LIBRARY_PATH at build time, since tapi builds bits of
31 # clang build tools, and then executes those tools.
32 export LD_LIBRARY_PATH=$CLANG_DIR/lib
34 # Build libtapi; the included build.sh is not sufficient for our purposes.
35 cd $LIBTAPI_BUILD_DIR
37 # Values taken from build.sh
38 TAPI_REPOSITORY=tapi-1000.10.8
39 TAPI_VERSION=10.0.0
41 INCLUDE_FIX="-I $LIBTAPI_SOURCE_DIR/src/llvm/projects/clang/include -I $PWD/projects/clang/include"
43 cmake $LIBTAPI_SOURCE_DIR/src/llvm \
44 -GNinja \
45 -DCMAKE_CXX_FLAGS="$INCLUDE_FIX" \
46 -DLLVM_INCLUDE_TESTS=OFF \
47 -DCMAKE_BUILD_TYPE=RELEASE \
48 -DCMAKE_INSTALL_PREFIX=$CROSSTOOLS_BUILD_DIR \
49 -DCMAKE_SYSROOT=$MOZ_FETCHES_DIR/sysroot \
50 -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld \
51 -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld \
52 -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
53 -DTAPI_REPOSITORY_STRING=$TAPI_REPOSITORY \
54 -DTAPI_FULL_VERSION=$TAPI_VERSION
56 ninja clangBasic -v
57 ninja libtapi install-libtapi install-tapi-headers -v
59 # Setup LDFLAGS late so run-at-build-time tools in the basic clang build don't
60 # pick up the possibly-incompatible libstdc++ from clang.
61 # Also set it up such that loading libtapi doesn't require a LD_LIBRARY_PATH.
62 # (this requires two dollars and extra backslashing because it's used verbatim
63 # via a Makefile)
64 export LDFLAGS="-fuse-ld=lld -lpthread -Wl,-rpath-link,$MOZ_FETCHES_DIR/sysroot/lib/x86_64-linux-gnu -Wl,-rpath-link,$MOZ_FETCHES_DIR/sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath,\\\$\$ORIGIN/../lib,-rpath,\\\$\$ORIGIN/../../clang/lib"
66 export CC="$CC --sysroot=$MOZ_FETCHES_DIR/sysroot"
67 export CXX="$CXX --sysroot=$MOZ_FETCHES_DIR/sysroot"
69 # Configure crosstools-port
70 cd $CROSSTOOLS_CCTOOLS_DIR
71 patch -p2 < $GECKO_PATH/taskcluster/scripts/misc/cctools.patch
73 # Force re-libtoolization to overwrite files with the new libtool bits.
74 perl -pi -e 's/(LIBTOOLIZE -c)/\1 -f/' autogen.sh
75 ./autogen.sh
76 ./configure \
77 --prefix=$CROSSTOOLS_BUILD_DIR \
78 --target=x86_64-apple-darwin \
79 --with-llvm-config=$CLANG_DIR/bin/llvm-config \
80 --enable-lto-support \
81 --enable-tapi-support \
82 --with-libtapi=$CROSSTOOLS_BUILD_DIR
84 # Build cctools
85 make -j `nproc --all` install
87 # Build ldid
88 cd $LDID_SOURCE_DIR
89 # The crypto library in the sysroot cannot be linked in a PIE executable so we use -no-pie
90 make -j `nproc --all` install INSTALLPREFIX=$CROSSTOOLS_BUILD_DIR LDFLAGS="-no-pie -Wl,-Bstatic -lcrypto -Wl,-Bdynamic -ldl -pthread"
92 strip $CROSSTOOLS_BUILD_DIR/bin/*
93 # various build scripts based on cmake want to find `lipo` without a prefix
94 cp $CROSSTOOLS_BUILD_DIR/bin/x86_64-apple-darwin-lipo $CROSSTOOLS_BUILD_DIR/bin/lipo
96 (cd $CROSSTOOLS_BUILD_DIR/bin/; for i in x86_64-apple-darwin-*; do
97 ln $i aarch64${i#x86_64}
98 done)
100 # Put a tarball in the artifacts dir
101 mkdir -p $UPLOAD_DIR
102 tar caf $UPLOAD_DIR/cctools.tar.zst -C $CROSSTOOLS_BUILD_DIR/.. `basename $CROSSTOOLS_BUILD_DIR`