diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt index d6a972e5a5..25bd921fcb 100644 --- a/lib/builtins/CMakeLists.txt +++ b/lib/builtins/CMakeLists.txt @@ -347,7 +347,7 @@ if (APPLE) add_subdirectory(Darwin-excludes) add_subdirectory(macho_embedded) darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS}) -elseif (NOT WIN32 OR MINGW) +else () foreach (arch ${BUILTIN_SUPPORTED_ARCH}) if (CAN_TARGET_${arch}) # Filter out generic versions of routines that are re-implemented in diff --git a/make/config.mk b/make/config.mk index 094fd160f9..0998aca0de 100644 --- a/make/config.mk +++ b/make/config.mk @@ -44,6 +44,6 @@ endif ### # Common compiler options COMMON_INCLUDES=-I${ProjSrcRoot}/lib -I${ProjSrcRoot}/include -COMMON_CXXFLAGS=-std=c++11 -fno-exceptions -fPIC -funwind-tables $(COMMON_INCLUDES) -COMMON_CFLAGS=-fPIC $(COMMON_INCLUDES) +COMMON_CXXFLAGS=-std=c++11 -fno-exceptions -funwind-tables $(COMMON_INCLUDES) +COMMON_CFLAGS=$(COMMON_INCLUDES) COMMON_ASMFLAGS=$(COMMON_INCLUDES) diff --git a/make/platform/clang_darwin.mk b/make/platform/clang_darwin.mk index dff26943be..ecee33c857 100644 --- a/make/platform/clang_darwin.mk +++ b/make/platform/clang_darwin.mk @@ -151,7 +151,7 @@ $(foreach config,$(Configs),\ override CC := $(subst -arch ,-arch_,$(CC)) override CC := $(patsubst -arch_%,,$(CC)) -CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer +CFLAGS := -fPIC -Wall -Werror -O3 -fomit-frame-pointer # Always set deployment target arguments for every build, these libraries should # never depend on the environmental overrides. We simply set them to minimum diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk index 7b109d56c0..534b04f169 100644 --- a/make/platform/clang_linux.mk +++ b/make/platform/clang_linux.mk @@ -67,7 +67,7 @@ endif ### -CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer +CFLAGS := -fPIC -Wall -Werror -O3 -fomit-frame-pointer CFLAGS.builtins-i386 := $(CFLAGS) -m32 CFLAGS.builtins-x86_64 := $(CFLAGS) -m64 diff --git a/make/platform/darwin_bni.mk b/make/platform/darwin_bni.mk index 8e066e8e31..56e3ba5730 100644 --- a/make/platform/darwin_bni.mk +++ b/make/platform/darwin_bni.mk @@ -29,7 +29,7 @@ ifneq (,$(SDKROOT)) DEPLOYMENT_FLAGS += -isysroot $(SDKROOT) endif -CFLAGS := -Wall -Os -fomit-frame-pointer -g $(DEPLOYMENT_FLAGS) +CFLAGS := -fPIC -Wall -Os -fomit-frame-pointer -g $(DEPLOYMENT_FLAGS) CFLAGS.Static := $(CFLAGS) -static DYLIB_FLAGS := $(DEPLOYMENT_FLAGS) \ -Xarch_arm -Wl,-alias_list,$(SRCROOT)/lib/builtins/arm/softfloat-alias.list diff --git a/make/platform/triple.mk b/make/platform/triple.mk new file mode 100644 index 0000000000..061faa7f96 --- /dev/null +++ b/make/platform/triple.mk @@ -0,0 +1,66 @@ +# This "platform" file is intended for building compiler-rt using gcc. +# The actual target platform is selected by setting the TargetTriple variable to the corresponding LLVM triple. + +Description := Static runtime libraries for platforms selected by 'TargetTriple' + +# Provide defaults for the required vars +ifndef CC + CC := gcc +endif +ifndef CFLAGS + CFLAGS := -Wall -O3 +endif + +Configs := builtins + +Arch := $(word 1,$(subst -, ,$(TargetTriple))) +ifeq ($(Arch),i686) + Arch := i386 +else ifeq ($(Arch),arm) +ifneq (,$(findstring ios,$(TargetTriple))) + Arch := armv7 +else ifneq (,$(findstring android,$(TargetTriple))) + Arch := armv7 +endif +endif + +# Filter out stuff that gcc cannot compile (these are only needed for clang-generated code anywasys). +CommonFunctions_gcc := $(filter-out atomic% enable_execute_stack,$(CommonFunctions)) + +# Filter out stuff which is not available on specific target +# For example, sync_fetch_and_add_4 uses Thumb instructions, which are unavailable +# when building for arm-linux-androideabi +ifeq ($(TargetTriple),arm-linux-androideabi) + ArchDisabledFunctions := \ + sync_fetch_and_add_4 \ + sync_fetch_and_sub_4 \ + sync_fetch_and_and_4 \ + sync_fetch_and_or_4 \ + sync_fetch_and_xor_4 \ + sync_fetch_and_nand_4 \ + sync_fetch_and_max_4 \ + sync_fetch_and_umax_4 \ + sync_fetch_and_min_4 \ + sync_fetch_and_umin_4 \ + sync_fetch_and_add_8 \ + sync_fetch_and_sub_8 \ + sync_fetch_and_and_8 \ + sync_fetch_and_or_8 \ + sync_fetch_and_xor_8 \ + sync_fetch_and_nand_8 \ + sync_fetch_and_max_8 \ + sync_fetch_and_umax_8 \ + sync_fetch_and_min_8 \ + sync_fetch_and_umin_8 +endif + +# Clear cache is builtin on aarch64-apple-ios +# arm64 and aarch64 are synonims, but iOS targets usually use arm64 (history reasons) +ifeq (aarch64-apple-ios,$(subst arm64,aarch64,$(TargetTriple))) +CommonDisabledFunctions := clear_cache +endif + +ArchEnabledFunctions := $(filter-out $(ArchDisabledFunctions),$(value ArchFunctions.$(Arch))) +CommonEnabledFunctions := $(filter-out $(CommonDisabledFunctions),$(CommonFunctions_gcc)) + +FUNCTIONS.builtins := $(CommonEnabledFunctions) $(ArchEnabledFunctions)