-
-
Notifications
You must be signed in to change notification settings - Fork 783
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
Cannot link to system libraries due to ABI mismatch when modules are used #3855
Comments
just solve this issue. #2716 (comment) |
I think that fix isn't correct: that's what is introducing the |
I tried making that change myself and it seems to cause other issues but I'm not sure why... Forcing the old ABI will cause issues other than linkage though (for example, the old ABI is not thread safe) |
Actually, that was because the cache was not cleared. Setting the new ABI as I mentioned above does seem to work, at least on my system. |
But it still will break it in previous issue. #2716 (comment) this example: https://github.com/xmake-io/xmake/files/9404087/ModuleTest.zip
only |
What OS/version are you still seeing these issues on? I can take a look into it. |
I get the same issue when building a very simple test case without xmake just using the command line, and without using module header units for string or iostream. I think there's a bug in GCC with it specifying the wrong ABI in the module file when std::string is involved, although I'm surprised nobody would have noticed this before. |
ubuntu 22.10
But at least the previous problem was fixed and is working fine, with no further unusual feedback from users. If set Unless there is a better solution that solves both problems, I'm not going to change it for now. |
What I'm trying to say is that setting this flag doesn't actually fix the problem for anyone. It may allow programs built with it to compile but they'll just fail at runtime, often in subtle and difficult to debug ways. In my opinion silent runtime errors/incorrect semantics are worse than a compile error. The issue is a bug in gcc that needs fixing on their side, but working around it by silently introducing bugs into user code doesn't seem worthwhile until the gcc bug is fixed. At the very least there should be a warning that this flag is being added, because it breaks C semantics. |
At least in my case, it runs fine too.
Since it is the result of a bug in gcc, I will only consider setting it up and turning it off automatically based on the gcc version once it is fixed by gcc and a new release is available. Until then, I'll have to keep this setting for now. But I've added a new policy that allows you to optionally turn on new abi. set_languages("c 20")
set_policy("build.c .gcc.modules.cxx11abi", true)
target("hello")
set_kind("binary")
add_files("src/*.cpp", "src/*.cppm") |
any progress on this? |
This should be fixed in gcc14 I believe, I haven't tested it with xmake yet though. |
Xmake Version
2.7.9
Operating System Version and Architecture
Gentoo Linux
Describe Bug
When modules are enabled, xmake unconditionally passes a flag switching g to use the old pre-C 11 abi:
xmake/xmake/rules/c /modules/modules_support/gcc.lua
Line 77 in 68153d0
This causes failures to link, and also sometimes runtime failures, due to ABI mismatch as Linux distrobutions build with the new ABI. For example if calling a library function that takes a
std::string
from a library compiled without this flag you will either get a linker failure, or worse a runtime segfault, becausestd::string
has a different implementation with or without the flag.The old ABI is broken and non-standards conformant so it shouldn't really be being used anyway. If a specific ABI needs to be forced for some reason, we should flip the flag and pass
-D_GLIBCXX_USE_CXX11_ABI=1
to force the new ABI instead.Expected Behavior
Successful linkage with system libraries because both are using the new ABI
Project Configuration
xmake.lua:
src/main.cpp:
Additional Information and Error Logs
No response
The text was updated successfully, but these errors were encountered: