Skip to content

Commit

Permalink
update cross compile tool (mozilla#4898)
Browse files Browse the repository at this point in the history
update cross compile tool for M1 macs
  • Loading branch information
skhamis authored and bendk committed Oct 17, 2022
1 parent 9398314 commit 59bc16e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
10 changes: 5 additions & 5 deletions libs/build-nss-desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ if [[ -n "${CROSS_COMPILE_TARGET}" ]] && [[ "$(uname -s)" != "Linux" ]]; then
exit 1
fi

if [[ "${CROSS_COMPILE_TARGET}" =~ "win32-x86-64" ]]; then
if [[ "${CROSS_COMPILE_TARGET}" == "win32-x86-64" ]]; then
DIST_DIR=$(abspath "desktop/win32-x86-64/nss")
TARGET_OS="windows"
elif [[ "${CROSS_COMPILE_TARGET}" =~ "darwin" ]]; then
elif [[ "${CROSS_COMPILE_TARGET}" == "darwin" ]]; then
DIST_DIR=$(abspath "desktop/darwin/nss")
TARGET_OS="macos"
elif [[ "${CROSS_COMPILE_TARGET}" =~ "darwin-aarch64" ]]; then
elif [[ "${CROSS_COMPILE_TARGET}" == "darwin-aarch64" ]]; then
DIST_DIR=$(abspath "desktop/darwin-aarch64/nss")
TARGET_ARCH="aarch64"
TARGET_OS="macos"
Expand Down Expand Up @@ -63,14 +63,14 @@ fi

# TODO We do not know how to cross compile these, so we cheat by downloading them and the how is pretty disgusting.
# https://github.com/mozilla/application-services/issues/962
if [[ "${CROSS_COMPILE_TARGET}" =~ "darwin" ]]; then
if [[ "${CROSS_COMPILE_TARGET}" == "darwin" ]]; then
# Generated from nss-try@111b54aaa644978464bec98848ecba6f69d3f42e.
curl -sfSL --retry 5 --retry-delay 10 -O "https://fxa-dev-bucket.s3-us-west-2.amazonaws.com/a-s/nss_nspr_static_3.66_darwin.tar.bz2"
SHA256="2ad7c85b7b009120c7e883ccd367bbd3653857a4ed3adb4c5471b197d1844141"
echo "${SHA256} nss_nspr_static_3.66_darwin.tar.bz2" | shasum -a 256 -c - || exit 2
tar xvjf nss_nspr_static_3.66_darwin.tar.bz2 && rm -rf nss_nspr_static_3.66_darwin.tar.bz2
NSS_DIST_DIR=$(abspath "dist")
elif [[ "${CROSS_COMPILE_TARGET}" =~ "win32-x86-64" ]]; then
elif [[ "${CROSS_COMPILE_TARGET}" == "win32-x86-64" ]]; then
# Generated from nss-try@111b54aaa644978464bec98848ecba6f69d3f42e.
curl -sfSL --retry 5 --retry-delay 10 -O "https://fxa-dev-bucket.s3-us-west-2.amazonaws.com/a-s/nss_nspr_static_3.66_mingw.7z"
SHA256="d245ea7790602ef062ad6e6bac38f2d0452d753bf428c33ced46f022398a53ff"
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets = [
"armv7-linux-androideabi",
"i686-linux-android",
"x86_64-linux-android",
"aarch64-apple-darwin",
"aarch64-apple-ios",
"x86_64-apple-ios",
"aarch64-apple-ios-sim"
Expand Down
3 changes: 2 additions & 1 deletion taskcluster/ci/module-build/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ job-defaults:
- [rsync, '-a', /builds/worker/fetches/libs/, /builds/worker/checkouts/vcs/libs/]
# Once https://github.com/mozilla/application-services/issues/3917 is resolved,
# add `win32-x86-64-gnu` back in to the list of targets here.
- [bash, '-c', 'echo "rust.targets=arm,arm64,x86_64,x86,darwin,linux-x86-64\n" > local.properties']
- [bash, '-c', 'echo "rust.targets=arm,arm64,x86_64,x86,darwin-x86-64,darwin-aarch64,linux-x86-64\n" > local.properties']
gradlew:
- ':{module_name}:assembleRelease'
- ':{module_name}:publish'
Expand All @@ -62,5 +62,6 @@ job-defaults:
- android-libs
- desktop-linux-libs
- desktop-macos-libs
- desktop-macos-aarch64-libs
- desktop-win32-x86-64-libs
- rust
13 changes: 13 additions & 0 deletions taskcluster/scripts/toolchain/cross-compile-setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
export PATH=$PATH:/tmp/clang/bin

# x86_64 Darwin
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_NSS_STATIC=1
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_NSS_DIR=/builds/worker/checkouts/vcs/libs/desktop/darwin/nss
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_SQLCIPHER_LIB_DIR=/builds/worker/checkouts/vcs/libs/desktop/darwin/sqlcipher/lib
Expand All @@ -11,6 +13,17 @@ export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_LD_LIBR
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS="-C linker=/tmp/clang/bin/clang -C link-arg=-B -C link-arg=/tmp/cctools/bin -C link-arg=-target -C link-arg=x86_64-darwin11 -C link-arg=-isysroot -C link-arg=/tmp/MacOSX10.11.sdk -C link-arg=-Wl,-syslibroot,/tmp/MacOSX10.11.sdk -C link-arg=-Wl,-dead_strip"
# For ring's use of `cc`.
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_APPLE_DARWIN_CFLAGS_x86_64_apple_darwin="-B /tmp/cctools/bin -target x86_64-darwin11 -isysroot /tmp/MacOSX10.11.sdk -Wl,-syslibroot,/tmp/MacOSX10.11.sdk -Wl,-dead_strip"

# aarch64 Darwin (M1/Silicon)
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_CC=/builds/worker/clang/bin/clang
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_TOOLCHAIN_PREFIX=/builds/worker/cctools/bin
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_AR=/builds/worker/cctools/bin/aarch64-apple-darwin-ar
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_RANLIB=/builds/worker/cctools/bin/aarch64-apple-darwin-ranlib
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_LD_LIBRARY_PATH=/builds/worker/clang/lib
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS="-C linker=/builds/worker/clang/bin/clang -C link-arg=-B -C link-arg=/builds/worker/cctools/bin -C link-arg=-target -C link-arg=aarch64-apple-darwin -C link-arg=-isysroot -C link-arg=/tmp/MacOSX11.0.sdk -C link-arg=-Wl,-syslibroot,/tmp/MacOSX11.0.sdk -C link-arg=-Wl,-dead_strip"
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_AARCH64_APPLE_DARWIN_CFLAGS_aarch64_apple_darwin="-B /builds/worker/cctools/bin -target aarch64-apple-darwin -isysroot /tmp/MacOSX11.0.sdk -Wl,-syslibroot,/tmp/MacOSX11.0.sdk -Wl,-dead_strip"

# x86_64 Windows
# The wrong linker gets used otherwise: https://github.com/rust-lang/rust/issues/33465.
export ORG_GRADLE_PROJECT_RUST_ANDROID_GRADLE_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C linker=x86_64-w64-mingw32-gcc"

Expand Down

0 comments on commit 59bc16e

Please sign in to comment.