Skip to content

Commit 573b284

Browse files
committed
set CC and linker when cross-compiling for linux
I thought just setting the target would do this but it was still calling the system linker...
1 parent 967a7cc commit 573b284

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/release.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ jobs:
4646
targets: ${{ steps.get_target.outputs.target_name }}
4747

4848
- name: Building
49+
if: runner.os == 'Linux' && matrix.arch == 'arm64'
50+
env:
51+
npm_config_arch: ${{ matrix.arch }}
52+
CC: aarch64-linux-gnu-gcc
53+
run: pnpm install
54+
55+
- name: Building
56+
if: ${{ !(runner.os == 'Linux' && matrix.arch == 'arm64') }}
4957
env:
5058
npm_config_arch: ${{ matrix.arch }}
5159
run: pnpm install

build.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ const { spawn, buildPaths, exists } = require('./shared');
1616
await fs.mkdir(buildPaths.bin, { recursive: true });
1717
}
1818

19+
const customLinkerFlags = process.env.CC
20+
? ['--config', `target.${getRustTarget()}.linker="${process.env.CC}"`]
21+
: [];
22+
1923
await spawn('cargo', [
2024
'build',
2125
`--target=${getRustTarget()}`,
26+
...customLinkerFlags,
2227
`--manifest-path=${path.join(buildPaths.submodule, 'Cargo.toml')}`,
2328
`--target-dir=${buildPaths.build}`,
2429
'--release'
25-
]);
30+
], {
31+
env: process.env,
32+
});
2633

2734
await fs.copyFile(
2835
buildPaths.exeOut,

0 commit comments

Comments
 (0)