Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken zig behaviors #1432

Merged
merged 1 commit into from Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions cli/src/build.ts
Expand Up @@ -309,11 +309,12 @@ export class BuildCommand extends Command {
if (rustflags.length > 0) {
additionalEnv['RUSTFLAGS'] = rustflags.join(' ')
}
let isZigExisted = false
if (isCrossForLinux || isCrossForMacOS) {

let useZig = false
if (this.useZig || isCrossForLinux || isCrossForMacOS) {
try {
execSync('zig version')
isZigExisted = true
useZig = true
} catch (e) {
if (this.useZig) {
throw new TypeError(
Expand All @@ -329,15 +330,15 @@ export class BuildCommand extends Command {
}
}

if ((this.useZig || isCrossForLinux || isCrossForMacOS) && isZigExisted) {
if (useZig) {
controversial marked this conversation as resolved.
Show resolved Hide resolved
const zigABIVersion =
this.zigABIVersion ?? (isCrossForLinux && triple.abi === 'gnu')
? DEFAULT_GLIBC_TARGET
: null
this.zigABIVersion ??
(isCrossForLinux && triple.abi === 'gnu' ? DEFAULT_GLIBC_TARGET : null)
const mappedZigTarget = ZIG_PLATFORM_TARGET_MAP[triple.raw]
const zigTarget = `${mappedZigTarget}${
zigABIVersion ? `.${zigABIVersion}` : ''
}`
debug(`Using Zig with target ${chalk.green(zigTarget)}`)
if (!mappedZigTarget) {
throw new Error(`${triple.raw} can not be cross compiled by zig`)
}
Expand Down