www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - MSVC x64: Compilation issues with current head and LLVM 3.5 final

reply "kink" <noone nowhere.com> writes:
Hi guys,

I tried compiling the latest head with LLVM 3.5 final using 
VS2013 (Update 3) and failed due to linking errors when building 
ldc2.
Before getting to that, I had to fix 2 minor issues - adapting 
the pdata_patch.patch for LLVM and fixing an ambiguous strtold() 
overload in LDC (when compiling with VS2013 only).
So here are the 2 patches and the linking errors which I'm 
currently stuck at.

PATCH 1: pdata_patch.patch adapted for LLVM 3.5 final

diff --git a/include/llvm/MC/MCWin64EH.h 
b/include/llvm/MC/MCWin64EH.h
index 3df0d0a..76d760a 100644
--- a/include/llvm/MC/MCWin64EH.h
+++ b/include/llvm/MC/MCWin64EH.h
   -71,6 +71,7    struct Instruction {
      int LastFrameInst;
      MCWinFrameInfo *ChainedParent;
      std::vector<WinEH::Instruction> Instructions;
+    int Index;
    };

    class MCWin64EHUnwindEmitter {
diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp
index 46e80cc..98ae5b9 100644
--- a/lib/MC/MCStreamer.cpp
+++ b/lib/MC/MCStreamer.cpp
   -432,6 +432,7    void MCStreamer::EmitWinCFIStartProc(const 
MCSymbol *Symbol) {
    MCWinFrameInfo *Frame = new MCWinFrameInfo;
    Frame->Begin = getContext().CreateTempSymbol();
    Frame->Function = Symbol;
+  Frame->Index = WinFrameInfos.size();
    EmitLabel(Frame->Begin);
    WinFrameInfos.push_back(Frame);
    CurrentWinFrameInfo = WinFrameInfos.back();
   -451,6 +452,7    void MCStreamer::EmitWinCFIStartChained() {
    Frame->Begin = getContext().CreateTempSymbol();
    Frame->Function = CurrentWinFrameInfo->Function;
    Frame->ChainedParent = CurrentWinFrameInfo;
+  Frame->Index = WinFrameInfos.size();
    EmitLabel(Frame->Begin);
    WinFrameInfos.push_back(Frame);
    CurrentWinFrameInfo = WinFrameInfos.back();
diff --git a/lib/MC/MCWin64EH.cpp b/lib/MC/MCWin64EH.cpp
index 95e1983..7621d52 100644
--- a/lib/MC/MCWin64EH.cpp
+++ b/lib/MC/MCWin64EH.cpp
   -235,24 +235,23    StringRef 
MCWin64EHUnwindEmitter::GetSectionSuffix(const MCSymbol *func) {
  }

  static const MCSection *getWin64EHTableSection(StringRef suffix,
-                                               MCContext 
&context) {
-  if (suffix == "")
-    return context.getObjectFileInfo()->getXDataSection();
-
+                                               MCContext 
&context, int index) {
+  char comdat[30];
+  sprintf(comdat, "xdata%d", index);
    return context.getCOFFSection((".xdata"+suffix).str(),
                                  
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
                                  COFF::IMAGE_SCN_MEM_READ,
-                                SectionKind::getDataRel());
+                                SectionKind::getDataRel(), 
comdat, 0);
  }

  static const MCSection *getWin64EHFuncTableSection(StringRef 
suffix,
-                                                   MCContext 
&context) {
-  if (suffix == "")
-    return context.getObjectFileInfo()->getPDataSection();
+                                                   MCContext 
&context, int index) {
+  char comdat[30];
+  sprintf(comdat, "pdata%d", index);
    return context.getCOFFSection((".pdata"+suffix).str(),
                                  
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
                                  COFF::IMAGE_SCN_MEM_READ,
-                                SectionKind::getDataRel());
+                                SectionKind::getDataRel(), 
comdat, 0);
  }

  void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
   -261,7 +260,7    void 
MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
    // here and from Emit().
    MCContext &context = streamer.getContext();
    const MCSection *xdataSect =
-    getWin64EHTableSection(GetSectionSuffix(info->Function), 
context);
+    getWin64EHTableSection(GetSectionSuffix(info->Function), 
context, info->Index);
    streamer.SwitchSection(xdataSect);

    llvm::EmitUnwindInfo(streamer, info);
   -273,7 +272,7    void MCWin64EHUnwindEmitter::Emit(MCStreamer 
&Streamer) {
    // Emit the unwind info structs first.
    for (const auto &CFI : Streamer.getWinFrameInfos()) {
      const MCSection *XData =
-        getWin64EHTableSection(GetSectionSuffix(CFI->Function), 
Context);
+        getWin64EHTableSection(GetSectionSuffix(CFI->Function), 
Context, CFI->Index);
      Streamer.SwitchSection(XData);
      EmitUnwindInfo(Streamer, CFI);
    }
   -281,7 +280,7    void MCWin64EHUnwindEmitter::Emit(MCStreamer 
&Streamer) {
    // Now emit RUNTIME_FUNCTION entries.
    for (const auto &CFI : Streamer.getWinFrameInfos()) {
      const MCSection *PData =
-        
getWin64EHFuncTableSection(GetSectionSuffix(CFI->Function), 
Context);
+        
getWin64EHFuncTableSection(GetSectionSuffix(CFI->Function), 
Context, CFI->Index);
      Streamer.SwitchSection(PData);
      EmitRuntimeFunction(Streamer, CFI);
    }

--------------------

PATCH 2: strtold.patch for LDC

diff --git a/dmd2/root/longdouble.h b/dmd2/root/longdouble.h
index d5fbf94..cf6118d 100644
--- a/dmd2/root/longdouble.h
+++ b/dmd2/root/longdouble.h
   -198,7 +198,13    longdouble tanl (longdouble ld);

  longdouble fmodl(longdouble x, longdouble y);
  longdouble ldexpl(longdouble ldval, int exp); // see strtold
+
+#if _MSC_VER < 1800
  longdouble strtold(const char *p,char **endp);
+#else // VS2013 provides strtold(), but returns a double
+longdouble strtold_dmd(const char *p,char **endp);
+#define strtold strtold_dmd
+#endif

  inline longdouble fabs (longdouble ld) { return fabsl(ld); }
  inline longdouble sqrt (longdouble ld) { return sqrtl(ld); }

--------------------

I still get 12 linking errors when building the ldc2 project.

   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeMOVHLPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeMOVHLPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeMOVHLPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeMOVHLPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeMOVLHPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeMOVLHPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeMOVLHPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeMOVLHPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodePALIGNRMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePALIGNRMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodePALIGNRMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePALIGNRMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFHWMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFHWMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFHWMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFHWMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFLWMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFLWMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodePSHUFLWMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodePSHUFLWMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeSHUFPMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeSHUFPMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeSHUFPMask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeSHUFPMask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeUNPCKHMask(class llvm::MVT,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeUNPCKHMask llvm  YAXVMVT 1 AEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeUNPCKHMask(class llvm::MVT,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeUNPCKHMask llvm  YAXVMVT 1 AEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeUNPCKLMask(class llvm::MVT,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeUNPCKLMask llvm  YAXVMVT 1 AEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeUNPCKLMask(class llvm::MVT,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeUNPCKLMask llvm  YAXVMVT 1 AEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeVPERM2X128Mask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeVPERM2X128Mask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeVPERM2X128Mask(class llvm::MVT,unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeVPERM2X128Mask llvm  YAXVMVT 1 IAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86CodeGen.lib(X86ISelLowering.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeVPERMMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeVPERMMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "bool __cdecl getTargetShuffleMask(class 
llvm::SDNode *,class llvm::MVT,class llvm::SmallVectorImpl<int> 
&,bool &)" 
(?getTargetShuffleMask  YA_NPEAVSDNode llvm  VMVT 2 AEAV?$SmallVec
orImpl H 2 AEA_N Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2001: 
unresolved external symbol "void __cdecl 
llvm::DecodeVPERMMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeVPERMMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   LLVMX86AsmPrinter.lib(X86InstComments.obj) : error LNK2019: 
unresolved external symbol "void __cdecl 
llvm::DecodeINSERTPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &)" 
(?DecodeINSERTPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z) 
referenced in function "void __cdecl 
llvm::EmitAnyX86InstComments(class llvm::MCInst const *,class 
llvm::raw_ostream &,char const * (__cdecl*)(unsigned int))" 
(?EmitAnyX86InstComments llvm  YAXPEBVMCInst 1 AEAVraw_ostream 1 P6APEBDI Z Z) 
[C:\LDC\ldc-build\ldc2.vcxproj]
   C:\LDC\ldc-build\bin\Debug\ldc2.exe : fatal error LNK1120: 12 
unresolved externals [C:\LDC\ldc-build\ldc2.vcxproj]

The functions seem to belong to LLVMX86Utils.lib, which isn't 
linked explicitly to ldc2. I tried adding the lib manually in the 
VS project and building it in VS (so that CMake doesn't 
interfere), but I still get the same errors. I looked up the 
first function (DecodeMOVHLPSMask) in LLVMX86Utils.lib using 
dumpbin, which gave me:

216 00000150 SECT4  notype ()    External     | 
?DecodeMOVHLPSMask llvm  YAXIAEAV?$SmallVectorImpl H 1  Z (void 
__cdecl llvm::DecodeMOVHLPSMask(unsigned int,class 
llvm::SmallVectorImpl<int> &))

I don't know what to make of this. At least you know about it 
now. :)

Thanks and keep up the good work!
Sep 21 2014
next sibling parent "kink" <noone nowhere.com> writes:
Update:

Patch 2 isn't complete, I missed the implementation ;) - as I 
didn't get to the obvious linking error yet. :P

diff --git a/dmd2/root/longdouble.h b/dmd2/root/longdouble.h
index d5fbf94..cf6118d 100644
--- a/dmd2/root/longdouble.h
+++ b/dmd2/root/longdouble.h
   -198,7 +198,13    longdouble tanl (longdouble ld);

  longdouble fmodl(longdouble x, longdouble y);
  longdouble ldexpl(longdouble ldval, int exp); // see strtold
+
+#if _MSC_VER < 1800
  longdouble strtold(const char *p,char **endp);
+#else // VS2013 provides strtold(), but returns a double
+longdouble strtold_dmd(const char *p,char **endp);
+#define strtold strtold_dmd
+#endif

  inline longdouble fabs (longdouble ld) { return fabsl(ld); }
  inline longdouble sqrt (longdouble ld) { return sqrtl(ld); }
diff --git a/vcbuild/strtold.c b/vcbuild/strtold.c
index bbe0188..ffa7398 100644
--- a/vcbuild/strtold.c
+++ b/vcbuild/strtold.c
   -136,7 +136,11    static longdouble postab[] =
   * Terminates on first unrecognized character.
   */

+#if _MSC_VER >= 1800
+longdouble strtold_dmd(const char *p,char **endp)
+#else
  longdouble strtold(const char *p,char **endp)
+#endif
  {
          longdouble ldval;
          int exp;

--------------------

The linking errors when building the ldc2 library vanish as soon 
as I invoke the linker command-line manually and add the 
LLVMX86Utils.lib. It just doesn't work from within VS by editing 
the project options and building.
Anyway, looks like a bug in the CMake config. Unfortunately, I 
don't speak CMake..
Sep 21 2014
prev sibling parent reply "Trass3r" <un known.com> writes:
Be brave, building with msvc is still a bumpy road.
First of all the pdata problem is fixed in llvm head.
Doesn't necessarily mean the unwind tables are really correct now 
(https://github.com/ldc-developers/ldc/issues/166#issuecomment-54522891). 
But people seem to prefer discussing warning flags at great 
length.

There are more issues you may encounter, for some I use some 
local hacks.
Need to create some tickets for them.

Never seen those linker errors though.
Only some about *ObjC* functions in llvm.
Sep 21 2014
parent reply "kink" <noone nowhere.com> writes:
Thanks for the encouragement. ;)

 First of all the pdata problem is fixed in llvm head.
Perfect, this means we do not need any patches for LLVM and LDC (apart from strtold.patch above) to get it at least to compile with MSVC and provide some exception support - that's already a big improvement since last time I checked. :) With LLVM head I now get 32 errors with 17 unresolved externals, all due to the non-included LLVMX86Utils.lib. After unloading the ZERO_CHECK project in the VS solution, I'm able to add the missing lib in the project settings and build ldc2 successfully from VS without CMake interfering.
 There are more issues you may encounter, for some I use some 
 local hacks.
 Need to create some tickets for them.
That'd be great and save others the hassle - and may even get me into looking into them if I can. ;) I know about the missing C99 support of Microsoft's CRT and therefore LDC's MinGW dependency, but apparently VS2013 has improved in that regard. I'd strongly encourage all LDC for Windows efforts to follow the MSVC x64 path (instead of 32-bit and/or MinGW-x64!) and only support VS 2013+ due to its broader and more POSIX-compatible CRT, which should reduce the hacking effort..
Sep 21 2014
parent reply "Kai Nacke" <kai redstar.de> writes:
Hi kink!

Thanks for trying to use LDC2 with MSVC!

On Sunday, 21 September 2014 at 15:06:05 UTC, kink wrote:
 With LLVM head I now get 32 errors with 17 unresolved 
 externals, all due to the non-included LLVMX86Utils.lib. After 
 unloading the ZERO_CHECK project in the VS solution, I'm able 
 to add the missing lib in the project settings and build ldc2 
 successfully from VS without CMake interfering.
This is the result of a change in the LLVM build system. You can work around it by adding x86utils to list of LLVM components (CMakeLists.txt, line 19). See LLVM bug http://llvm.org/bugs/show_bug.cgi?id=21016
 There are more issues you may encounter, for some I use some 
 local hacks.
 Need to create some tickets for them.
That'd be great and save others the hassle - and may even get me into looking into them if I can. ;) I know about the missing C99 support of Microsoft's CRT and therefore LDC's MinGW dependency, but apparently VS2013 has improved in that regard. I'd strongly encourage all LDC for Windows efforts to follow the MSVC x64 path (instead of 32-bit and/or MinGW-x64!) and only support VS 2013+ due to its broader and more POSIX-compatible CRT, which should reduce the hacking effort..
I'll switch soon to VS2013. These problems should vanish then. Regards, Kai
Sep 21 2014
parent reply "kink" <noone nowhere.com> writes:
Hi Kai,

thanks for clarifying the LLVMX86Utils issue.

 I'll switch soon to VS2013. These problems should vanish then.
Great. We'll still need some sort of POSIX layer for the parts missing in MSVCRT but required by druntime/Phobos. For exactly this purpose, I trimmed down the MinGW-w64 CRT a while ago (based on v2.0.8) and adapted it so that it can be built with Clang in order to get a COFF library suited for the MS linker. Additionally, I modified Clang to enable x87 support for VS x64 targets, so that MinGW-w64's longdouble functions can be used from D. https://github.com/kinke/mingw-w64-crt
Sep 22 2014
parent "kink" <noone nowhere.com> writes:
 I'll switch soon to VS2013. These problems should vanish then.
You may wanna reconsider and wait for VS2014. ;) http://blogs.msdn.com/b/vcblog/archive/2014/06/18/crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1.aspx "In the Visual Studio "14" CTP we have fully implemented the C99 Standard Library, with the exception of any library features that depend on compiler features not yet supported by the Visual C++ compiler (notably, <tgmath.h> is not implemented). There are undoubtedly some remaining conformance issues--we know of a few, including that _Exit is missing and wcstok has the wrong signature, and we are working to fix these." These are pretty good news indeed! By relaxing the D real type to FP64 in LDC2 for Windows and relying on the VS2014+ CRT we could probably get away with a minor number of hacks in druntime/Phobos (and get rid of a few legacy workarounds)! :))
Sep 22 2014