Skip to content

Commit 150a3d9

Browse files
committed
debugging ci
1 parent ab47e79 commit 150a3d9

File tree

5 files changed

+97
-10
lines changed

5 files changed

+97
-10
lines changed

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: 85 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,86 @@ 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+
# REAL_CC may contain spaces (e.g., "clang-20 -target ..."), so we need to use eval
76+
eval exec "${REAL_CC}" '"${args[@]}"'
77+
EOF
78+
chmod +x "${WRAPPER_DIR}/cc-wrapper"
79+
80+
# Set CC and CXX to use the wrapper with all flags baked in
81+
export REAL_CC="${BASE_CC} ${CFLAGS}"
82+
CC="${WRAPPER_DIR}/cc-wrapper"
83+
CXX="${WRAPPER_DIR}/cc-wrapper"
84+
export CC CXX
85+
86+
# Create a fake xcodebuild script and tool wrappers to allow gyp to use the mac flavor
87+
# This tricks gyp into thinking Xcode is installed so it generates macOS-style build rules
88+
cat > "${WRAPPER_DIR}/xcodebuild" << 'EOF'
89+
#!/usr/bin/env bash
90+
# Fake xcodebuild that returns a version for gyp's mac flavor
91+
# Xcode 12.2 corresponds to macOS SDK 11.0 (Big Sur) and adds Apple Silicon support
92+
echo "Xcode 12.2"
93+
echo "Build version 12B45b"
94+
EOF
95+
chmod +x "${WRAPPER_DIR}/xcodebuild"
96+
97+
# Create unprefixed symlinks to cctools binaries that gyp's mac flavor expects
98+
# The mac flavor expects tools like 'otool', 'libtool', 'lipo' without the target prefix
99+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-otool" "${WRAPPER_DIR}/otool"
100+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-libtool" "${WRAPPER_DIR}/libtool"
101+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-lipo" "${WRAPPER_DIR}/lipo"
102+
ln -s "${TOOLCHAIN_BIN}/${NSS_TARGET}-nm" "${WRAPPER_DIR}/nm"
103+
104+
export PATH="${WRAPPER_DIR}:${PATH}"
105+
106+
# Work around Python 3 bug in Ubuntu 22.04 gyp package
107+
# Create a wrapper that monkey-patches GetStdoutQuiet to fix bytes/str handling
108+
GYP_WRAPPER=$(mktemp)
109+
cat > "${GYP_WRAPPER}" << 'EOFGYP'
110+
#!/usr/bin/env python3
111+
import sys
112+
import gyp.xcode_emulation
113+
114+
# Monkey-patch GetStdoutQuiet to fix Python 3 bytes/str bug
115+
original_GetStdoutQuiet = gyp.xcode_emulation.GetStdoutQuiet
116+
def patched_GetStdoutQuiet(cmdlist):
117+
import subprocess
118+
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
119+
out = job.communicate()[0]
120+
if job.returncode != 0:
121+
return None
122+
return out.rstrip(b'\n').decode('utf-8')
123+
gyp.xcode_emulation.GetStdoutQuiet = patched_GetStdoutQuiet
124+
125+
# Now run gyp normally
126+
import gyp
127+
sys.exit(gyp.script_main())
128+
EOFGYP
129+
chmod +x "${GYP_WRAPPER}"
56130

57131
# Build NSPR
58132
NSPR_BUILD_DIR=$(mktemp -d)
@@ -61,12 +135,10 @@ pushd "${NSPR_BUILD_DIR}"
61135
STRIP="${STRIP}" \
62136
RANLIB="${RANLIB}" \
63137
AR="${AR}" \
64-
AS="${AS:-${AR}}" \
65-
LD="${LD:-${AR}}" \
138+
AS="${AS}" \
139+
LD="${LD}" \
66140
CC="${CC}" \
67141
CCC="${CC}" \
68-
CFLAGS="${CFLAGS}" \
69-
LDFLAGS="${LDFLAGS}" \
70142
--target="${NSS_TARGET}" \
71143
--enable-64bit \
72144
--disable-debug \
@@ -78,7 +150,7 @@ popd
78150
NSS_BUILD_DIR=$(mktemp -d)
79151
rm -rf "${NSS_SRC_DIR}/nss/out"
80152

81-
gyp -f ninja "${NSS_SRC_DIR}/nss/nss.gyp" \
153+
"${GYP_WRAPPER}" -f ninja-mac "${NSS_SRC_DIR}/nss/nss.gyp" \
82154
--depth "${NSS_SRC_DIR}/nss/" \
83155
--generator-output=. \
84156
-DOS=mac \
@@ -97,6 +169,11 @@ gyp -f ninja "${NSS_SRC_DIR}/nss/nss.gyp" \
97169
-Dpython=python3
98170

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

102179
# Assemble the DIST_DIR with relevant libraries and headers
@@ -112,3 +189,4 @@ ninja -C "${GENERATED_DIR}"
112189
# Cleanup
113190
rm -rf "${NSS_BUILD_DIR}"
114191
rm -rf "${NSPR_BUILD_DIR}"
192+
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)