Skip to content

Commit 5d36ef8

Browse files
committed
debugging ci
1 parent ab47e79 commit 5d36ef8

5 files changed

Lines changed: 96 additions & 10 deletions

File tree

libs/build-nss-desktop.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ elif [[ "$(uname -s)" == "Darwin" ]] || [[ "$(uname -s)" == "Linux" ]]; then
7878
-Dsign_libs=0 \
7979
-Ddisable_libpkix=1
8080
NSS_DIST_DIR="${NSS_SRC_DIR}/dist"
81+
82+
# Debug output for CI
83+
if [[ -f "${NSS_SRC_DIR}/nss/out/Release/build.ninja" ]]; then
84+
echo "=== Dumping build.ninja for nss-desktop ==="
85+
cat "${NSS_SRC_DIR}/nss/out/Release/build.ninja"
86+
fi
8187
fi
8288

8389
# Assemble the DIST_DIR with relevant libraries and headers

libs/build-nss-ios.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ gyp -f ninja "${NSS_SRC_DIR}/nss/nss.gyp" \
9393
-Dpython=python3
9494

9595
GENERATED_DIR="${NSS_SRC_DIR}/nss/out/Release-$(echo ${OS_COMPILER} | tr '[:upper:]' '[:lower:]')/"
96+
echo "=== Dumping build.ninja for nss-ios ==="
97+
cat "${GENERATED_DIR}/build.ninja"
9698
ninja -C "${GENERATED_DIR}"
9799

98100
# Assemble the DIST_DIR with relevant libraries and headers

libs/build-nss-macos-cross.sh

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,85 @@ if [[ -z "${!nss_dir_var}" ]]; then
4747
fi
4848

4949
# Use toolchain configuration from environment
50-
eval "CC=\$${RUST_ANDROID_PREFIX}_CC"
50+
eval "BASE_CC=\$${RUST_ANDROID_PREFIX}_CC"
5151
eval "AR=\$${RUST_ANDROID_PREFIX}_AR"
52+
eval "AS=\$${RUST_ANDROID_PREFIX}_AS"
5253
eval "RANLIB=\$${RUST_ANDROID_PREFIX}_RANLIB"
54+
eval "LD=\$${RUST_ANDROID_PREFIX}_LD"
5355
eval "STRIP=\$${RUST_ANDROID_PREFIX}_TOOLCHAIN_PREFIX/${NSS_TARGET}-strip"
56+
eval "TOOLCHAIN_BIN=\$${RUST_ANDROID_PREFIX}_TOOLCHAIN_PREFIX"
5457
eval "CFLAGS=\$${RUST_ANDROID_PREFIX}_CFLAGS_${NSS_TARGET//-/_}"
55-
eval "LDFLAGS=\$${RUST_ANDROID_PREFIX}_LDFLAGS_${NSS_TARGET//-/_}"
58+
59+
# Create a wrapper directory for fake tools and compiler wrappers
60+
WRAPPER_DIR=$(mktemp -d)
61+
62+
# Create compiler wrapper scripts that filter out incompatible Apple-specific flags
63+
# and add C++ standard library include paths for cross-compilation
64+
cat > "${WRAPPER_DIR}/cc-wrapper" << 'EOF'
65+
#!/usr/bin/env bash
66+
# Filter out -fasm-blocks and -mpascal-strings which clang-20 doesn't support for cross-compilation
67+
args=()
68+
for arg in "$@"; do
69+
if [[ "$arg" != "-fasm-blocks" && "$arg" != "-mpascal-strings" ]]; then
70+
args+=("$arg")
71+
fi
72+
done
73+
# Add clang's C++ standard library include path
74+
args+=("-I/builds/worker/clang/include/c++/v1")
75+
exec "${REAL_CC}" "${args[@]}"
76+
EOF
77+
chmod +x "${WRAPPER_DIR}/cc-wrapper"
78+
79+
# Set CC and CXX to use the wrapper with all flags baked in
80+
export REAL_CC="${BASE_CC} ${CFLAGS}"
81+
CC="${WRAPPER_DIR}/cc-wrapper"
82+
CXX="${WRAPPER_DIR}/cc-wrapper"
83+
export CC CXX
84+
85+
# Create a fake xcodebuild script and tool wrappers to allow gyp to use the mac flavor
86+
# This tricks gyp into thinking Xcode is installed so it generates macOS-style build rules
87+
cat > "${WRAPPER_DIR}/xcodebuild" << 'EOF'
88+
#!/usr/bin/env bash
89+
# Fake xcodebuild that returns a version for gyp's mac flavor
90+
# Xcode 12.2 corresponds to macOS SDK 11.0 (Big Sur) and adds Apple Silicon support
91+
echo "Xcode 12.2"
92+
echo "Build version 12B45b"
93+
EOF
94+
chmod +x "${WRAPPER_DIR}/xcodebuild"
95+
96+
# Create unprefixed symlinks to cctools binaries that gyp's mac flavor expects
97+
# The mac flavor expects tools like 'otool', 'libtool', 'lipo' without the target prefix
98+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-otool" "${WRAPPER_DIR}/otool"
99+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-libtool" "${WRAPPER_DIR}/libtool"
100+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-lipo" "${WRAPPER_DIR}/lipo"
101+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-nm" "${WRAPPER_DIR}/nm"
102+
103+
export PATH="${WRAPPER_DIR}:${PATH}"
104+
105+
# Work around Python 3 bug in Ubuntu 22.04 gyp package
106+
# Create a wrapper that monkey-patches GetStdoutQuiet to fix bytes/str handling
107+
GYP_WRAPPER=$(mktemp)
108+
cat > "${GYP_WRAPPER}" << 'EOFGYP'
109+
#!/usr/bin/env python3
110+
import sys
111+
import gyp.xcode_emulation
112+
113+
# Monkey-patch GetStdoutQuiet to fix Python 3 bytes/str bug
114+
original_GetStdoutQuiet = gyp.xcode_emulation.GetStdoutQuiet
115+
def patched_GetStdoutQuiet(cmdlist):
116+
import subprocess
117+
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
118+
out = job.communicate()[0]
119+
if job.returncode != 0:
120+
return None
121+
return out.rstrip(b'\n').decode('utf-8')
122+
gyp.xcode_emulation.GetStdoutQuiet = patched_GetStdoutQuiet
123+
124+
# Now run gyp normally
125+
import gyp
126+
sys.exit(gyp.script_main())
127+
EOFGYP
128+
chmod +x "${GYP_WRAPPER}"
56129

57130
# Build NSPR
58131
NSPR_BUILD_DIR=$(mktemp -d)
@@ -61,12 +134,10 @@ pushd "${NSPR_BUILD_DIR}"
61134
STRIP="${STRIP}" \
62135
RANLIB="${RANLIB}" \
63136
AR="${AR}" \
64-
AS="${AS:-${AR}}" \
65-
LD="${LD:-${AR}}" \
137+
AS="${AS}" \
138+
LD="${LD}" \
66139
CC="${CC}" \
67140
CCC="${CC}" \
68-
CFLAGS="${CFLAGS}" \
69-
LDFLAGS="${LDFLAGS}" \
70141
--target="${NSS_TARGET}" \
71142
--enable-64bit \
72143
--disable-debug \
@@ -78,7 +149,7 @@ popd
78149
NSS_BUILD_DIR=$(mktemp -d)
79150
rm -rf "${NSS_SRC_DIR}/nss/out"
80151

81-
gyp -f ninja "${NSS_SRC_DIR}/nss/nss.gyp" \
152+
"${GYP_WRAPPER}" -f ninja-mac "${NSS_SRC_DIR}/nss/nss.gyp" \
82153
--depth "${NSS_SRC_DIR}/nss/" \
83154
--generator-output=. \
84155
-DOS=mac \
@@ -97,6 +168,11 @@ gyp -f ninja "${NSS_SRC_DIR}/nss/nss.gyp" \
97168
-Dpython=python3
98169

99170
GENERATED_DIR="${NSS_SRC_DIR}/nss/out/Release/"
171+
echo "=== Dumping build.ninja for nss-macos-cross ==="
172+
cat "${GENERATED_DIR}/build.ninja"
173+
174+
# With the mac flavor, we can build all targets including shared libraries
175+
# The generated ninja rules will use macOS-style linker flags (e.g., -install_name instead of -soname)
100176
ninja -C "${GENERATED_DIR}"
101177

102178
# Assemble the DIST_DIR with relevant libraries and headers
@@ -112,3 +188,4 @@ ninja -C "${GENERATED_DIR}"
112188
# Cleanup
113189
rm -rf "${NSS_BUILD_DIR}"
114190
rm -rf "${NSPR_BUILD_DIR}"
191+
rm -rf "${WRAPPER_DIR}"

taskcluster/scripts/toolchain/cross-compile-setup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ for TARGET in x86_64-apple-darwin aarch64-apple-darwin; do
2929
export ${RUST_ANDROID_PREFIX}_CC=${CLANG_BIN}/clang-20
3030
export ${RUST_ANDROID_PREFIX}_TOOLCHAIN_PREFIX=${CCTOOL_BIN}
3131
export ${RUST_ANDROID_PREFIX}_AR=${CCTOOL_BIN}/${TARGET}-ar
32+
export ${RUST_ANDROID_PREFIX}_AS=${CCTOOL_BIN}/${TARGET}-as
3233
export ${RUST_ANDROID_PREFIX}_RANLIB=${CCTOOL_BIN}/${TARGET}-ranlib
34+
export ${RUST_ANDROID_PREFIX}_LD=${CCTOOL_BIN}/${TARGET}-ld
3335
export ${RUST_ANDROID_PREFIX}_LD_LIBRARY_PATH=${CLANG_LIB}
3436
export ${RUST_ANDROID_PREFIX}_RUSTFLAGS="-C linker=${CLANG_BIN}/clang-20 -C link-arg=-fuse-ld=${CCTOOL_BIN}/${TARGET}-ld -C link-arg=-B -C link-arg=${CCTOOL_BIN} -C link-arg=-target -C link-arg=${TARGET} -C link-arg=-isysroot -C link-arg=${SYSROOT} -C link-arg=-Wl,-syslibroot,${SYSROOT} -C link-arg=-Wl,-dead_strip"
35-
export ${RUST_ANDROID_PREFIX}_CFLAGS_${TARGET//-/_}="-B ${CCTOOL_BIN} -target ${TARGET} -isysroot ${SYSROOT}"
36-
export ${RUST_ANDROID_PREFIX}_LDFLAGS_${TARGET//-/_}="-B ${CCTOOL_BIN} -target ${TARGET} -isysroot ${SYSROOT} -Wl,-syslibroot,${SYSROOT} -Wl,-dead_strip"
37+
export ${RUST_ANDROID_PREFIX}_CFLAGS_${TARGET//-/_}="-B ${CCTOOL_BIN} -target ${TARGET} -isysroot ${SYSROOT} -fuse-ld=${CCTOOL_BIN}/${TARGET}-ld"
3738
export ${RUST_ANDROID_PREFIX}_BINDGEN_EXTRA_CLANG_ARGS="--sysroot ${SYSROOT}"
3839
done
3940

taskcluster/scripts/toolchain/desktop-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ git submodule update --init
55
./taskcluster/scripts/toolchain/setup-fetched-rust-toolchain.sh
66
. ./taskcluster/scripts/toolchain/cross-compile-setup.sh
77
pushd libs
8-
./build-all.sh darwin-x86-64
98
./build-all.sh darwin-aarch64
9+
./build-all.sh darwin-x86-64
1010
popd
1111
mkdir -p "$UPLOAD_DIR"
1212
tar -czf "$UPLOAD_DIR"/macos.tar.gz libs/desktop

0 commit comments

Comments
 (0)