- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcompiler-rtcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.
Milestone
Description
Zig Version
0.15.0-dev.99+c1db72cdb
Steps to Reproduce and Observed Behavior
Tried finding existing reports or similar issues, but no luck. Apologies if there's an existing one I couldn't find.
Found while trying to build dvui for wasm32-freestanding
in ReleaseSafe mode, which fails, but which works in Debug mode. The smallest reproducible snippet I could find is
// test.zig
export fn bla(f: i32) f64 {
return @exp2(@as(f64, @floatFromInt(f)));
}
Then
$ zig build-exe -target wasm32-freestanding -O Debug -fno-entry -rdynamic test.zig
$ echo $?
0
$ zig-0.15.0-dev build-exe -target wasm32-freestanding -O ReleaseSafe -fno-entry -rdynamic test.zig
error: wasm-ld: test.wasm.o: undefined symbol: ldexp
Changing the argument from i32
to i64
makes it pass:
export fn bla(f: i64) f64 {
return @exp2(@as(f64, @floatFromInt(f)));
}
Changing the integer to i32 argument and the floats to f32 makes it fail on undefined symbol: ldexpf
.
Expected Behavior
I expected a build which succeeds in Debug to also succeed in any of the release build modes.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcompiler-rtcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
alexrp commentedon Mar 25, 2025
This is happening because of LLVM's
LibCallSimplifier
; it seems to assume thatldexp
exists when simplifyingexp2
. Same story forldexpf
.We should just add
ldexp
/ldexpf
/ldexpl
implementations in Zig's compiler-rt for use when libc doesn't provide them, similar to what we do withexp2
/exp2f
/exp2l
.Add a basic ldexp
Add a basic ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp
Add the ldexp family of functions, proxy to std.math.ldexp