You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to use cc-rs to build some code that's in two well-defined sections: some library code, distributed as source, and another library that wraps the first library.
To me, the logical way to implement this in my build.rs is by using two instances of cc::Build, one for the first library and one for the second. This works completely fine under Windows.
However, when testing the build on Linux (both on Arch Linux on a laptop and Ubuntu 22.04.2 through WSL2 on my PC), the build fails to link. For some reason, symbols in the first library aren't being found properly, so the second library is full of undefined references. Adding shared_flag(true) doesn't seem to do anything.
I've created a minimal example that demonstrates this using two C files. My actual project is C++, but the exact same issue occurs.
Interestingly, I was able to work around the issue - by adding .link_lib_modifier("+whole-archive") to the first library. This obviously isn't ideal, as I'd prefer to avoid bloating the final binary if at all possible, but it does suggest that perhaps the issue is related to dead code elimination. I'm mainly just confused about why the behaviour is different on Windows.
Am I being extremely silly and missing an obvious flag to make this magically work? Is this use case simply not supported?
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to use cc-rs to build some code that's in two well-defined sections: some library code, distributed as source, and another library that wraps the first library.
To me, the logical way to implement this in my
build.rs
is by using two instances ofcc::Build
, one for the first library and one for the second. This works completely fine under Windows.However, when testing the build on Linux (both on Arch Linux on a laptop and Ubuntu 22.04.2 through WSL2 on my PC), the build fails to link. For some reason, symbols in the first library aren't being found properly, so the second library is full of undefined references. Adding
shared_flag(true)
doesn't seem to do anything.I've created a minimal example that demonstrates this using two C files. My actual project is C++, but the exact same issue occurs.
Interestingly, I was able to work around the issue - by adding
.link_lib_modifier("+whole-archive")
to the first library. This obviously isn't ideal, as I'd prefer to avoid bloating the final binary if at all possible, but it does suggest that perhaps the issue is related to dead code elimination. I'm mainly just confused about why the behaviour is different on Windows.Am I being extremely silly and missing an obvious flag to make this magically work? Is this use case simply not supported?
The text was updated successfully, but these errors were encountered: