[llvm-commits] [PATCH][EXPERIMENTAL] Building LLVMgold.dll

NAKAMURA Takumi geek4civic at gmail.com
Mon Sep 13 09:19:54 CDT 2010


Good evening, guys!

This patch enables building LTO.dll, libLTO.a and LLVMgold.dll on cygming.
I know it is still incomplete, and I would say it is "experimental".

Known issue:

  - dependency between libs would be incomplete.
  - I don't know how to test functionality.

...Takumi
-------------- next part --------------
diff --git a/tools/Makefile b/tools/Makefile
index aa07a2b..fb70f22 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -35,12 +35,11 @@ include $(LEVEL)/Makefile.config
 # These libraries build as dynamic libraries (.dylib /.so), they can only be
 # built if ENABLE_PIC is set.
 ifeq ($(ENABLE_PIC),1)
-  # No support for dynamic libraries on windows targets.
-  ifneq ($(TARGET_OS), $(filter $(TARGET_OS), Cygwin MingW))
     # gold only builds if binutils is around.  It requires "lto" to build before
     # it so it is added to DIRS.
     ifdef BINUTILS_INCDIR
-      DIRS += lto gold
+      DIRS += lto
+      PARALLEL_DIRS += gold
     else
       PARALLEL_DIRS += lto
     endif
@@ -54,6 +53,13 @@ ifeq ($(ENABLE_PIC),1)
       PARALLEL_DIRS += edis
     endif
     endif
+endif
+
+# No support for dynamic libraries on windows targets.
+ifneq (,$(filter $(TARGET_OS), Cygwin MingW))
+  ifneq ($(ENABLE_SHARED),1)
+    PARALLEL_DIRS := $(filter-out bugpoint-passes edis, \
+                        $(PARALLEL_DIRS))
   endif
 endif
 
diff --git a/tools/gold/Makefile b/tools/gold/Makefile
index 82a4e39..9eb02c1 100644
--- a/tools/gold/Makefile
+++ b/tools/gold/Makefile
@@ -22,10 +22,28 @@ SHARED_LIBRARY = 1
 LOADABLE_MODULE = 1
 
 LINK_COMPONENTS := support system
-LIBS += -llto
+
+ifneq (,$(filter $(HOST_OS), Cygwin MingW))
+  ifneq ($(ENABLE_SHARED),1)
+    LINK_COMPONENTS += $(TARGETS_TO_BUILD) ipo scalaropts linker bitreader bitwriter
+  endif
+endif
 
 # Because off_t is used in the public API, the largefile parts are required for
 # ABI compatibility.
-CXXFLAGS+=-I$(BINUTILS_INCDIR) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -lLTO
+CXXFLAGS+=-I$(BINUTILS_INCDIR) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 
 include $(LEVEL)/Makefile.common
+
+ifneq (,$(filter $(HOST_OS), Cygwin MingW))
+  ifeq ($(ENABLE_SHARED),1)
+    LLVMLibsOptions := -L$(SharedLibDir) -lLTO $(LLVMLibsOptions)
+    LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LTO$(SHLIBEXT)
+  else
+    LLVMLibsOptions := -lLTO $(LLVMLibsOptions)
+    LLVMLibsPaths += $(LibDir)/libLTO.a
+  endif
+else
+  LLVMLibsOptions := -L$(SharedLibDir) -lLTO $(LLVMLibsOptions)
+  LLVMLibsPaths += $(SharedLibDir)/$(SharedPrefix)LTO$(SHLIBEXT)
+endif
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 4b58fae..1f40768 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -29,6 +29,10 @@
 #include <list>
 #include <vector>
 
+#ifdef __MINGW32__
+#include <io.h>
+#endif
+
 using namespace llvm;
 
 namespace {


More information about the llvm-commits mailing list