Skip to content

Commit

Permalink
fix(cli): properly handle RUSTFLAGS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jan 13, 2022
1 parent 110f219 commit d84cbe8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,21 @@ export class BuildCommand extends Command {
})
}

let rustflags = process.env.RUSTFLAGS ?? ''
const rustflags = process.env.RUSTFLAGS
? process.env.RUSTFLAGS.split(' ')
: []
if (triple.raw.includes('musl')) {
if (!rustflags.includes('target-feature=-crt-static')) {
rustflags += '-C target-feature=-crt-static'
rustflags.push('-C target-feature=-crt-static')
}
}

if (this.isStrip && !rustflags.includes('-C link-arg=-s')) {
rustflags += '-C link-arg=-s'
rustflags.push('-C link-arg=-s')
}

if (rustflags.length > 0) {
additionalEnv['RUSTFLAGS'] = rustflags
additionalEnv['RUSTFLAGS'] = rustflags.join(' ')
}

if (this.useZig) {
Expand Down

0 comments on commit d84cbe8

Please sign in to comment.