Skip to content

Commit

Permalink
use xcode ar and ranlib if present (#285)
Browse files Browse the repository at this point in the history
We set AR and RANLIB if gcc is used on darwin
---------

Co-authored-by: Max Howell <[email protected]>
  • Loading branch information
jhheider and mxcl authored Jan 31, 2024
1 parent 2950396 commit 643b3f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/cmd/build
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ if (ghout) {
///////////////////////////////////////////////////////////////////
function make_toolchain() {
const deps = new Set(config.deps.dry.build.concat(config.deps.dry.runtime).map(x => x.project))

if (deps.has('llvm.org') || deps.has('gnu.org/gcc')) {
return
}
Expand Down
8 changes: 8 additions & 0 deletions lib/porcelain/build-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { usePantry, useConfig } = hooks
const { host } = utils

export default async function(config: Config, PATH?: Path): Promise<string> {
const depset = new Set(config.deps.gas.map(x => x.pkg.project))
const depstr = (deps: PackageRequirement[]) => deps.map(x => `"+${utils.pkg.str(x)}"`).join(' ')
const env_plus = `${depstr(config.deps.dry.runtime)} ${depstr(config.deps.dry.build)}`.trim()
const user_script = await usePantry().getScript(config.pkg, 'build', config.deps.gas, config)
Expand All @@ -24,6 +25,13 @@ export default async function(config: Config, PATH?: Path): Promise<string> {
const FLAGS = flags()
if (host().platform == 'darwin') {
FLAGS.push("export MACOSX_DEPLOYMENT_TARGET=11.0")

// gcc needs to use Apple’s ar/ranlib combo on darwin almost always or link failure occurs
// see https://github.com/pkgxdev/brewkit/pull/285
if (depset.has('gnu.org/binutils')) {
FLAGS.push("export AR=/usr/bin/ar")
FLAGS.push("export RANLIB=/usr/bin/ranlib")
}
}

const tmp = (() => {
Expand Down
1 change: 1 addition & 0 deletions projects/fix-machos.com/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ build:
else
ZLIB_VERSION={{deps.zlib.net.version}}
fi
- run: install_name_tool -change @rpath/zlib.net/v{{deps.zlib.net.version}}/lib/libz.${ZLIB_VERSION}.dylib {{prefix}}/lib/libz.dylib fix-machos-test
working-directory: '{{prefix}}/bin'

Expand Down

0 comments on commit 643b3f6

Please sign in to comment.