Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] itanium_demangle symbols in .wasm file #110861

Open
pavelsavara opened this issue Dec 20, 2024 · 10 comments · May be fixed by #111033
Open

[browser] itanium_demangle symbols in .wasm file #110861

pavelsavara opened this issue Dec 20, 2024 · 10 comments · May be fixed by #111033
Assignees
Labels
arch-wasm WebAssembly architecture area-Build-mono in-pr There is an active PR which will close this issue when it is merged os-browser Browser variant of arch-wasm
Milestone

Comments

@pavelsavara
Copy link
Member

Our .wasm files contain itanium_demangle symbols which is LLVMDemangle.lib from x64

See

set(MONO_llvm_core_libs "LLVMOrcJIT" "LLVMPasses" "LLVMIRPrinter" "LLVMHipStdPar" "LLVMCoroutines" "LLVMipo" "LLVMInstrumentation" "LLVMVectorize" "LLVMLinker" "LLVMFrontendOpenMP" "LLVMFrontendOffloading" "LLVMCodeGen" "LLVMScalarOpts" "LLVMInstCombine" "LLVMObjCARCOpts" "LLVMCodeGenTypes" "LLVMCFGuard" "LLVMAggressiveInstCombine" "LLVMTransformUtils" "LLVMWindowsDriver" "LLVMJITLink" "LLVMOption" "LLVMMCJIT" "LLVMExecutionEngine" "LLVMTarget" "LLVMRuntimeDyld" "LLVMOrcTargetProcess" "LLVMOrcShared" "LLVMBitWriter" "LLVMAnalysis" "LLVMProfileData" "LLVMSymbolize" "LLVMDebugInfoBTF" "LLVMDebugInfoPDB" "LLVMDebugInfoMSF" "LLVMDebugInfoDWARF" "LLVMObject" "LLVMTextAPI" "LLVMMCParser" "LLVMIRReader" "LLVMAsmParser" "LLVMMC" "LLVMDebugInfoCodeView" "LLVMBitReader" "LLVMCore" "LLVMRemarks" "LLVMBitstreamReader" "LLVMBinaryFormat" "LLVMTargetParser" "LLVMSupport" "LLVMDemangle")

list(APPEND MONOSGENSHARED_LINKABLE_EXTRALIBS ${OS_LIBS} ${LLVM_LIBS})

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-browser Browser variant of arch-wasm labels Dec 20, 2024
@pavelsavara pavelsavara added this to the 10.0.0 milestone Dec 20, 2024
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@pavelsavara
Copy link
Member Author

It also happens on Net9

@radekdoulik
Copy link
Member

radekdoulik commented Jan 2, 2025

the Itanium demangle is just C++ name mangling on unix systems, used on other architectures than itanium.

it is linked away in out publish .wasm, so I think we don't need to do anything here.

> wa-info -d -f itanium_demangle artifacts/obj/mono/Wasm.Browser.Bench.Sample/browser.wasm.Release/browser-wasm/wasm/for-publish/dotnet.native.wasm | grep func | wc -l
     268
> wa-info -d -f itanium_demangle src/mono/sample/wasm/browser-bench/bin/browser-wasm/publish/dotnet.native.wasm | grep func | wc -l
       0

@pavelsavara
Copy link
Member Author

pavelsavara commented Jan 2, 2025

I can reproduce it out of tree with 9.0.101 vanilla template

dotnet new wasmbrowser
dotnet publish -c Release

Image

@pavelsavara pavelsavara reopened this Jan 2, 2025
@pavelsavara
Copy link
Member Author

Adding <EmccExtraLDFlags>-Wl,--print-map</EmccExtraLDFlags> shows the source as

C:\Dev\.dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Cache.win-x64\9.0.0\tools\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-except.a(cxa_demangle.o)

@radekdoulik
Copy link
Member

Interestingly it doesn't happen in intree build in main, but happens in net9 template. I was able to reproduce it locally in net9 and wasmbrowser template.

With Pavel we tried to use main's clang and wasm-ld to see if main's linker might behave differently. it still reproduced in net9 template.

@pavelsavara
Copy link
Member Author

with <EmccExtraLDFlags>-Wl,--trace-symbol=__cxa_demangle</EmccExtraLDFlags>

    C:\Dev\.dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Cache.win-x64\9.0.0\tools\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-except.a(cxa_demangle.o): lazy definition of __cxa_demangle
    C:\Dev\.dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Cache.win-x64\9.0.0\tools\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-except.a(cxa_exception_js_utils.o): reference to __cxa_demangle
    C:\Dev\.dotnet\packs\Microsoft.NET.Runtime.Emscripten.3.1.56.Cache.win-x64\9.0.0\tools\emscripten\cache\sysroot\lib\wasm32-emscripten\libc++abi-except.a(cxa_demangle.o): definition of __cxa_demangle

@radekdoulik
Copy link
Member

Meanwhile we traced it back to -s EXPORT_EXCEPTION_HANDLING_HELPERS=1 option, which pulls the demangle symbols in.

@kg do we still need this setting? It was added in #91364

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Jan 2, 2025
@pavelsavara
Copy link
Member Author

I'm testing without it here #111033

@kg
Copy link
Member

kg commented Jan 2, 2025

I believe these are still needed for proper exception handling integration. Not specifically the demangle stuff but the other bits that come with the exception handling helpers.

It's possible something has changed and they aren't needed, but you would need to manually test to verify that the relevant configurations haven't regressed, as they aren't tested by CI. I don't remember how to test it anymore, to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Build-mono in-pr There is an active PR which will close this issue when it is merged os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants