diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-10-09 16:05:50 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-10-09 16:05:50 +0000 |
commit | 48154ece07a13072d2ee72d6796e2604cf40545e (patch) | |
tree | 84a18f0464b64f72a0418133b59f294526a4deb1 /make | |
parent | 35b661425ad452520544863f1b1afae961e6a92e (diff) | |
download | compiler-rt-48154ece07a13072d2ee72d6796e2604cf40545e.tar.gz compiler-rt-48154ece07a13072d2ee72d6796e2604cf40545e.tar.bz2 compiler-rt-48154ece07a13072d2ee72d6796e2604cf40545e.tar.xz |
Determine supported archs for compiler-rt libraries on Linux by trying to compile a simple executable
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'make')
-rw-r--r-- | make/platform/clang_linux.mk | 59 | ||||
-rw-r--r-- | make/platform/clang_linux_test_input.c | 4 |
2 files changed, 40 insertions, 23 deletions
diff --git a/make/platform/clang_linux.mk b/make/platform/clang_linux.mk index 638707f3..770a551b 100644 --- a/make/platform/clang_linux.mk +++ b/make/platform/clang_linux.mk @@ -18,43 +18,56 @@ $(error "unable to infer compiler target triple for $(CC)") endif endif -CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple))) - # Only define configs if we detected a linux target. ifneq ($(findstring -linux-,$(CompilerTargetTriple)),) -# Configurations which just include all the runtime functions. -ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true) -Configs += full-i386 full-x86_64 -Arch.full-i386 := i386 -Arch.full-x86_64 := x86_64 -endif - -# Configuration for profile runtime. +# Define configs only if arch in triple is i386 or x86_64 +CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple))) ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true) -Configs += profile-i386 profile-x86_64 -Arch.profile-i386 := i386 -Arch.profile-x86_64 := x86_64 -endif -# Configuration for ASAN runtime. +# TryCompile compiler source flags +# Returns exit code of running a compiler invocation. +TryCompile = \ + $(shell \ + cflags=""; \ + for flag in $(3); do \ + cflags="$$cflags $$flag"; \ + done; \ + $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \ + echo $$?) + +test_source = $(ProjSrcRoot)/make/platform/clang_linux_test_input.c ifeq ($(CompilerTargetArch),i386) -Configs += asan-i386 -Arch.asan-i386 := i386 + SupportedArches := i386 + ifeq ($(call TryCompile,$(CC),$(test_source),-m64),0) + SupportedArches += x86_64 + endif +else + SupportedArches := x86_64 + ifeq ($(call TryCompile,$(CC),$(test_source),-m32),0) + SupportedArches += i386 + endif endif -ifeq ($(CompilerTargetArch),x86_64) -Configs += asan-i386 asan-x86_64 + +# Build runtime libraries for i386. +ifeq ($(call contains,$(SupportedArches),i386),true) +Configs += full-i386 profile-i386 asan-i386 +Arch.full-i386 := i386 +Arch.profile-i386 := i386 Arch.asan-i386 := i386 -Arch.asan-x86_64 := x86_64 endif -# Configuration for TSAN runtime. -ifeq ($(CompilerTargetArch),x86_64) -Configs += tsan-x86_64 +# Build runtime libraries for x86_64. +ifeq ($(call contains,$(SupportedArches),x86_64),true) +Configs += full-x86_64 profile-x86_64 asan-x86_64 tsan-x86_64 +Arch.full-x86_64 := x86_64 +Arch.profile-x86_64 := x86_64 +Arch.asan-x86_64 := x86_64 Arch.tsan-x86_64 := x86_64 endif endif +endif ### diff --git a/make/platform/clang_linux_test_input.c b/make/platform/clang_linux_test_input.c new file mode 100644 index 00000000..e65ce986 --- /dev/null +++ b/make/platform/clang_linux_test_input.c @@ -0,0 +1,4 @@ +// This file is used to check if we can produce working executables +// for i386 and x86_64 archs on Linux. +#include <stdlib.h> +int main(){} |