[llvm-commits] [compiler-rt] r165504 - in /compiler-rt/trunk/make/platform: clang_linux.mk clang_linux_test_input.c
Alexey Samsonov
samsonov at google.com
Tue Oct 9 09:05:50 PDT 2012
Author: samsonov
Date: Tue Oct 9 11:05:50 2012
New Revision: 165504
URL: http://llvm.org/viewvc/llvm-project?rev=165504&view=rev
Log:
Determine supported archs for compiler-rt libraries on Linux by trying to compile a simple executable
Added:
compiler-rt/trunk/make/platform/clang_linux_test_input.c
Modified:
compiler-rt/trunk/make/platform/clang_linux.mk
Modified: compiler-rt/trunk/make/platform/clang_linux.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_linux.mk?rev=165504&r1=165503&r2=165504&view=diff
==============================================================================
--- compiler-rt/trunk/make/platform/clang_linux.mk (original)
+++ compiler-rt/trunk/make/platform/clang_linux.mk Tue Oct 9 11:05:50 2012
@@ -18,43 +18,56 @@
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.
+# 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 += full-i386 full-x86_64
-Arch.full-i386 := i386
-Arch.full-x86_64 := x86_64
-endif
-# Configuration for profile runtime.
-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
+# 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 $$?)
-# Configuration for ASAN runtime.
+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
###
Added: compiler-rt/trunk/make/platform/clang_linux_test_input.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_linux_test_input.c?rev=165504&view=auto
==============================================================================
--- compiler-rt/trunk/make/platform/clang_linux_test_input.c (added)
+++ compiler-rt/trunk/make/platform/clang_linux_test_input.c Tue Oct 9 11:05:50 2012
@@ -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(){}
More information about the llvm-commits
mailing list