33# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
44# SPDX-License-Identifier: Apache-2.0
55
6- # Shared build-environment helpers for host-side cross-compilation .
6+ # Shared build-environment helpers for host-side Rust builds .
77#
88# Source this file (do not execute it) and call the helpers before invoking
9- # cargo-zigbuild on the host.
9+ # Cargo on the host.
1010
1111# ensure_build_nofile_limit raises the per-process open-file limit before a
12- # host cargo-zigbuild cross-compile. The static *-unknown-linux-musl link opens
13- # hundreds of .rlib files simultaneously, which exceeds macOS's default soft
14- # limit of 256 and fails with ProcessFdQuotaExceeded. The raised limit
15- # propagates to the cargo/zig children the caller spawns.
12+ # host Rust build. Sccache and static *-unknown-linux-musl links can each open
13+ # hundreds of files simultaneously, exceeding macOS's default soft limit of
14+ # 256. The raised limit propagates to the Cargo children the caller spawns.
1615#
1716# The limit is read from OPENSHELL_BUILD_NOFILE_LIMIT (default 8192), honoring
18- # the legacy OPENSHELL_VM_BUILD_NOFILE_LIMIT for back-compat. This is a no-op on
19- # Linux and when cargo-zigbuild is not installed (native builds, CI Linux
20- # runners), so it must be safe to call unconditionally.
17+ # the legacy OPENSHELL_VM_BUILD_NOFILE_LIMIT for back-compat. This is a no-op
18+ # on Linux, so it must be safe to call unconditionally.
2119ensure_build_nofile_limit () {
2220 local desired=" ${OPENSHELL_BUILD_NOFILE_LIMIT:- ${OPENSHELL_VM_BUILD_NOFILE_LIMIT:- 8192} } "
2321 local minimum=1024
@@ -26,9 +24,7 @@ ensure_build_nofile_limit() {
2624 local target=" "
2725
2826 [ " $( uname -s) " = " Darwin" ] || return 0
29- command -v cargo-zigbuild > /dev/null 2>&1 || return 0
30-
31- current=" $( ulimit -n 2> /dev/null || echo " " ) "
27+ current=" $( ulimit -Sn 2> /dev/null || echo " " ) "
3228 case " ${current} " in
3329 ' ' |* [!0-9]* )
3430 return 0
@@ -53,24 +49,24 @@ ensure_build_nofile_limit() {
5349 ;;
5450 esac
5551
56- if [ " ${target} " -gt " ${current} " ] && ulimit -n " ${target} " 2> /dev/null; then
57- echo " ==> Raised open file limit for cargo-zigbuild : ${current} -> $( ulimit -n ) "
52+ if [ " ${target} " -gt " ${current} " ] && ulimit -Sn " ${target} " 2> /dev/null; then
53+ echo " ==> Raised open file limit for host Cargo build : ${current} -> $( ulimit -Sn ) "
5854 fi
5955
60- current=" $( ulimit -n 2> /dev/null || echo " ${current} " ) "
56+ current=" $( ulimit -Sn 2> /dev/null || echo " ${current} " ) "
6157 case " ${current} " in
6258 ' ' |* [!0-9]* )
6359 return 0
6460 ;;
6561 esac
6662
6763 if [ " ${current} " -lt " ${desired} " ]; then
68- echo " WARNING: Open file limit is ${current} ; cargo-zigbuild is more reliable at ${desired} + on macOS."
64+ echo " WARNING: Open file limit is ${current} ; host Cargo builds are more reliable at ${desired} + on macOS."
6965 fi
7066
7167 if [ " ${current} " -lt " ${minimum} " ]; then
72- echo " ERROR: Open file limit (${current} ) is too low for cargo-zigbuild on macOS." >&2
73- echo " Run: ulimit -n ${desired} " >&2
68+ echo " ERROR: Open file limit (${current} ) is too low for host Cargo builds on macOS." >&2
69+ echo " Run: ulimit -Sn ${desired} " >&2
7470 echo " Then re-run this script." >&2
7571 exit 1
7672 fi
0 commit comments