Closed
Description
Related links:
- https://groups.google.com/g/emscripten-discuss/c/g_vkRRSCPUI
- Update musl to v1.2.2 #13006
- Add some new musl math files to libc-rt library #15497
When testing the latest tot version which switched to musl v1.2.2, I'm getting linker errors in the sokol-samples project only when building with LTO enabled:
wasm-ld: error: /...cache/sysroot/lib/wasm32-emscripten/lto/libc.a(exp2f_data.o): undefined symbol: __exp2f_data
wasm-ld: error: /...cache/sysroot/lib/wasm32-emscripten/lto/libc.a(exp_data.o): undefined symbol: __exp_data
Unfortunately I'm having a hard time coming up with a minimal reproduction test case. From looking at the MUSL sources I'd expect that just using one of the pow(), exp(), exp2()
calls (or their 'f' versions) in a minimal source file and compiling with LTO should trigger the problem, but so far no dice (stay tuned).
PS: the optimizer passes removed the actual function calls and replaced them with simplified expressions 🙄
Here's a reproducer for the exp2_data problem:
//
// Compile with:
//
// emcc -flto -O3 -o bla.js bla.c
//
#include <stdio.h> // printf()
#include <stdlib.h> // atof()
#include <math.h> // exp2f()
#include <assert.h> // assert()
int main(int argc, char* argv[]) {
assert(argc > 0);
// important to have some unpredictable input value, otherwise
// the optimizer will remove the exp2f call alltogether
const float val = atof(argv[1]);
const float res = exp2f(val);
printf("%f\n", res);
return 0;
}
...and a reproducer for exp_data
, same code, just replace the exp2f()
call with exp2()
:
//
// Compile with:
//
// emcc -flto -O3 -o bla.js bla.c
//
#include <stdio.h> // printf()
#include <stdlib.h> // atof()
#include <math.h> // exp2f()
#include <assert.h> // assert()
int main(int argc, char* argv[]) {
assert(argc > 0);
const double val = atof(argv[1]);
const double res = exp2(val);
printf("%f\n", res);
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels