Skip to content

Commit

Permalink
fallback if no zig
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Nov 20, 2022
1 parent 294a39b commit 5337152
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cli/src/build.ts
Expand Up @@ -303,8 +303,27 @@ export class BuildCommand extends Command {
if (rustflags.length > 0) {
additionalEnv['RUSTFLAGS'] = rustflags.join(' ')
}
let isZigExisted = false
if (isCrossForLinux || isCrossForMacOS) {
try {
execSync('zig version')
isZigExisted = true
} catch (e) {
if (this.useZig) {
throw new TypeError(
`Could not find ${chalk.green('zig')} on the PATH`,
)
} else {
debug(
`Could not find ${chalk.green(
'zig',
)} on the PATH, fallback to normal linker`,
)
}
}
}

if (this.useZig || isCrossForLinux || isCrossForMacOS) {
if ((this.useZig || isCrossForLinux || isCrossForMacOS) && isZigExisted) {
const zigABIVersion =
this.zigABIVersion ?? (isCrossForLinux && triple.abi === 'gnu')
? DEFAULT_GLIBC_TARGET
Expand Down

1 comment on commit 5337152

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5337152 Previous: 035def0 Ratio
noop#napi-rs 59757413 ops/sec (±0.24%) 55270758 ops/sec (±0.19%) 0.92
noop#JavaScript 593065337 ops/sec (±0.09%) 712617818 ops/sec (±0.16%) 1.20
Plus number#napi-rs 21430756 ops/sec (±0.62%) 19840697 ops/sec (±0.56%) 0.93
Plus number#JavaScript 591930692 ops/sec (±0.43%) 709773557 ops/sec (±0.28%) 1.20
Create buffer#napi-rs 459591 ops/sec (±6.86%) 376424 ops/sec (±9.34%) 0.82
Create buffer#JavaScript 2011697 ops/sec (±1.77%) 1654823 ops/sec (±4.55%) 0.82
createArray#createArrayJson 42423 ops/sec (±0.12%) 38355 ops/sec (±0.11%) 0.90
createArray#create array for loop 8461 ops/sec (±0.1%) 7525 ops/sec (±0.11%) 0.89
createArray#create array with serde trait 8512 ops/sec (±0.09%) 7507 ops/sec (±0.13%) 0.88
getArrayFromJs#get array from json string 17787 ops/sec (±0.34%) 16903 ops/sec (±0.24%) 0.95
getArrayFromJs#get array from serde 11299 ops/sec (±0.12%) 10167 ops/sec (±0.03%) 0.90
getArrayFromJs#get array with for loop 12830 ops/sec (±0.15%) 12185 ops/sec (±0.12%) 0.95
Get Set property#Get Set from native#u32 375629 ops/sec (±4.91%) 402616 ops/sec (±5.68%) 1.07
Get Set property#Get Set from JavaScript#u32 337435 ops/sec (±4.36%) 349716 ops/sec (±5.48%) 1.04
Get Set property#Get Set from native#string 359353 ops/sec (±4.41%) 362021 ops/sec (±5.47%) 1.01
Get Set property#Get Set from JavaScript#string 314427 ops/sec (±4.41%) 333856 ops/sec (±5.75%) 1.06
Async task#spawn task 35012 ops/sec (±1.34%) 35797 ops/sec (±2.1%) 1.02
Async task#ThreadSafeFunction 2304 ops/sec (±8.15%) 1990 ops/sec (±12.78%) 0.86
Async task#Tokio future to Promise 30815 ops/sec (±3.38%) 30478 ops/sec (±3.53%) 0.99
Query#query * 100 2021 ops/sec (±5.47%) 1996 ops/sec (±4.23%) 0.99
Query#query * 1 30724 ops/sec (±6.77%) 31402 ops/sec (±0.64%) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.