Skip to content

Commit 7217dac

Browse files
committed
add rpath flag if not using cc shims
1 parent 6f3f56e commit 7217dac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libexec/stage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ const pkg = await pantry.resolve(parse(pkgname))
5858
const pantry_sh = await pantry.getScript(pkg, 'build', deps)
5959
const sup_PATH = [new Path(new URL(import.meta.url).pathname).parent().parent().join("share/brewkit")]
6060

61-
if (!deps.find(({pkg}) => pkg.project == 'llvm.org' || pkg.project == 'gnu.org/gcc')) {
61+
const use_cc_shims = !deps.find(({pkg}) => pkg.project == 'llvm.org' || pkg.project == 'gnu.org/gcc')
62+
63+
if (use_cc_shims) {
6264
/// add our helper cc toolchain unless the package has picked its own toolchain
6365
sup_PATH.push(new Path(new URL(import.meta.url).pathname).parent().parent().join("share/toolchain/bin"))
6466

@@ -110,6 +112,10 @@ if (host().platform == 'linux' && host().arch == 'x86-64') {
110112
env['CFLAGS'] = [`${env['CFLAGS']?.[0] ?? ''} -fPIC`.trim()]
111113
env['CXXFLAGS'] = [`${env['CXXFLAGS']?.[0] ?? ''} -fPIC`.trim()]
112114
}
115+
if (host().platform == 'darwin' && !use_cc_shims) {
116+
// our shims inject this but if we aren’t using them we need to add it manually or everything breaks
117+
env['LDFLAGS'] = [`${env['LDFLAGS']?.[0] ?? ''} -Wl,-rpath,${useConfig().prefix}`.trim()]
118+
}
113119

114120
const text = undent`
115121
#!/usr/bin/env -S pkgx bash

0 commit comments

Comments
 (0)