diff options
-rw-r--r-- | automation/taskcluster/graph/src/extend.js | 14 | ||||
-rwxr-xr-x | build.sh | 101 | ||||
-rw-r--r-- | coreconf/fuzz.sh | 7 | ||||
-rw-r--r-- | coreconf/msvc.sh | 98 | ||||
-rw-r--r-- | coreconf/nspr.sh | 3 | ||||
-rw-r--r-- | help.txt | 56 |
6 files changed, 86 insertions, 193 deletions
diff --git a/automation/taskcluster/graph/src/extend.js b/automation/taskcluster/graph/src/extend.js index d117daa3d..4b74f593f 100644 --- a/automation/taskcluster/graph/src/extend.js +++ b/automation/taskcluster/graph/src/extend.js @@ -152,13 +152,13 @@ export default async function main() { await scheduleLinux("Linux 32 (opt)", { platform: "linux32", image: LINUX_IMAGE - }, "-t ia32 --opt"); + }, "-m32 --opt"); await scheduleLinux("Linux 32 (debug)", { platform: "linux32", collection: "debug", image: LINUX_IMAGE - }, "-t ia32"); + }, "-m32"); await scheduleLinux("Linux 64 (opt)", { platform: "linux64", @@ -248,12 +248,12 @@ export default async function main() { await scheduleWindows("Windows 2012 32 (opt)", { platform: "windows2012-32", - }, "build_gyp.sh --opt -t ia32"); + }, "build_gyp.sh --opt -m32"); await scheduleWindows("Windows 2012 32 (debug)", { platform: "windows2012-32", collection: "debug" - }, "build_gyp.sh -t ia32"); + }, "build_gyp.sh -m32"); await scheduleFuzzing(); await scheduleFuzzing32(); @@ -679,7 +679,7 @@ async function scheduleFuzzing32() { "/bin/bash", "-c", "bin/checkout.sh && " + - "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz -t ia32" + "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz -m32" ], artifacts: { public: { @@ -706,7 +706,7 @@ async function scheduleFuzzing32() { "/bin/bash", "-c", "bin/checkout.sh && " + - "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz=tls -t ia32" + "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz=tls -m32" ], })); @@ -1102,7 +1102,7 @@ async function scheduleTools() { command: [ "/bin/bash", "-c", - "bin/checkout.sh && nss/automation/taskcluster/scripts/build_gyp.sh --disable-tests --emit-llvm -t ia32" + "bin/checkout.sh && nss/automation/taskcluster/scripts/build_gyp.sh --disable-tests --emit-llvm -m32" ] })); @@ -50,85 +50,75 @@ fuzz=0 fuzz_tls=0 fuzz_oss=0 no_local_nspr=0 +armhf=0 gyp_params=(--depth="$cwd" --generator-output=".") +nspr_params=() ninja_params=() -# Assume that the target architecture is the same as the host by default. -host_arch=$(python "$cwd"/coreconf/detect_host_arch.py) -target_arch=$host_arch - -# Assume that MSVC is wanted if this is running on windows. -platform=$(uname -s) -if [ "${platform%-*}" = "MINGW32_NT" -o "${platform%-*}" = "MINGW64_NT" ]; then - msvc=1 +# try to guess sensible defaults +arch=$(python "$cwd"/coreconf/detect_host_arch.py) +if [ "$arch" = "x64" -o "$arch" = "aarch64" ]; then + build_64=1 +elif [ "$arch" = "arm" ]; then + armhf=1 fi -# Parse command line arguments. +# parse command line arguments while [ $# -gt 0 ]; do - case "$1" in + case $1 in -c) clean=1 ;; -cc) clean_only=1 ;; - -v) ninja_params+=(-v); verbose=1 ;; - -j) ninja_params+=(-j "$2"); shift ;; --gyp|-g) rebuild_gyp=1 ;; - --opt|-o) opt_build=1 ;; - -m32|--m32) target_arch=ia32; echo 'Warning: use -t instead of -m32' 1>&2 ;; - -t|--target) target_arch="$2"; shift ;; - --target=*) target_arch="${1#*=}" ;; - --clang) export CC=clang; export CCC=clang++; export CXX=clang++; msvc=0 ;; - --gcc) export CC=gcc; export CCC=g++; export CXX=g++; msvc=0 ;; - --msvc) msvc=1 ;; + --nspr) nspr_clean; rebuild_nspr=1 ;; + -j) ninja_params+=(-j "$2"); shift ;; + -v) ninja_params+=(-v); verbose=1 ;; + --test) gyp_params+=(-Dtest_build=1) ;; + --clang) export CC=clang; export CCC=clang++; export CXX=clang++ ;; + --gcc) export CC=gcc; export CCC=g++; export CXX=g++ ;; + --fuzz) fuzz=1 ;; + --fuzz=oss) fuzz=1; fuzz_oss=1 ;; + --fuzz=tls) fuzz=1; fuzz_tls=1 ;; --scan-build) enable_scanbuild ;; --scan-build=?*) enable_scanbuild "${1#*=}" ;; - --disable-tests) gyp_params+=(-Ddisable_tests=1) ;; - --pprof) gyp_params+=(-Duse_pprof=1) ;; + --opt|-o) opt_build=1 ;; + -m32|--m32) build_64=0 ;; --asan) enable_sanitizer asan ;; --msan) enable_sanitizer msan ;; --ubsan) enable_ubsan ;; --ubsan=?*) enable_ubsan "${1#*=}" ;; - --fuzz) fuzz=1 ;; - --fuzz=oss) fuzz=1; fuzz_oss=1 ;; - --fuzz=tls) fuzz=1; fuzz_tls=1 ;; --sancov) enable_sancov ;; --sancov=?*) enable_sancov "${1#*=}" ;; + --pprof) gyp_params+=(-Duse_pprof=1) ;; + --ct-verif) gyp_params+=(-Dct_verif=1) ;; --emit-llvm) gyp_params+=(-Demit_llvm=1 -Dsign_libs=0) ;; + --disable-tests) gyp_params+=(-Ddisable_tests=1) ;; --no-zdefs) gyp_params+=(-Dno_zdefs=1) ;; - --test) gyp_params+=(-Dtest_build=1) ;; - --ct-verif) gyp_params+=(-Dct_verif=1) ;; - --nspr) nspr_clean; rebuild_nspr=1 ;; + --system-sqlite) gyp_params+=(-Duse_system_sqlite=1) ;; --with-nspr=?*) set_nspr_path "${1#*=}"; no_local_nspr=1 ;; --system-nspr) set_nspr_path "/usr/include/nspr/:"; no_local_nspr=1 ;; - --system-sqlite) gyp_params+=(-Duse_system_sqlite=1) ;; - --enable-fips) gyp_params+=(-Ddisable_fips=0) ;; --enable-libpkix) gyp_params+=(-Ddisable_libpkix=0) ;; + --enable-fips) gyp_params+=(-Ddisable_fips=0) ;; *) show_help; exit 2 ;; esac shift done -# Set the target architecture and build type. -gyp_params+=(-Dtarget_arch="$target_arch") if [ "$opt_build" = 1 ]; then target=Release else target=Debug fi - -# Do special setup. +if [ "$build_64" = 1 ]; then + nspr_params+=(--enable-64bit) +elif [ ! "$armhf" = 1 ]; then + gyp_params+=(-Dtarget_arch=ia32) +fi if [ "$fuzz" = 1 ]; then source "$cwd"/coreconf/fuzz.sh fi -nspr_set_flags $sanitizer_flags -if [ ! -z "$sanitizer_flags" ]; then - gyp_params+=(-Dsanitizer_flags="$sanitizer_flags") -fi -if [ "$msvc" = 1 ]; then - source "$cwd"/coreconf/msvc.sh -fi - -# Setup build paths. +# set paths target_dir="$cwd"/out/$target mkdir -p "$target_dir" dist_dir="$cwd"/../dist @@ -159,7 +149,6 @@ check_config() echo CC="$CC" >"$newconf" echo CCC="$CCC" >>"$newconf" echo CXX="$CXX" >>"$newconf" - echo target_arch="$target_arch" >>"$newconf" for i in "$@"; do echo $i; done | sort >>"$newconf" # Note: The following diff fails if $oldconf isn't there as well, which @@ -170,7 +159,6 @@ check_config() gyp_config="$cwd"/out/gyp_config nspr_config="$cwd"/out/$target/nspr_config -# Now check what needs to be rebuilt. # If we don't have a build directory make sure that we rebuild. if [ ! -d "$target_dir" ]; then rebuild_nspr=1 @@ -179,28 +167,33 @@ elif [ ! -d "$dist_dir"/$target ]; then rebuild_nspr=1 fi -if check_config "$nspr_config" \ +# Update NSPR ${C,CXX,LD}FLAGS. +nspr_set_flags $sanitizer_flags + +if check_config "$nspr_config" "${nspr_params[@]}" \ nspr_cflags="$nspr_cflags" \ nspr_cxxflags="$nspr_cxxflags" \ nspr_ldflags="$nspr_ldflags"; then rebuild_nspr=1 fi +# Forward sanitizer flags. +if [ ! -z "$sanitizer_flags" ]; then + gyp_params+=(-Dsanitizer_flags="$sanitizer_flags") +fi + if check_config "$gyp_config" "${gyp_params[@]}"; then rebuild_gyp=1 fi -# Save the chosen target. +# save the chosen target mkdir -p "$dist_dir" echo $target > "$dist_dir"/latest -# Build. -# NSPR. if [[ "$rebuild_nspr" = 1 && "$no_local_nspr" = 0 ]]; then - nspr_build + nspr_build "${nspr_params[@]}" mv -f "$nspr_config".new "$nspr_config" fi -# gyp. if [ "$rebuild_gyp" = 1 ]; then if ! hash ${GYP} 2> /dev/null; then echo "Please install gyp" 1>&2 @@ -218,11 +211,11 @@ if [ "$rebuild_gyp" = 1 ]; then mv -f "$gyp_config".new "$gyp_config" fi -# ninja. -if hash ninja-build 2>/dev/null; then - ninja=ninja-build -elif hash ninja 2>/dev/null; then +# Run ninja. +if hash ninja 2>/dev/null; then ninja=ninja +elif hash ninja-build 2>/dev/null; then + ninja=ninja-build else echo "Please install ninja" 1>&2 exit 1 diff --git a/coreconf/fuzz.sh b/coreconf/fuzz.sh index c7b8844b6..67cb7f594 100644 --- a/coreconf/fuzz.sh +++ b/coreconf/fuzz.sh @@ -5,7 +5,8 @@ set +e # Default to clang if CC is not set. if [ -z "$CC" ]; then - if ! command -v clang &> /dev/null 2>&1; then + command -v clang &> /dev/null 2>&1 + if [ $? != 0 ]; then echo "Fuzzing requires clang!" exit 1 fi @@ -23,8 +24,8 @@ if [ "$fuzz_oss" = 1 ]; then gyp_params+=(-Dno_zdefs=1 -Dfuzz_oss=1) else enable_sanitizer asan - # Ubsan only builds on x64 for the moment. - if [ "$target_arch" = "x64" ]; then + # Ubsan doesn't build on 32-bit at the moment. Disable it. + if [ "$build_64" = 1 ]; then enable_ubsan fi enable_sancov diff --git a/coreconf/msvc.sh b/coreconf/msvc.sh deleted file mode 100644 index 0eac4bcc4..000000000 --- a/coreconf/msvc.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# This configures the environment for running MSVC. It uses vswhere, the -# registry, and a little knowledge of how MSVC is laid out. - -if ! hash vswhere 2>/dev/null; then - echo "Can't find vswhere on the path, aborting" 1>&2 - exit 1 -fi - -if ! hash reg 2>/dev/null; then - echo "Can't find reg on the path, aborting" 1>&2 - exit 1 -fi - -# Turn a unix-y path into a windows one. -fixpath() { - if hash cygpath 2>/dev/null; then - cygpath --unix "$1" - else # haxx - echo "$1" | sed -e 's,\\,/,g;s,^\(.\):,/\L\1,;s,/$,,' - fi -} - -# Query the registry. This takes $1 and tags that on the end of several -# different paths, looking for a value called $2 at that location. -# e.g., -# regquery Microsoft\Microsoft SDKs\Windows\v10.0 ProductVersion -# looks for a REG_SZ value called ProductVersion at -# HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 -# HKLU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 -# etc... -regquery() { - search=("HKLM\\SOFTWARE\\Wow6432Node" \ - "HKCU\\SOFTWARE\\Wow6432Node" \ - "HKLM\\SOFTWARE" \ - "HKCU\\SOFTWARE") - for i in "${search[@]}"; do - r=$(reg query "${i}\\${1}" -v "$2" | sed -e 's/ *'"$2"' *REG_SZ *//;t;d') - if [ -n "$r" ]; then - echo "$r" - return 0 - fi - done - return 1 -} - -case "$target_arch" in - ia32) m=x86 ;; - x64) m="$target_arch" ;; - *) - echo "No support for target architecture '$target_arch' with MSVC." 1>&2 - exit 1 -esac - -VSCOMPONENT=Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -VSPATH=$(vswhere -latest -requires "$VSCOMPONENT" -property installationPath) -export VSPATH=$(fixpath "$VSPATH") -export WINDOWSSDKDIR="${VSPATH}/SDK" -export VCINSTALLDIR="${VSPATH}/VC" - -CRTREG="Microsoft\\Microsoft SDKs\\Windows\\v10.0" -UniversalCRTSdkDir=$(regquery "$CRTREG" InstallationFolder) -UniversalCRTSdkDir=$(fixpath "$UniversalCRTSdkDir") -UCRTVersion=$(regquery "$CRTREG" ProductVersion) -UCRTVersion=$(cd "${UniversalCRTSdkDir}/include"; ls -d "${UCRTVersion}"* | tail -1) - -VCVER=$(cat "${VCINSTALLDIR}/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt") -REDISTVER=$(cat "${VCINSTALLDIR}/Auxiliary/Build/Microsoft.VCRedistVersion.default.txt") -export WIN32_REDIST_DIR="${VCINSTALLDIR}/Redist/MSVC/${REDISTVER}/${m}/Microsoft.VC141.CRT" -export WIN_UCRT_REDIST_DIR="${UniversalCRTSdkDir}/Redist/ucrt/DLLs/${m}" - -if [ "$m" == "x86" ]; then - PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/HostX64/x86" - PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/Hostx86/x86" -fi -PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/HostX64/x64" -PATH="${PATH}:${UniversalCRTSdkDir}/bin/${UCRTVersion}/x64" -PATH="${PATH}:${UniversalCRTSdkDir}/bin/${UCRTVersion}/x86" -PATH="${PATH}:${WIN32_REDIST_DIR}" -export PATH - -INCLUDE="${VCINSTALLDIR}/Tools/MSVC/${VCVER}/ATLMFC/include" -INCLUDE="${INCLUDE}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/include" -INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/ucrt" -INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/shared" -INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/um" -INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/winrt" -INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/cppwinrt" -export INCLUDE - -LIB="${VCINSTALLDIR}/lib/${m}" -LIB="${VCINSTALLDIR}/Tools/MSVC/${VCVER}/lib/${m}" -LIB="${LIB}:${UniversalCRTSdkDir}/lib/${UCRTVersion}/ucrt/${m}" -LIB="${LIB}:${UniversalCRTSdkDir}/lib/${UCRTVersion}/um/${m}" -export LIB - -export GYP_MSVS_OVERRIDE_PATH="${VSPATH}" -export GYP_MSVS_VERSION=$(vswhere -latest -requires "$VSCOMPONENT" -property catalog_productLineVersion) diff --git a/coreconf/nspr.sh b/coreconf/nspr.sh index 325a188c3..d11cd48ed 100644 --- a/coreconf/nspr.sh +++ b/coreconf/nspr.sh @@ -32,9 +32,6 @@ nspr_build() if [ "$opt_build" = 1 ]; then extra_params+=(--disable-debug --enable-optimize) fi - if [ "$target_arch" = "x64" ]; then - extra_params+=(--enable-64bit) - fi echo "NSPR [1/3] configure ..." pushd "$nspr_dir" >/dev/null @@ -1,14 +1,15 @@ -Usage: build.sh [-h] [-c|-cc] [-v] [-j <n>] [--gyp|-g] [--opt|-o] - [-t <x64|x86|...>|--target=<x64|x86|...>] - [--clang|--gcc|--msvc] [--scan-build[=dir]] [--disable-tests] - [--pprof] [--asan] [--msan] [--ubsan[=bool,shift,...] - [--fuzz[=tls|oss]] [--sancov[=edge|bb|func|...]] - [--emit-llvm] [--no-zdefs] [--test] [--ct-verif] - [--nspr|--with-nspr=<include>:<lib>|--system-nspr] - [--system-sqlite] [--enable-fips] [--enable-libpkix] +Usage: build.sh [-hcv] [-cc] [-j <n>] [--nspr] [--gyp|-g] [--opt|-o] [-m32] + [--test] [--pprof] [--scan-build[=output]] [--ct-verif] + [--asan] [--ubsan] [--msan] [--sancov[=edge|bb|func|...]] + [--disable-tests] [--fuzz[=tls|oss]] [--system-sqlite] + [--no-zdefs] [--with-nspr] [--system-nspr] [--enable-libpkix] + [--enable-fips] This script builds NSS with gyp and ninja. +This build system is still under development. It does not yet support all +the features or platforms that NSS supports. + NSS build tool options: -h display this help and exit @@ -16,35 +17,34 @@ NSS build tool options: -cc clean without building -v verbose build -j <n> run at most <n> concurrent jobs + --nspr force a rebuild of NSPR --gyp|-g force a rerun of gyp --opt|-o do an opt build - --target|-t specify target architecture (e.g., x86, x64, aarch64) + -m32 do a 32-bit build on a 64-bit system --clang build with clang and clang++ --gcc build with gcc and g++ - --msvc build with MSVC - --scan-build run the build with scan-build - --scan-build=<dir> sets the output path for scan-build - --disable-tests don't build tests and corresponding cmdline utils - --pprof build with gperftool support - --asan enable address sanitizer - --msan enable memory sanitizer - --ubsan enable undefined behavior sanitizer - --ubsan=bool,shift,... sets specific UB sanitizers + --test ignore map files and export everything we have --fuzz build fuzzing targets (this always enables test builds) --fuzz=tls to enable TLS fuzzing mode --fuzz=oss to build for OSS-Fuzz + --pprof build with gperftool support + --ct-verif build with valgrind for ct-verif + --scan-build run the build with scan-build (scan-build has to be in the path) + --scan-build=/out/path sets the output path for scan-build + --asan do an asan build + --ubsan do an ubsan build + --ubsan=bool,shift,... sets specific UB sanitizers + --msan do an msan build --sancov do sanitize coverage builds --sancov=func sets coverage to function level for example --emit-llvm emit LLVM bitcode while building (requires the gold linker, use clang-3.8 for SAW) - --no-zdefs don't set -Wl,-z,defs - --test ignore map files and export everything we have - --ct-verif build with valgrind for ct-verif - --nspr force a rebuild of NSPR - --with-nspr use the NSPR build at the given locations - --with-nspr=<include>:<lib> sets include and lib paths - --system-nspr attempt to use system nspr - shorthand for --with-nspr=/usr/include/nspr: + --disable-tests don't build tests and corresponding cmdline utils --system-sqlite use system sqlite - --enable-fips enable FIPS checks - --enable-libpkix make libpkix part of the build + --no-zdefs don't set -Wl,-z,defs + --with-nspr don't build NSPR but use the one at the given location, e.g. + --with-nspr=/path/to/nspr/include:/path/to/nspr/lib + --system-nspr use system nspr. This requires an installation of NSPR and + might not work on all systems. + --enable-libpkix make libpkix part of the build. + --enable-fips don't disable FIPS checks. |