:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(flox): pin SDKROOT to an SDK lld can link against (#101478)
Alessandro Pogliaghi724bd42aef8f
diff --git a/.flox/env/on-activate.sh b/.flox/env/on-activate.shindex 9054e66ffcaa..f7c000ee20d6 100755--- a/.flox/env/on-activate.sh+++ b/.flox/env/on-activate.sh@@ -542,6 +542,53 @@ elif [[ -n "$_flox_rustc_ver" ]]; thendone_step "Rust toolchain (rustc ${_flox_rustc_ver})"fi+# ── macOS SDK check for lld (aarch64-darwin only) ──────────────────+# rust/.cargo/config.toml links Rust via lld here. Newer macOS SDKs drop the+# arm64-macos slice from their libSystem/libc/libm .tbd stubs and add an+# arm64e.x1 slice that lld cannot parse, which fails every Rust link with+# undefined libc symbols. Pin SDKROOT to the newest SDK lld can still read.+if [[ "$(uname -s)-$(uname -m)" == "Darwin-arm64" && -z "${SDKROOT:-}" ]] && command -v lld >/dev/null 2>&1; then+ _sdk_links_arm64() {+ local tbd="$1/usr/lib/libSystem.tbd"+ [[ -r "$tbd" ]] || return 1+ awk '/^targets:/{f=1} f{print} f&&/]/{exit}' "$tbd" |+ grep -qE '(^|[][ ,])arm64-macos([],]|$)'+ }++ _active_sdk=$(xcrun --show-sdk-path 2>/dev/null)+ if [[ -n "$_active_sdk" ]] && ! _sdk_links_arm64 "$_active_sdk"; then+ _sdk_dirs=(/Library/Developer/CommandLineTools/SDKs)+ _xcode_dev_dir=$(xcode-select -p 2>/dev/null)+ [[ -n "$_xcode_dev_dir" ]] && _sdk_dirs+=("$_xcode_dev_dir/Platforms/MacOSX.platform/Developer/SDKs")++ _lld_sdk=""+ while IFS=$'\t' read -r _ _candidate; do+ if _sdk_links_arm64 "$_candidate"; then+ _lld_sdk="$_candidate"+ break+ fi+ done < <(+ for _dir in "${_sdk_dirs[@]}"; do+ [[ -d "$_dir" ]] || continue+ for _sdk in "$_dir"/MacOSX*.sdk; do+ [[ -d "$_sdk" && ! -L "$_sdk" ]] || continue+ printf '%s\t%s\n' "$(basename "$_sdk")" "$_sdk"+ done+ done | sort -Vr -k1,1+ )++ if [[ -n "$_lld_sdk" ]]; then+ export SDKROOT="$_lld_sdk"+ done_step "macOS SDK ${C_DIM}($(basename "$_lld_sdk") — newest one lld can link against)${C_RESET}"+ else+ warn_step "No macOS SDK found that lld can link against. Rust builds will fail."+ echo -e " ${C_DIM}$(basename "$_active_sdk") has no arm64-macos slice in its .tbd stubs.${C_RESET}"+ echo -e " ${C_DIM}Fix: install an older SDK, or drop -fuse-ld=lld from rust/.cargo/config.toml.${C_RESET}"+ fi+ fi+ unset -f _sdk_links_arm64+fi+# Share a single Cargo target dir so worktrees skip redundant linkingexport CARGO_TARGET_DIR="$HOME/.cargo/target"