WIP : Glibc fixes to fix build errors and undefined symbol errors#793
WIP : Glibc fixes to fix build errors and undefined symbol errors#793vidyalakshmir wants to merge 5 commits intomainfrom
Conversation
…supported by wasm and caused build errors
…uilds which caused undefined symbol error for pow etc
End-to-End Test ReportTest PreviewTest Report Deterministic TestsSummary
Test Results by Category
Fail TestsSummary
Test Results by Category
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # which must be preserved. | ||
| # With SSE disabled, ensure -fpmath is not set to use sse either. | ||
| rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387 | ||
| #rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387 |
There was a problem hiding this comment.
would prefer to remove rather than comment out? leave a comment that it was removed.
There was a problem hiding this comment.
also with comments what are these flags for and why they should be removed for wasm build
rennergade
left a comment
There was a problem hiding this comment.
Left a minor comment. Also the title of the PR would be better to be more descriptive.
Other than that looks good, approved.
|
Thanks. Will change the title. Would like to wait to merge this since I might have additional fixes. |
qianxichen233
left a comment
There was a problem hiding this comment.
previously when I was building shared glibc, I simulated part of the symbol versioning by scanning the VERSIONS file in glibc and manually exporting these symbols. This PR seems to try to completely disable symbol versioning. Could you explain what is the limitation of the simulated symbol versioning approach?
| return 1 | ||
| fi | ||
|
|
||
| #libdl.a is created as a placeholder since static python build requires libdl.a |
There was a problem hiding this comment.
FYI: this is likely due to the special wasm routine for python build as python do treat wasm build slightly different
| # which must be preserved. | ||
| # With SSE disabled, ensure -fpmath is not set to use sse either. | ||
| rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387 | ||
| #rtld-CFLAGS += -mno-sse -mno-mmx -mfpmath=387 |
There was a problem hiding this comment.
also with comments what are these flags for and why they should be removed for wasm build
This PR does additional glibc fixes:
It adds a placeholder for libdl.a which is required for apps like python
Adds unwind_def object file for libc.a
Updated s_frexpl.c with latest glibc code to fix the build error. Essentially control flow always matched #else of the preprocessing directive which was causing build error for the file.
Compiler flags -mno-sse, -mno-mmx and -mfpmath-387 were used to build files within elf/ for shared builds and this was compilation errors as these flags are not supported for wasm. Hence, removed these flags and all files within elf/ are successfully compiled and object files are created.
Undefined symbol error were observed for 'pow' and other functions while running tests with glibc shared build. WebAssembly does not support ELF-style symbol versioning (.symver).
When compiling glibc shared objects (.os), the Clang Wasm backend silently drops public symbols (like
pow) that are wrapped in these versioning macros. Furthermore, since Wasmtime does not use thestandard Linux
ld.sodynamic loader, glibc's internal PLT-bypassing and hidden visibility mechanisms are incompatible. This commit updatesinclude/libc-symbols.hto:SHAREDbuilds by redefiningsymbol_versionanddefault_symbol_versionto fallback to standard Cstrong_aliasandweak_aliasmacros.visibility("hidden")attribute block for shared builds (acting as a hard guarantee alongsideCFLAGS="-DNO_HIDDEN").These changes force the glibc shared build to emit standard, globally visible symbols, mirroring the behavior of static (.o) builds and allowing the Clang Wasm backend to correctly link the library.