Home | History | Annotate | Download | only in platform
      1 Description := Static runtime libraries for clang/Linux.
      2 
      3 ###
      4 
      5 CC := clang
      6 Arch := unknown
      7 Configs :=
      8 
      9 # We don't currently have any general purpose way to target architectures other
     10 # than the compiler defaults (because there is no generalized way to invoke
     11 # cross compilers). For now, we just find the target architecture of the
     12 # compiler and only define configurations we know that compiler can generate.
     13 CompilerTargetTriple := $(shell \
     14 	LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2)
     15 ifeq ($(CompilerTargetTriple),)
     16 $(error "unable to infer compiler target triple for $(CC)")
     17 endif
     18 
     19 # Only define configs if we detected a linux target.
     20 ifneq ($(findstring -linux-,$(CompilerTargetTriple)),)
     21 
     22 # Define configs only if arch in triple is i386 or x86_64
     23 CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple)))
     24 ifeq ($(call contains,i386 x86_64,$(CompilerTargetArch)),true)
     25 
     26 # TryCompile compiler source flags
     27 # Returns exit code of running a compiler invocation.
     28 TryCompile = \
     29   $(shell \
     30     cflags=""; \
     31     for flag in $(3); do \
     32       cflags="$$cflags $$flag"; \
     33     done; \
     34     $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \
     35     echo $$?)
     36 
     37 test_source = $(ProjSrcRoot)/make/platform/clang_linux_test_input.c
     38 ifeq ($(CompilerTargetArch),i386)
     39   SupportedArches := i386
     40   ifeq ($(call TryCompile,$(CC),$(test_source),-m64),0)
     41     SupportedArches += x86_64
     42   endif
     43 else
     44   SupportedArches := x86_64
     45   ifeq ($(call TryCompile,$(CC),$(test_source),-m32),0)
     46     SupportedArches += i386
     47   endif
     48 endif
     49 
     50 # Build runtime libraries for i386.
     51 ifeq ($(call contains,$(SupportedArches),i386),true)
     52 Configs += builtins-i386 profile-i386
     53 Arch.builtins-i386 := i386
     54 Arch.profile-i386 := i386
     55 endif
     56 
     57 # Build runtime libraries for x86_64.
     58 ifeq ($(call contains,$(SupportedArches),x86_64),true)
     59 Configs += builtins-x86_64 profile-x86_64
     60 Arch.builtins-x86_64 := x86_64
     61 Arch.profile-x86_64 := x86_64
     62 endif
     63 
     64 endif
     65 
     66 endif
     67 
     68 ###
     69 
     70 CFLAGS := -Wall -Werror -O3 -fomit-frame-pointer
     71 
     72 CFLAGS.builtins-i386 := $(CFLAGS) -m32
     73 CFLAGS.builtins-x86_64 := $(CFLAGS) -m64
     74 CFLAGS.profile-i386 := $(CFLAGS) -m32
     75 CFLAGS.profile-x86_64 := $(CFLAGS) -m64
     76 
     77 FUNCTIONS.builtins-i386 := $(CommonFunctions) $(ArchFunctions.i386)
     78 FUNCTIONS.builtins-x86_64 := $(CommonFunctions) $(ArchFunctions.x86_64)
     79 FUNCTIONS.profile-i386 := GCDAProfiling InstrProfiling InstrProfilingBuffer \
     80                           InstrProfilingFile InstrProfilingPlatformOther \
     81                           InstrProfilingRuntime InstrProfilingUtil \
     82                           InstrProfilingWriter InstrProfilingValue \
     83                           InstrProfilingMerge InstrProfilingMergeFile
     84 FUNCTIONS.profile-x86_64 := $(FUNCTIONS.profile-i386)
     85 
     86 # Always use optimized variants.
     87 OPTIMIZED := 1
     88 
     89 # We don't need to use visibility hidden on Linux.
     90 VISIBILITY_HIDDEN := 0
     91 
     92 SHARED_LIBRARY_SUFFIX := so
     93