-
Notifications
You must be signed in to change notification settings - Fork 213
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
Regression: build failure on i686-pc-windows-gnu due to multiple definition of _alloca
#585
Comments
Failed also on Rust's CI: rust-lang/rust#123426
|
"good", in that it's readily reproducible. |
Given that the previous Alternative (untested) solutions:
|
I'll try invoking the expert: @mstorsjo, any thoughts? I am still not entirely clear on the use case for this (at least on windows-gnu*). It seems libgcc is always linked in for -gnu, which obviously contains |
GCC always adds |
Does this work now? I know we have issues with checking I think I previously said that this wouldn't work for us (in msys2) because we are still patching rust to turn i686-pc-windows-gnu into something that acts like -gnullvm but is still called -gnu. Thinking about this more, now I think this would be OK, it would exclude |
Sorry, I don't quite know the whole picture of what's going on here, but I'll try to add some comments/observations.
In the C world, when linking with GCC, it always links in libgcc. When linking with clang (in mingw mode), it either links in libgcc or compiler-rt builtins. So the object files providing this symbol should always be included. If linked with Having both may or may not end up in a conflict. If the user provided object (where I guess the rust files are?) files contains |
I think it was determined that the object file in libgcc where
Also, another possible complicating factor is that in rust's case, this crate seems to end up provided by a shared library (DLL), so we're actually dealing with symbols coming from an import library (libstd-394a669d59370585.dll.a) vs those coming from a static library (libgcc.a) |
What if a |
For fun, trying to see where the
This seems to be coming from the static libLLVMSupport.a |
Indeed, I added the following to src/x86.rs (at the start of the #[naked]
#[cfg(all(
windows,
target_env = "gnu",
not(feature = "no-asm")
))]
pub unsafe extern "C" fn __chkstk() {
core::arch::asm!(
"jmp __alloca", // Jump to __alloca since fallthrough may be unreliable"
options(noreturn, att_syntax)
);
} |
Yes both i686-pc-windows-gnu and gnullvm build all the way through with that addition. |
I've tracked down where the reference to |
This does sound like a reasonable solution, and it sounds like it works well in practice. Overall, having a toolchain library object file supply more than one symbol, has been a cause for such conflicts many times. See mstorsjo/llvm-mingw#397 for a very similar issue recently, where we had two edit: That’s not the commit I was thinking about. I actually meant llvm/llvm-project@248aeac. |
This also seems like a reasonable solution to me. Feel free to open a PR for that. 👍 |
For both MSVC and MinGW targets, the compiler generates calls to functions for probing the stack, in functions that allocate a larger amount of stack space. The exact behaviour of these functions differ per architecture (some decrement the stack, some actually decrement the stack pointer, some only probe the stack). In MSVC mode, the compiler always generates calls to a symbol named "__chkstk". In MinGW mode, the symbol is named "__alloca" on i386 and "___chkstk_ms" on x86_64, but the functions behave exactly the same as their MSVC counterparts despite the differing names. (On i386, these names are the raw symbol names - if considering a C level function name with the extra implicit leading underscore, they would be called "_chkstk" and "_alloca".) Remove the misleading duplicate and unused functions. These were added in fbfed86 / c27de5b (adding "___chkstk_ms" for both architectures, even if that symbol name only was used on x86_64) and 40eb83b (adding "__alloca" and "___chkstk", even if the former only was used on i386, and the latter seeming like a misspelled form of the MSVC function, with three underscores instead of two). The x86_64 "___chkstk" was doubly surprising as that function had the same behaviour as the function used on i386, while the "__chkstk" that MSVC emitted calls to should behave exactly like the preexisting "___chkstk_ms". Remove the unused functions, and rename the misspelled MSVC-like symbols to the correct name that MSVC mode actually uses. Note that these files aren't assembled at all when building compiler-rt builtins in MSVC mode, as they are expected to be provided by MSVC libraries when building code in MSVC mode. Differential Revision: https://reviews.llvm.org/D159139
The changes in #575 seem to have broken MSYS2's build of i686-pc-windows-gnu:
Specifically, the latest update renaming
__alloca
to_alloca
seems to have caused this error. The version of the changes from commit 67c1c0a (before the last force-push on that PR) work in both i686-pc-windows-gnu and i686-pc-windows-gnullvm.I'm opening this as a new issue in hopes that that increases visibility. Hopefully somebody else can also verify that this breaks the 'offical' build of i686-pc-windows-gnu as distributed by rust-lang.org.
Originally posted by @jeremyd2019 in #575 (comment)
The text was updated successfully, but these errors were encountered: