-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
-ffunction-sections -fdata-sections #148
Comments
Yes, To achieve the same as |
It appears to work and compile correctly, but the generated libraries don't seem to be compatible with MSVC linker. It complains that the library is corrupt. The same issue occurs when using mingw64 gcc. |
So you are compiling something using mingw tools, and then linking using mingw tools or the MSVC linker? You'll need to provide a minimal reproducible example for me to be able to act on this. Do note that you can't (in general) mix object files (or static libraries) built in mingw mode and MSVC mode; code built in mingw mode needs to be linked into a dll with a mingw linker before you can interface with it with MSVC tools. (The fact that it might seem to work in small testcases does not imply that it works in general.) |
The libraries I am creating are GNU GMP, MPFR, and MPC. They are compiled and linked with LLVM-MINGW. If I create static libraries and then use them in visual studio 2019, everything works great. If I compile with |
Aha, ok, that explains it. Yes, this is a clear case that the warranty doesn't cover - the fact that it happened to work for you before adding these options was sheer luck, and even if it does seem to link correctly there could be cases where the e.g. CRT headers and import libraries subtly disagree and you'd run into to hard to diagnose bugs at runtime. In particular, |
I see, that makes sense. So, do you recommend compiling these libraries dynamically instead of statically in order to eliminate these hard to diagnose bugs at runtime? Or are these bugs unavoidable when mixing mingw gcc/llvm code with MSVC. |
Building libraries dynamically is the generally recommended, safe way of handling mixing mingw and and msvc code. |
Does llvm-mingw for windows support
-ffunction-sections
and-fdata-sections
? If it does, do we need these flags for Windows? Assume I have compiled a library with llvm-mingw and wish to use MSVC's/Gy
and/OPT:REF
(in order to only statically link those functions which my executable uses from the library). I asked a similar question here: msys2/MINGW-packages#6808The text was updated successfully, but these errors were encountered: