Index: test/lang/c/shared_lib/foo.h =================================================================== --- test/lang/c/shared_lib/foo.h +++ test/lang/c/shared_lib/foo.h @@ -6,7 +6,7 @@ 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); Index: test/lldbtest.py =================================================================== --- test/lldbtest.py +++ test/lldbtest.py @@ -1474,7 +1474,7 @@ '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")), Index: test/make/Makefile.rules =================================================================== --- test/make/Makefile.rules +++ test/make/Makefile.rules @@ -114,6 +114,7 @@ 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) @@ -148,6 +149,8 @@ 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 @@ -184,7 +187,6 @@ 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. @@ -373,6 +375,8 @@ #---------------------------------------------------------------------- # 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)" @@ -391,7 +395,7 @@ #---------------------------------------------------------------------- # 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. #---------------------------------------------------------------------- @@ -405,28 +409,36 @@ # 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 #---------------------------------------------------------------------- @@ -457,6 +469,10 @@ 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 #---------------------------------------------------------------------- Index: test/make/test_common.h =================================================================== --- /dev/null +++ test/make/test_common.h @@ -0,0 +1,20 @@ +// 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 ensures that it is +// declared. This may not be necessary after MSVC 12. +#include +#endif Index: test/make/uncaught_exception.h =================================================================== --- test/make/uncaught_exception.h +++ /dev/null @@ -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; } Index: test/plugins/builder_base.py =================================================================== --- test/plugins/builder_base.py +++ test/plugins/builder_base.py @@ -12,7 +12,7 @@ variable. """ -import os +import os, sys import platform import lldbtest @@ -78,8 +78,8 @@ # 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