diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/make')
-rw-r--r-- | packages/Python/lldbsuite/test/make/Android.rules | 91 | ||||
-rw-r--r-- | packages/Python/lldbsuite/test/make/Makefile.rules | 81 | ||||
-rw-r--r-- | packages/Python/lldbsuite/test/make/pseudo_barrier.h | 20 | ||||
-rw-r--r-- | packages/Python/lldbsuite/test/make/test_common.h | 39 |
4 files changed, 155 insertions, 76 deletions
diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules new file mode 100644 index 000000000000..3e6a093f4bae --- /dev/null +++ b/packages/Python/lldbsuite/test/make/Android.rules @@ -0,0 +1,91 @@ +NDK_ROOT := $(shell dirname $(CC))/../../../../.. + +ifeq "$(findstring 64, $(ARCH))" "64" + # lowest 64-bit API level + API_LEVEL := 21 +else ifeq "$(ARCH)" "i386" + # clone(2) declaration is present only since this api level + API_LEVEL := 17 +else + # lowest supported 32-bit API level + API_LEVEL := 9 +endif + +ifeq "$(ARCH)" "arm" + SYSROOT_ARCH := arm + STL_ARCH := armeabi-v7a + TRIPLE := armv7-none-linux-androideabi + ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm +else ifeq "$(ARCH)" "aarch64" + SYSROOT_ARCH := arm64 + TRIPLE := aarch64-none-linux-android + STL_ARCH := arm64-v8a +else ifeq "$(ARCH)" "i386" + SYSROOT_ARCH := x86 + STL_ARCH := x86 + TRIPLE := i686-none-linux-android +else ifeq "$(ARCH)" "mips64r6" + SYSROOT_ARCH := mips64 + STL_ARCH := mips64 + TRIPLE := mips64el-none-linux-android +else ifeq "$(ARCH)" "mips32" + SYSROOT_ARCH := mips + STL_ARCH := mips + TRIPLE := mipsel-none-linux-android +else + SYSROOT_ARCH := $(ARCH) + STL_ARCH := $(ARCH) + TRIPLE := $(ARCH)-none-linux-android +endif + +ifeq "$(findstring 86,$(ARCH))" "86" + TOOLCHAIN_DIR := $(STL_ARCH)-4.9 +else ifeq "$(ARCH)" "arm" + TOOLCHAIN_DIR := arm-linux-androideabi-4.9 +else + TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9 +endif + +ifeq "$(ARCH)" "arm" + TOOL_PREFIX := arm-linux-androideabi +else + TOOL_PREFIX := $(subst -none,,$(TRIPLE)) +endif + +ifeq "$(HOST_OS)" "Linux" + HOST_TAG := linux-x86_64 +else ifeq "$(HOST_OS)" "Darwin" + HOST_TAG := darwin-x86_64 +else + HOST_TAG := windows-x86_64 +endif + +GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG) + +OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy + +ifeq "$(findstring clang,$(CC))" "clang" + ARCH_CFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN) + ARCH_LDFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN) +endif + +ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) +ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm + +ifeq (1,$(USE_LIBCPP)) + ARCH_CFLAGS += \ + -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ + -isystem $(NDK_ROOT)/sources/android/support/include \ + -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include + + ARCH_LDFLAGS += \ + -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ + $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a +else + ARCH_CFLAGS += \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward + + ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a +endif diff --git a/packages/Python/lldbsuite/test/make/Makefile.rules b/packages/Python/lldbsuite/test/make/Makefile.rules index 5abbc85e649b..a7b94ef57380 100644 --- a/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/packages/Python/lldbsuite/test/make/Makefile.rules @@ -32,10 +32,26 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../ #---------------------------------------------------------------------- +# If OS is not defined, use 'uname -s' to determine the OS name. +# +# uname on Windows gives "windows32", but most environments standardize +# on "Windows_NT", so we'll make it consistent here. When running +# tests from Visual Studio, the environment variable isn't inherited +# all the way down to the process spawned for make. +#---------------------------------------------------------------------- +HOST_OS = $(shell uname -s) +ifeq "$(HOST_OS)" "windows32" + HOST_OS = Windows_NT +endif +ifeq "$(OS)" "" + OS = $(HOST_OS) +endif + +#---------------------------------------------------------------------- # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more # from the triple alone #---------------------------------------------------------------------- -TRIPLE_CFLAGS := +ARCH_CFLAGS := ifneq "$(TRIPLE)" "" triple_space = $(subst -, ,$(TRIPLE)) ARCH =$(word 1, $(triple_space)) @@ -52,33 +68,20 @@ ifneq "$(TRIPLE)" "" ifeq "$(TRIPLE_VERSION)" "" TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') endif - TRIPLE_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" + ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" else SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path) ifeq "$(TRIPLE_VERSION)" "" TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/') endif - TRIPLE_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" + ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)" endif endif endif endif endif - -#---------------------------------------------------------------------- -# If OS is not defined, use 'uname -s' to determine the OS name. -# -# uname on Windows gives "windows32", but most environments standardize -# on "Windows_NT", so we'll make it consistent here. When running -# tests from Visual Studio, the environment variable isn't inherited -# all the way down to the process spawned for make. -#---------------------------------------------------------------------- -HOST_OS = $(shell uname -s) -ifeq "$(HOST_OS)" "windows32" - HOST_OS = Windows_NT -endif -ifeq "$(OS)" "" - OS = $(HOST_OS) +ifeq "$(OS)" "Android" + include $(THIS_FILE_DIR)/Android.rules endif #---------------------------------------------------------------------- @@ -199,13 +202,13 @@ else CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include endif -CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS) +CFLAGS += -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) $(ARCH_CFLAGS) # Use this one if you want to build one part of the result without debug information: ifeq "$(OS)" "Darwin" - CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) + CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS) else - CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS) + CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS) endif ifeq "$(MAKE_DWO)" "YES" @@ -221,7 +224,7 @@ CXXFLAGS += -std=c++11 CXXFLAGS += $(subst -fmodules,, $(CFLAGS)) LD = $(CC) LDFLAGS ?= $(CFLAGS) -LDFLAGS += $(LD_EXTRAS) +LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS) ifeq (,$(filter $(OS), Windows_NT Android)) ifneq (,$(filter YES,$(ENABLE_THREADS))) LDFLAGS += -pthread @@ -297,10 +300,12 @@ ifeq "$(OS)" "Windows_NT" # Clang for Windows doesn't support C++ Exceptions CXXFLAGS += -fno-exceptions CXXFLAGS += -D_HAS_EXCEPTIONS=0 - ifeq "$(VisualStudioVersion)" "14.0" - CXXFLAGS += -fms-compatibility-version=19.0 - override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS)) - endif + + # MSVC 2015 or higher is required, which depends on c++14, so + # append these values unconditionally. + CXXFLAGS += -fms-compatibility-version=19.0 + override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS)) + # The MSVC linker doesn't understand long section names # generated by the clang compiler. LDFLAGS += -fuse-ld=lld @@ -319,19 +324,21 @@ ifeq (1,$(USE_LIBSTDCPP)) endif ifeq (1,$(USE_LIBCPP)) - # Clang requires an extra flag: -stdlib=libstdc++ - ifneq (,$(findstring clang,$(CC))) - ifeq "$(OS)" "Linux" - # This is the default install location on Ubuntu 14.04 - ifneq ($(wildcard /usr/include/c++/v1/.),) - CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP - LDFLAGS += -stdlib=libc++ - CXXFLAGS += -I/usr/include/c++/v1 - endif - else - CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP + CXXFLAGS += -DLLDB_USING_LIBCPP + ifeq "$(OS)" "Linux" + ifneq (,$(findstring clang,$(CC))) + CXXFLAGS += -stdlib=libc++ LDFLAGS += -stdlib=libc++ + else + CXXFLAGS += -isystem /usr/include/c++/v1 + LDFLAGS += -lc++ endif + else ifeq "$(OS)" "Android" + # Nothing to do, this is already handled in + # Android.rules. + else + CXXFLAGS += -stdlib=libc++ + LDFLAGS += -stdlib=libc++ endif endif diff --git a/packages/Python/lldbsuite/test/make/pseudo_barrier.h b/packages/Python/lldbsuite/test/make/pseudo_barrier.h new file mode 100644 index 000000000000..592000ddea4d --- /dev/null +++ b/packages/Python/lldbsuite/test/make/pseudo_barrier.h @@ -0,0 +1,20 @@ +#include <atomic> + +// Note that although hogging the CPU while waiting for a variable to change +// would be terrible in production code, it's great for testing since it +// avoids a lot of messy context switching to get multiple threads synchronized. + +typedef std::atomic<int> pseudo_barrier_t; +#define pseudo_barrier_wait(barrier) \ + do \ + { \ + --(barrier); \ + while ((barrier).load() > 0) \ + ; \ + } while (0) + +#define pseudo_barrier_init(barrier, count) \ + do \ + { \ + (barrier) = (count); \ + } while (0) diff --git a/packages/Python/lldbsuite/test/make/test_common.h b/packages/Python/lldbsuite/test/make/test_common.h index 575ca62c2fc0..529d0952ed3e 100644 --- a/packages/Python/lldbsuite/test/make/test_common.h +++ b/packages/Python/lldbsuite/test/make/test_common.h @@ -10,14 +10,6 @@ #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 - #if defined(_WIN32) #define LLVM_PRETTY_FUNCTION __FUNCSIG__ #else @@ -53,34 +45,3 @@ #define lldb_enable_attach() #endif - -#if defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP) - -// on Darwin, libstdc++ is missing <atomic>, so this would cause any test to fail building -// since this header file is being included in every C-family test case, we need to not include it -// on Darwin, most tests use libc++ by default, so this will only affect tests that explicitly require libstdc++ - -#else -#ifdef __cplusplus -#include <atomic> - -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. - -typedef std::atomic<int> pseudo_barrier_t; -#define pseudo_barrier_wait(barrier) \ - do \ - { \ - --(barrier); \ - while ((barrier).load() > 0) \ - ; \ - } while (0) - -#define pseudo_barrier_init(barrier, count) \ - do \ - { \ - (barrier) = (count); \ - } while (0) -#endif // __cplusplus -#endif // defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP) |