emscripten-core / emscripten-core/emscripten

[question] Mixing C and C++ code if -fwasm-exceptions enabled

Open
#18,500 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi,

most probably it is related to https://github.com/emscripten-core/emscripten/issues/11219, but I'd like to have a confirmation.
I am building C++ code into a library with "-fwasm-exceptions", which means that "libc++-except.a" is being pulled in during linking.
However I need to create a C library (which by default pulls in "libc++-noexcept.a") - as I have different CFLAGS and CXXFLAGS, I
am adding "-fwasm-exceptions" only to the CXXFLAGS.
And finally I need to link them together. Currently it fails with duplicate symbols as lot of __cxa stuff is being pulled in duplicated from "libc++-except.a" and "libc++-noexcept.a".

I have sorted the issue out via adding "-fwasm-exceptions" to CFLAGS as well, which sounds kinda counterintuitive.

Is it the appropriate way to sort this issue out?
Thanks,

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.