Skip to content

Commit d43350e

Browse files
authored
Pass headerpad_max_install_names to linker (#346)
* Pass headerpad_max_install_names to linker * Add weak-node-api to macos test app
1 parent 178f205 commit d43350e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.changeset/clear-peas-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cmake-rn": patch
3+
---
4+
5+
Fix auto-linking failures due to lack of padding when renaming install name of libraries, by passing headerpad_max_install_names argument to linker.

packages/cmake-rn/src/platforms/apple.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ export const platform: Platform<Triplet[], AppleOpts> = {
278278
CMAKE_SYSTEM_NAME: CMAKE_SYSTEM_NAMES[triplet],
279279
CMAKE_OSX_SYSROOT: XCODE_SDK_NAMES[triplet],
280280
CMAKE_OSX_ARCHITECTURES: APPLE_ARCHITECTURES[triplet],
281+
// Passing a linker flag to increase the header pad size to allow renaming the install name when linking it into the app.
282+
CMAKE_SHARED_LINKER_FLAGS: "-Wl,-headerpad_max_install_names",
281283
},
282284
{
283285
// Setting the output directories works around an issue with Xcode generator

scripts/init-macos-test-app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ async function patchPackageJson() {
104104
APP_PATH,
105105
path.join(ROOT_PATH, "packages", "host"),
106106
),
107+
"weak-node-api": path.relative(
108+
APP_PATH,
109+
path.join(ROOT_PATH, "packages", "weak-node-api"),
110+
),
107111
...Object.fromEntries(
108112
Object.entries(otherDependencies).filter(([name]) =>
109113
transferredDependencies.has(name),

0 commit comments

Comments
 (0)