Skip to content

Commit

Permalink
mk: Sync with *ring*.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Dec 5, 2023
1 parent f84a538 commit 280dc3a
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 6 deletions.
75 changes: 71 additions & 4 deletions mk/cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ IFS=$'\n\t'

rustflags_self_contained="-Clink-self-contained=yes -Clinker=rust-lld"
qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu"
qemu_arm="qemu-arm -L /usr/arm-linux-gnueabihf"
qemu_arm_gnueabi="qemu-arm -L /usr/arm-linux-gnueabi"
qemu_arm_gnueabihf="qemu-arm -L /usr/arm-linux-gnueabihf"
qemu_mipsel="qemu-mipsel -L /usr/mipsel-linux-gnu"
qemu_powerpc="qemu-ppc -L /usr/powerpc-linux-gnu"
qemu_powerpc64="qemu-ppc64 -L /usr/powerpc64-linux-gnu"
qemu_powerpc64le="qemu-ppc64le -L /usr/powerpc64le-linux-gnu"
qemu_riscv64="qemu-riscv64 -L /usr/riscv64-linux-gnu"
qemu_s390x="qemu-s390x -L /usr/s390x-linux-gnu"

# Avoid putting the Android tools in `$PATH` because there are tools in this
# directory like `clang` that would conflict with the same-named tools that may
Expand All @@ -45,7 +51,7 @@ for arg in $*; do
done

# See comments in install-build-tools.sh.
llvm_version=15
llvm_version=16

case $target in
aarch64-linux-android)
Expand All @@ -66,22 +72,35 @@ case $target in
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="$qemu_aarch64"
;;
arm-unknown-linux-gnueabi)
export CC_arm_unknown_linux_gnueabi=arm-linux-gnueabi-gcc
export AR_arm_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-ar
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_RUNNER="$qemu_arm_gnueabi"
;;
arm-unknown-linux-gnueabihf)
# XXX: clang cannot build the sha256 and x25519 assembly.
export CC_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc-ar
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm"
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm_gnueabihf"
;;
armv7-linux-androideabi)
export CC_armv7_linux_androideabi=$android_tools/armv7a-linux-androideabi19-clang
export AR_armv7_linux_androideabi=$android_tools/llvm-ar
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$android_tools/armv7a-linux-androideabi19-clang
;;
armv7-unknown-linux-gnueabihf)
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm_gnueabihf"
;;
armv7-unknown-linux-musleabihf)
export CC_armv7_unknown_linux_musleabihf=clang-$llvm_version
export AR_armv7_unknown_linux_musleabihf=llvm-ar-$llvm_version
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS="$rustflags_self_contained"
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="$qemu_arm"
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="$qemu_arm_gnueabihf"
;;
i686-unknown-linux-gnu)
export CC_i686_unknown_linux_gnu=clang-$llvm_version
Expand All @@ -99,6 +118,43 @@ case $target in
export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc
export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER="$qemu_mipsel"
;;
powerpc-unknown-linux-gnu)
export CC_powerpc_unknown_linux_gnu=clang-$llvm_version
export AR_powerpc_unknown_linux_gnu=llvm-ar-$llvm_version
export CFLAGS_powerpc_unknown_linux_gnu="--sysroot=/usr/powerpc-linux-gnu"
export CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc
export CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="$qemu_powerpc"
;;
powerpc64-unknown-linux-gnu)
export CC_powerpc64_unknown_linux_gnu=clang-$llvm_version
export AR_powerpc64_unknown_linux_gnu=llvm-ar-$llvm_version
export CFLAGS_powerpc64_unknown_linux_gnu="--sysroot=/usr/powerpc64-linux-gnu"
export CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc
export CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_powerpc64"
;;
powerpc64le-unknown-linux-gnu)
export CC_powerpc64le_unknown_linux_gnu=clang-$llvm_version
export AR_powerpc64le_unknown_linux_gnu=llvm-ar-$llvm_version
export CFLAGS_powerpc64le_unknown_linux_gnu="--sysroot=/usr/powerpc64le-linux-gnu"
export CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc
export CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="$qemu_powerpc64le"
;;
riscv64gc-unknown-linux-gnu)
export CC_riscv64gc_unknown_linux_gnu=clang-$llvm_version
export AR_riscv64gc_unknown_linux_gnu=llvm-ar-$llvm_version
export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc
export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="$qemu_riscv64"
;;
s390x-unknown-linux-gnu)
export CC_s390x_unknown_linux_gnu=clang-$llvm_version
export AR_s390x_unknown_linux_gnu=llvm-ar-$llvm_version
# XXX: Using -march=zEC12 to work around a z13 instruction bug in
# QEMU 8.0.2 and earlier that causes `test_constant_time` to fail
# (https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg06965.html).
export CFLAGS_s390x_unknown_linux_gnu="--sysroot=/usr/s390x-linux-gnu -march=zEC12"
export CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc
export CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="$qemu_s390x"
;;
x86_64-unknown-linux-musl)
export CC_x86_64_unknown_linux_musl=clang-$llvm_version
export AR_x86_64_unknown_linux_musl=llvm-ar-$llvm_version
Expand All @@ -109,13 +165,24 @@ case $target in
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained"
fi
;;
loongarch64-unknown-linux-gnu)
export CC_loongarch64_unknown_linux_gnu=clang-$llvm_version
export AR_loongarch64_unknown_linux_gnu=llvm-ar-$llvm_version
export CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version
;;
wasm32-unknown-unknown)
# The first two are only needed for when the "wasm_c" feature is enabled.
export CC_wasm32_unknown_unknown=clang-$llvm_version
export AR_wasm32_unknown_unknown=llvm-ar-$llvm_version
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
export WASM_BINDGEN_TEST_TIMEOUT=60
;;
wasm32-wasi)
# The first two are only needed for when the "wasm_c" feature is enabled.
export CC_wasm32_wasi=clang-$llvm_version
export AR_wasm32_wasi=llvm-ar-$llvm_version
export CARGO_TARGET_WASM32_WASI_RUNNER=target/tools/linux-x86_64/wasmtime/wasmtime
;;
*)
;;
esac
Expand Down
6 changes: 6 additions & 0 deletions mk/install-build-tools.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# TODO: Lock this down to a specific commit instead of always using the latest.
git clone `
--branch windows `
--depth 1 `
https://github.com/briansmith/ring-toolchain `
target/tools/windows
57 changes: 55 additions & 2 deletions mk/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ case $target in
install_packages \
qemu-user
;;
--target=arm-unknown-linux-gnueabihf)
--target=arm-unknown-linux-gnueabi)
install_packages \
qemu-user \
gcc-arm-linux-gnueabi \
libc6-dev-armel-cross
;;
--target=arm-unknown-linux-gnueabihf|--target=armv7-unknown-linux-gnueabihf)
install_packages \
qemu-user \
gcc-arm-linux-gnueabihf \
Expand All @@ -85,24 +91,71 @@ case $target in
--target=i686-unknown-linux-musl|--target=x86_64-unknown-linux-musl)
use_clang=1
;;
--target=loongarch64-unknown-linux-gnu)
use_clang=1
;;
--target=mipsel-unknown-linux-gnu)
install_packages \
gcc-mipsel-linux-gnu \
libc6-dev-mipsel-cross \
qemu-user
;;
--target=powerpc-unknown-linux-gnu)
use_clang=1
install_packages \
gcc-powerpc-linux-gnu \
libc6-dev-powerpc-cross \
qemu-user
;;
--target=powerpc64-unknown-linux-gnu)
use_clang=1
install_packages \
gcc-powerpc64-linux-gnu \
libc6-dev-ppc64-cross \
qemu-user
;;
--target=powerpc64le-unknown-linux-gnu)
use_clang=1
install_packages \
gcc-powerpc64le-linux-gnu \
libc6-dev-ppc64el-cross \
qemu-user
;;
--target=riscv64gc-unknown-linux-gnu)
use_clang=1
install_packages \
gcc-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
qemu-user
;;
--target=s390x-unknown-linux-gnu)
# Clang is needed for code coverage.
use_clang=1
install_packages \
qemu-user \
gcc-s390x-linux-gnu \
libc6-dev-s390x-cross
;;
--target=wasm32-unknown-unknown)
cargo install wasm-bindgen-cli --bin wasm-bindgen-test-runner
use_clang=1
;;
--target=wasm32-wasi)
use_clang=1
git clone \
--branch linux-x86_64 \
--depth 1 \
https://github.com/briansmith/ring-toolchain \
target/tools/linux-x86_64
;;
--target=*)
;;
esac

case "$OSTYPE" in
linux*)
ubuntu_codename=$(lsb_release --codename --short)
llvm_version=15
llvm_version=16
sudo apt-key add mk/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/$ubuntu_codename/ llvm-toolchain-$ubuntu_codename-$llvm_version main"
sudo apt-get update
Expand Down

0 comments on commit 280dc3a

Please sign in to comment.