github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/builder/mkrelease.sh (about) 1 #!/usr/bin/env bash 2 3 # This script builds a CockroachDB release binary, potentially cross compiling 4 # for a different platform. It must be run in the cockroachdb/builder docker 5 # image, as it depends on cross-compilation toolchains available there. Usage: 6 # 7 # mkrelease [CONFIGURATION] [MAKE-GOALS...] 8 # 9 # Possible configurations: 10 # 11 # - amd64-linux-gnu: amd64, Linux 2.6.32, dynamically link glibc 2.12.2 12 # - amd64-linux-msan: amd64, recent Linux, enable Clang's memory sanitizer 13 # - arm64-linux-gnueabi: arm64, Linux 3.7.10, dynamically link glibc 2.12.2 14 # - amd64-darwin: amd64, macOS 10.9 15 # - amd64-windows: amd64, Windows 8, statically link all non-Windows libraries 16 # 17 # When specifying configurations on the command line, the architecture prefix 18 # and/or the ABI suffix can be omitted, in which case a suitable default will 19 # be selected. If no release arguments are specified, the configuration 20 # amd64-linux-gnu is used (this is the default linux binary). 21 # 22 # In order to specify MAKE-GOALS, a configuration must be explicitly 23 # specified. 24 # 25 # Note to maintainers: these configurations must be kept in sync with the 26 # crosstool-ng toolchains installed in the Dockerfile. 27 28 set -euo pipefail 29 shopt -s extglob 30 31 cd "$(dirname "$(readlink -f "$0")")/../.." 32 source build/shlib.sh 33 34 case "${1-}" in 35 ""|?(amd64-)linux?(-gnu)) 36 args=( 37 XGOOS=linux 38 XGOARCH=amd64 39 XCMAKE_SYSTEM_NAME=Linux 40 TARGET_TRIPLE=x86_64-unknown-linux-gnu 41 # -lrt is needed as clock_gettime isn't part of glibc prior to 2.17. 42 # If we update to a newer glibc, the -lrt can be removed. 43 LDFLAGS="-static-libgcc -static-libstdc++ -lrt" 44 SUFFIX=-linux-2.6.32-gnu-amd64 45 ) ;; 46 47 ?(arm64-)linux?(-gnueabi)) 48 # Manually set the correct values for configure checks that libkrb5 won't be 49 # able to perform because we're cross-compiling. 50 export krb5_cv_attr_constructor_destructor=yes 51 export ac_cv_func_regcomp=yes 52 export ac_cv_printf_positional=yes 53 args=( 54 XGOOS=linux 55 XGOARCH=arm64 56 XCMAKE_SYSTEM_NAME=Linux 57 TARGET_TRIPLE=aarch64-unknown-linux-gnueabi 58 LDFLAGS="-static-libgcc -static-libstdc++" 59 SUFFIX=-linux-3.7.10-gnu-aarch64 60 ) ;; 61 62 ?(amd64-)linux-msan) 63 flags="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -I/libcxx_msan/include -I/libcxx_msan/include/c++/v1" 64 args=( 65 CFLAGS="$flags" 66 CXXFLAGS="$flags" 67 LDFLAGS="-fsanitize=memory -stdlib=libc++ -L/libcxx_msan/lib -lc++abi -Wl,-rpath,/libcxx_msan/lib" 68 GOFLAGS=-msan 69 TAGS=stdmalloc 70 ) ;; 71 72 ?(amd64-)darwin) 73 args=( 74 XGOOS=darwin 75 XGOARCH=amd64 76 XCMAKE_SYSTEM_NAME=Darwin 77 TARGET_TRIPLE=x86_64-apple-darwin14 78 EXTRA_XCMAKE_FLAGS=-DCMAKE_INSTALL_NAME_TOOL=x86_64-apple-darwin14-install_name_tool 79 SUFFIX=-darwin-10.10-amd64 80 ) ;; 81 82 ?(amd64-)windows) 83 args=( 84 XGOOS=windows 85 XGOARCH=amd64 86 XCMAKE_SYSTEM_NAME=Windows 87 TARGET_TRIPLE=x86_64-w64-mingw32 88 LDFLAGS=-static 89 SUFFIX=-windows-6.2-amd64 90 ) ;; 91 92 *) die "unknown release configuration: $1" ;; 93 esac 94 95 if [ $# -ge 1 ]; then 96 shift 97 fi 98 99 (set -x && CGO_ENABLED=1 make BUILDTYPE=release "${args[@]}" "$@")