-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Bad function pointer using fmt in a side-module. #22587
Comments
It seems that combining both LTO, DCE (with I've also been trying to replace my usage of |
@jdumas {fmt} has logic to autodetect string-like types so if your custom string view has compatible API it will be automatically formattable. |
@vitaut is there a way to hijack that? At least for local testing to see if I can circumvent the runtime error by having fmt convert it to a full std::string, or use the |
@jdumas you can opt out of this detection via this internal trait: https://github.com/fmtlib/fmt/blob/6d43c755bc225b57f0fb55fef53408e7964644c6/include/fmt/base.h#L423C8-L423C26 |
Does enabling How about using |
@vitaut Hmm this doesn't seem to work. Am I forgetting something? @sbc100 I enabled Using |
|
I see. Yes the stack trace looks like this after I enable
|
My bad. Since this trait is internal, it's only used for convenience in some places and not enough to disable string-like API detection. |
Ah, too bad. Would it make sense to expose it as a feature in fmt? Without it I don't really see what other workaround I could use. |
Sure, a PR would be welcome, provided that there is a reasonable motivation - I can't say that I fully understand what is going on in this issue. |
Yeah me neither. I'm hoping @sb100 can confirm whether it's a bug in emscripten and whether there is a possible workaround. |
I think I see what the problem might be. Can you confirm is adding |
Indeed, adding |
I'm working on a fix, but is adding |
I think so? I'm not sure exactly what this does tbh. Do you have an explanation of what is happening and why |
Then you use emscripten/src/library_dylink.js Line 531 in 52cc139
dynCall_xxx functions that are provided by the module: emscripten/src/library_dylink.js Lines 575 to 577 in 52cc139
If |
Hmm but how do you explain that the program ran fine in Debug mode, or without LTO/DCE enabled? In any case thanks for your help! I would have never been able to figure this out myself 😅 |
I would imagine that perhaps in that mode the main module already had its own version of |
Version of emscripten/emsdk:
I'm on macOS 14.5.
Failing command line in full:
Consider the following project:
CMakeLists.txt
main_module.cpp
side_module.cpp
Steps to reproduce:
Compile with the following:
Failing output:
The text was updated successfully, but these errors were encountered: