Skip to content

Commit 8f91084

Browse files
kraenhansenclaude
andauthored
Stop the host Hermes compiler build from targeting visionOS (#443)
* Dump the CMake configure log when the Hermes build fails CMake reports a failed feature check as a bare "not found", with the compiler's actual complaint only in its configure log. The host hermesc configure is failing on the macOS runner with checks that succeed everywhere else, so surface that log rather than guess at it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UkNbgdyuKgHaFwT27RahGH * Stop the host Hermes compiler build from targeting visionOS Every command got all three deployment targets build-apple-framework.sh can ask for, including the host compiler build. XROS_DEPLOYMENT_TARGET is also a clang driver variable, so clang targeted visionOS against the macOS sysroot: clang: warning: using sysroot for 'MacOSX' but targeting 'XR' error: 'pthread_mutexattr_init' is unavailable: not available on visionOS Every API marked unavailable on visionOS then failed to compile, which is why unistd.h (which reaches _fd_def.h through sys/select.h) came back "not found" while sys/stat.h did not, and why the configure died on CheckAtomic. Each platform build now gets only the deployment target it needs, and the host compiler build gets none. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UkNbgdyuKgHaFwT27RahGH --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 263a3bc commit 8f91084

3 files changed

Lines changed: 74 additions & 10 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"react-native-node-api": patch
3+
---
4+
5+
Fix `prebuilt-hermes` failing to configure the host Hermes compiler with "Host
6+
compiler appears to require libatomic, but cannot find it". It exported all
7+
three deployment targets Hermes' `build-apple-framework.sh` can ask for to every
8+
command it ran, including the host compiler build. `XROS_DEPLOYMENT_TARGET` is
9+
also a clang driver variable, so clang targeted visionOS against the macOS
10+
sysroot, and every API marked unavailable there — `pthread_mutexattr_init`, the
11+
`fd_set` helpers reached through `unistd.h` — failed to compile. Each platform
12+
build now gets only the deployment target it needs, and the host compiler build
13+
gets none.

.github/workflows/hermes-prebuilt.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@ jobs:
6767
run: |
6868
path=$(pnpm exec react-native-node-api prebuilt-hermes --no-download)
6969
echo "path=$path" >> "$GITHUB_OUTPUT"
70+
# CMake reports a failed feature check as a bare "not found", with the
71+
# compiler's actual complaint only in its configure log. Surface that log
72+
# here so a failure is diagnosable without another round trip.
73+
- name: Dump CMake configure log
74+
if: failure()
75+
run: |
76+
log=$(find "$PWD" -name CMakeConfigureLog.yaml -path '*build_host_hermesc*' | head -1)
77+
if [ -z "$log" ]; then
78+
echo "No CMakeConfigureLog.yaml found"
79+
find "$PWD" -name 'CMakeError.log' -path '*build_host_hermesc*' -exec cat {} \;
80+
exit 0
81+
fi
82+
echo "::group::Environment seen by CMake"
83+
env | sort
84+
xcode-select --print-path
85+
xcrun --show-sdk-path || true
86+
echo "::endgroup::"
87+
echo "::group::unistd.h check"
88+
grep -n -B 5 -A 45 'unistd\.h' "$log" | head -150
89+
echo "::endgroup::"
90+
echo "::group::atomics check"
91+
grep -n -B 5 -A 60 'HAVE_CXX_ATOMICS_WITHOUT_LIB' "$log" | head -180
92+
echo "::endgroup::"
93+
cp "$log" "$RUNNER_TEMP/CMakeConfigureLog.yaml"
94+
- name: Upload CMake configure log
95+
if: failure()
96+
uses: actions/upload-artifact@v7
97+
with:
98+
name: hermesc-cmake-configure-log
99+
path: ${{ runner.temp }}/CMakeConfigureLog.yaml
100+
if-no-files-found: ignore
70101
# --latest=false keeps these out of the "latest release" slot, which
71102
# belongs to the package releases changesets publishes.
72103
- name: Publish as a release asset

packages/host/src/node/cli/hermes-prebuilt.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,25 @@ const RELEASES_URL =
2727

2828
export const DEFAULT_PLATFORMS = ["iphoneos", "iphonesimulator"];
2929

30-
// Passed to Hermes' build-apple-framework.sh, which errors out rather than
31-
// assume one. These match React Native's own podspec declarations.
32-
const DEPLOYMENT_TARGETS = {
33-
IOS_DEPLOYMENT_TARGET: "15.1",
34-
MAC_DEPLOYMENT_TARGET: "10.15",
35-
XROS_DEPLOYMENT_TARGET: "1.0",
36-
};
30+
/**
31+
* The deployment target build-apple-framework.sh reads for a platform — it
32+
* errors out rather than assume one. These match React Native's own podspec
33+
* declarations.
34+
*
35+
* Only the variable that platform needs is passed. XROS_DEPLOYMENT_TARGET is
36+
* also a clang driver variable, so leaking it into a build that isn't for
37+
* visionOS makes clang target visionOS against whatever sysroot it was given —
38+
* and every API marked unavailable there then fails to compile.
39+
*/
40+
function getDeploymentTarget(platform: string): Record<string, string> {
41+
if (platform === "macosx") {
42+
return { MAC_DEPLOYMENT_TARGET: "10.15" };
43+
} else if (platform === "xros" || platform === "xrsimulator") {
44+
return { XROS_DEPLOYMENT_TARGET: "1.0" };
45+
} else {
46+
return { IOS_DEPLOYMENT_TARGET: "15.1" };
47+
}
48+
}
3749

3850
export const BUILD_TYPES = ["debug", "release"] as const;
3951
export type BuildType = (typeof BUILD_TYPES)[number];
@@ -162,15 +174,19 @@ async function buildArchive({
162174
// vendored copy: the framework and the app linking it share jsi::Runtime.
163175
const jsiPath = path.join(reactNativePath, "ReactCommon", "jsi");
164176

165-
const run = (command: string, args: string[]) =>
177+
const run = (
178+
command: string,
179+
args: string[],
180+
extraEnv: Record<string, string> = {},
181+
) =>
166182
spawn(command, args, {
167183
cwd: hermesPath,
168184
outputMode: "inherit",
169185
// Keeps the build log off stdout, which callers parse for the final path.
170186
stdout: process.stderr,
171187
env: {
172-
...DEPLOYMENT_TARGETS,
173188
...process.env,
189+
...extraEnv,
174190
JSI_PATH: jsiPath,
175191
BUILD_TYPE: buildType === "debug" ? "Debug" : "Release",
176192
HERMES_OVERRIDE_HERMESC_PATH: importHostCompilersPath,
@@ -202,7 +218,11 @@ async function buildArchive({
202218
}
203219

204220
for (const platform of platforms) {
205-
await run("./utils/build-apple-framework.sh", [platform]);
221+
await run(
222+
"./utils/build-apple-framework.sh",
223+
[platform],
224+
getDeploymentTarget(platform),
225+
);
206226
}
207227

208228
const frameworksPath = path.join(

0 commit comments

Comments
 (0)