[PATCH] [libcxx] Set _LIBCPP_ELAST for mingw.
Breckin Loggins
breckin at apportable.com
Fri Dec 5 17:31:50 PST 2014
This would be as good a time as any to mention a few clang + llvm mingw hacks:
1. You may want to use the Itanium CXX ABI format if something on the MS CXX ABI isn’t working or if you want to try linking with other mingw-compiled C++ libraries.
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index 4d06648..ec702a9 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -83,7 +83,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
ComplexLongDoubleUsesFP2Ret = false;
// Set the C++ ABI based on the triple.
- TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment()
+ TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment() && Triple.getVendor() != llvm::Triple::MyCustomTarget
? TargetCXXABI::Microsoft
: TargetCXXABI::GenericItanium);
2. (this is on LLVM) If you want to use GDB to debug your mingw-built binaries compiled with clang, you need to have LLVM output DWARF instead of CodeView:
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 331381b..ee608f2 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -222,7 +222,8 @@ bool AsmPrinter::doInitialization(Module &M) {
}
if (MAI->doesSupportDebugInformation()) {
- if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) {
+ if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment() &&
+ !(Triple(TM.getTargetTriple()).getVendor() == Triple::MyCustomTarget)) {
Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this),
DbgTimerName,
CodeViewLineTablesGroupName));
It might actually support both at once since it’s a vector of Handlers, but I haven’t tested this.
(In both cases I have a custom vendor target defined, but you could switch on whatever you want or just hack it to false if you want to play around, of course)
The latter should probably be fixed by looking for an explicit -ggdb option or -gdwarf-foo (assuming those can get all the way to the LLVM code).
3. f you are running on Win32 and you have a function that takes up more than 4k of stack space, clang will emit a chkstk() intrinsic (which you can’t ignore because it will allocate more valid stack pages instead of running into the guard page). But it doesn’t link with mingw’s bfd so you need to stub it and call it correctly. I did it this way:
__declspec(naked) void _chkstk() {
// Don't "call", "jmp" because cygwin.S's _alloca routine pushes the original function's
// return address on the stack before calling "ret", so calling "call" here would screw up the
// return stack
asm("jmp __alloca”); // No, not THAT one, the OTHER one...
}
4. Clang/LLVM with MSVC compatibility emits names without underscores, but MingW’s linker and the included libs want them, so that’s fun.
5. You might need to munge some of the math instrinsics like long long divide.
I hope this helps your mingw + clang quest!
Regards,
Breckin Loggins
> On Dec 5, 2014, at 4:59 PM, Eric Fiselier <eric at efcs.ca> wrote:
>
> I have a mingw environment set up so I'll test this and look into it tomorrow.
>
> http://reviews.llvm.org/D6558
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list