[Lldb-commits] [lldb] r232220 - Fix makefiles to build shared library tests on Windows.

Zachary Turner zturner at google.com
Fri Mar 13 14:51:11 PDT 2015


Author: zturner
Date: Fri Mar 13 16:51:11 2015
New Revision: 232220

URL: http://llvm.org/viewvc/llvm-project?rev=232220&view=rev
Log:
Fix makefiles to build shared library tests on Windows.

Abstracted away some POSIX-isms that caused MAKE to issue invalid
commands on Windows.  Added a new force-include for the test
programs so that we can use platform-specific macros.

TestSharedLib now builds and cleans up on Windows, though the test
still fails some of the expectations.

Differential Revision: http://reviews.llvm.org/D8277
Patch by: Adrian McCarthy
Issue Tracker: http://llvm.org/pr21727

Added:
    lldb/trunk/test/make/test_common.h
Removed:
    lldb/trunk/test/make/uncaught_exception.h
Modified:
    lldb/trunk/test/lang/c/shared_lib/foo.h
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/make/Makefile.rules
    lldb/trunk/test/plugins/builder_base.py

Modified: lldb/trunk/test/lang/c/shared_lib/foo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/shared_lib/foo.h?rev=232220&r1=232219&r2=232220&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/shared_lib/foo.h (original)
+++ lldb/trunk/test/lang/c/shared_lib/foo.h Fri Mar 13 16:51:11 2015
@@ -6,7 +6,5 @@ struct sub_foo
   char *sub_2;
 };
 
-struct foo *GetMeAFoo();
-struct sub_foo *GetMeASubFoo (struct foo *in_foo);
-
-
+LLDB_TEST_API struct foo *GetMeAFoo();
+LLDB_TEST_API struct sub_foo *GetMeASubFoo(struct foo *in_foo);

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=232220&r1=232219&r2=232220&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Mar 13 16:51:11 2015
@@ -1509,7 +1509,7 @@ class Base(unittest2.TestCase):
                  'FRAMEWORK_INCLUDES' : "-F%s" % self.lib_dir,
                  'LD_EXTRAS' : "%s -Wl,-rpath,%s -dynamiclib" % (dsym, self.lib_dir),
                 }
-        elif sys.platform.startswith('freebsd') or sys.platform.startswith("linux") or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
+        elif sys.platform.startswith('freebsd') or sys.platform.startswith("linux") or sys.platform.startswith("win") or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
             d = {'DYLIB_CXX_SOURCES' : sources,
                  'DYLIB_NAME' : lib_name,
                  'CFLAGS_EXTRAS' : "%s -I%s -fPIC" % (stdflag, os.path.join(os.environ["LLDB_SRC"], "include")),

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=232220&r1=232219&r2=232220&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Fri Mar 13 16:51:11 2015
@@ -118,6 +118,7 @@ endif
 
 CFLAGS ?= -g -O0
 CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include
+CFLAGS += -include $(THIS_FILE_DIR)test_common.h
 
 # Use this one if you want to build one part of the result without debug information:
 CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS)
@@ -152,6 +153,8 @@ EXE ?= a.out
 ifneq "$(DYLIB_NAME)" ""
 	ifeq "$(OS)" "Darwin"
 		DYLIB_FILENAME = lib$(DYLIB_NAME).dylib
+  else ifeq "$(OS)" "Windows_NT"
+    DYLIB_FILENAME = $(DYLIB_NAME).dll
 	else
 		DYLIB_FILENAME = lib$(DYLIB_NAME).so
 	endif
@@ -188,7 +191,6 @@ ifeq "$(OS)" "Windows_NT"
 	ifneq (,$(findstring clang,$(CC)))
 		# Clang for Windows doesn't support C++ Exceptions
 		CXXFLAGS += -fno-exceptions
-		CXXFLAGS += -include $(THIS_FILE_DIR)uncaught_exception.h
 		CXXFLAGS += -D_HAS_EXCEPTIONS=0
 		# The MSVC linker doesn't understand long section names
 		# generated by the clang compiler.
@@ -377,6 +379,8 @@ endif
 #----------------------------------------------------------------------
 # Make the dylib
 #----------------------------------------------------------------------
+$(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL
+
 $(DYLIB_FILENAME) : $(DYLIB_OBJECTS)
 ifeq "$(OS)" "Darwin"
 	$(LD) $(LDFLAGS) $(DYLIB_OBJECTS) -install_name "@executable_path/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)"
@@ -395,7 +399,7 @@ endif
 
 #----------------------------------------------------------------------
 # Automatic variables based on items already entered. Below we create
-# an objects lists from the list of sources by replacing all entries
+# an object's lists from the list of sources by replacing all entries
 # that end with .c with .o, and we also create a list of prerequisite
 # files by replacing all .c files with .d.
 #----------------------------------------------------------------------
@@ -409,28 +413,36 @@ endif
 # the compiler -MM option. The -M option will list all system headers,
 # and the -MM option will list all non-system dependencies.
 #----------------------------------------------------------------------
+ifeq "$(OS)" "Windows_NT"
+	JOIN_CMD = &
+	QUOTE = "
+else
+	JOIN_CMD = ;
+	QUOTE = '
+endif
+
 %.d: %.c
-	@rm -f $@; \
+	@rm -f $@ $(JOIN_CMD) \
 	$(CC) -M $(CFLAGS) $< > $@.tmp && \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
 	rm -f $@.tmp
 
 %.d: %.cpp
-	@rm -f $@; \
+	@rm -f $@ $(JOIN_CMD) \
 	$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
 	rm -f $@.tmp
 
 %.d: %.m
-	@rm -f $@; \
+	@rm -f $@ $(JOIN_CMD) \
 	$(CC) -M $(CFLAGS) $< > $@.tmp && \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
 	rm -f $@.tmp
 
 %.d: %.mm
-	@rm -f $@; \
+	@rm -f $@ $(JOIN_CMD) \
 	$(CXX) -M $(CXXFLAGS) $< > $@.tmp && \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+	sed $(QUOTE)s,\($*\)\.o[ :]*,\1.o $@ : ,g$(QUOTE) < $@.tmp > $@ $(JOIN_CMD) \
 	rm -f $@.tmp
 
 #----------------------------------------------------------------------
@@ -461,6 +473,10 @@ ifneq "$(DSYM)" ""
 endif
 ifeq "$(OS)" "Windows_NT"
 	$(RM) "$(EXE).manifest" $(wildcard *.pdb *.ilk)
+  ifneq "$(DYLIB_NAME)" ""
+	  $(RM) $(DYLIB_FILENAME).manifest
+	  $(RM) $(DYLIB_NAME).lib $(DYLIB_NAME).exp
+  endif
 endif
 
 #----------------------------------------------------------------------

Added: lldb/trunk/test/make/test_common.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/test_common.h?rev=232220&view=auto
==============================================================================
--- lldb/trunk/test/make/test_common.h (added)
+++ lldb/trunk/test/make/test_common.h Fri Mar 13 16:51:11 2015
@@ -0,0 +1,19 @@
+// This header is included in all the test programs (C and C++) and provides a
+// hook for dealing with platform-specifics.
+#if defined(_WIN32) || defined(_WIN64)
+#ifdef COMPILING_LLDB_TEST_DLL
+#define LLDB_TEST_API __declspec(dllexport)
+#else
+#define LLDB_TEST_API __declspec(dllimport)
+#endif
+#else
+#define LLDB_TEST_API
+#endif
+
+#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
+// calls to __uncaught_exception.  Unfortunately, it does seem to eliminate
+// the delcaration of __uncaught_excpeiton.  Including <eh.h> ensures that it is
+// declared.  This may not be necessary after MSVC 12.
+#include <eh.h>
+#endif

Removed: lldb/trunk/test/make/uncaught_exception.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/uncaught_exception.h?rev=232219&view=auto
==============================================================================
--- lldb/trunk/test/make/uncaught_exception.h (original)
+++ lldb/trunk/test/make/uncaught_exception.h (removed)
@@ -1,5 +0,0 @@
-// MSVC header files have compilation issues when compiling with exceptions disabled.  Notably,
-// this function is compiled out when _HAS_EXCEPTIONS=0, but this function is called from another
-// place even when _HAS_EXCEPTIONS=0.  So we define a dummy implementation as a workaround and
-// force include this header file.
-static void *__uncaught_exception() { return nullptr; }

Modified: lldb/trunk/test/plugins/builder_base.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/builder_base.py?rev=232220&r1=232219&r2=232220&view=diff
==============================================================================
--- lldb/trunk/test/plugins/builder_base.py (original)
+++ lldb/trunk/test/plugins/builder_base.py Fri Mar 13 16:51:11 2015
@@ -12,7 +12,7 @@ Same idea holds for LLDB_ARCH environmen
 variable.
 """
 
-import os
+import os, sys
 import platform
 import lldbtest
 
@@ -78,8 +78,8 @@ def getCmdLine(d):
     # If d is None or an empty mapping, just return an empty string.
     if not d:
         return ""
-
-    cmdline = " ".join(["%s='%s'" % (k, v) for k, v in d.items()])
+    pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'"
+    cmdline = " ".join([pattern % (k, v) for k, v in d.items()])
 
     return cmdline
 





More information about the lldb-commits mailing list