Home | History | Annotate | Download | only in llvm-3.2
      1 # Copyright (C) 2013 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 TOOLCHAIN_NAME   := clang-3.2
     16 TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/
     17 LLVM_TRIPLE := le32-none-ndk
     18 
     19 # For sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/*/libsupc++.a
     20 TOOLCHAIN_VERSION := 4.7
     21 
     22 TARGET_CC := $(TOOLCHAIN_PREFIX)clang$(HOST_EXEEXT)
     23 TARGET_CXX := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
     24 TARGET_LD := $(TOOLCHAIN_PREFIX)clang++$(HOST_EXEEXT)
     25 TARGET_AR := $(TOOLCHAIN_PREFIX)llvm-ar$(HOST_EXEEXT)
     26 TARGET_STRIP := $(TOOLCHAIN_PREFIX)$(LLVM_TRIPLE)-strip$(HOST_EXEEXT)
     27 
     28 # Compiler runtime is determined in bc2native
     29 TARGET_LIBGCC :=
     30 
     31 BC2NATIVE := $(HOST_PYTHON) $(TOOLCHAIN_PREBUILT_ROOT)/bin/ndk-bc2native.py
     32 
     33 TARGET_CFLAGS := \
     34     -target $(LLVM_TRIPLE) \
     35     -emit-llvm \
     36     -ffunction-sections \
     37     -funwind-tables \
     38     -fPIC \
     39     -no-canonical-prefixes
     40 # -nostdlibinc
     41 
     42 #TARGET_CXXFLAGS := $(TARGET_CFLAGS) -fno-exceptions -fno-rtti
     43 
     44 # reset backend flags
     45 TARGET_NO_EXECUTE_CFLAGS :=
     46 
     47 # Add and LDFLAGS for the target here
     48 TARGET_LDFLAGS := \
     49     -target $(LLVM_TRIPLE) \
     50     -emit-llvm \
     51     -no-canonical-prefixes
     52 
     53 TARGET_C_INCLUDES := \
     54     $(SYSROOT_INC)/usr/include
     55 
     56 TARGET_release_CFLAGS := -O2 \
     57                          -g \
     58                          -DNDEBUG \
     59                          -fomit-frame-pointer \
     60                          -fstrict-aliasing
     61 
     62 TARGET_debug_CFLAGS := $(TARGET_release_CFLAGS) \
     63                        -O0 \
     64                        -UNDEBUG \
     65                        -fno-omit-frame-pointer \
     66                        -fno-strict-aliasing
     67 
     68 # This function will be called to determine the target CFLAGS used to build
     69 # a C or Assembler source file, based on its tags.
     70 #
     71 TARGET-process-src-files-tags = \
     72 $(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
     73 $(eval __release_sources := $(call get-src-files-without-tag,debug)) \
     74 $(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_debug_CFLAGS)) \
     75 $(call set-src-files-target-cflags, $(__release_sources),$(TARGET_release_CFLAGS)) \
     76 $(call set-src-files-text,$(LOCAL_SRC_FILES),bc$(space)$(space)) \
     77 
     78 ifeq ($(strip $(filter-out $(NDK_KNOWN_ABIS),$(TARGET_ARCH_ABI))),)
     79 
     80 define cmd-build-shared-library
     81 $(PRIVATE_CXX) \
     82     -Wl,-soname,$(notdir $(LOCAL_BUILT_MODULE)) \
     83     -shared \
     84     --sysroot=$(call host-path,$(PRIVATE_SYSROOT_LINK)) \
     85     $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
     86     $(PRIVATE_LDFLAGS) \
     87     $(PRIVATE_LDLIBS) \
     88     -o $(call host-path,$(LOCAL_BUILT_MODULE)) && \
     89     $(BC2NATIVE) \
     90     --ndk-dir=$(NDK_ROOT) \
     91     --abi=$(TARGET_ARCH_ABI) \
     92     --platform=$(TARGET_PLATFORM) \
     93     --file $(call host-path, $(LOCAL_BUILT_MODULE)) $(patsubst %.bc,%.so,$(call host-path,$(LOCAL_BUILT_MODULE)))
     94 endef
     95 
     96 define cmd-build-executable
     97 $(PRIVATE_CXX) \
     98     -Wl,--gc-sections \
     99     -Wl,-z,nocopyreloc \
    100     --sysroot=$(call host-path,$(PRIVATE_SYSROOT_LINK)) \
    101     $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
    102     $(PRIVATE_LDFLAGS) \
    103     $(PRIVATE_LDLIBS) \
    104     -o $(call host-path,$(LOCAL_BUILT_MODULE)) && \
    105     $(BC2NATIVE) \
    106     --ndk-dir=$(NDK_ROOT) \
    107     --abi=$(TARGET_ARCH_ABI) \
    108     --platform=$(TARGET_PLATFORM) \
    109     --file $(call host-path,$(LOCAL_BUILT_MODULE)) $(call host-path,$(LOCAL_BUILT_MODULE))
    110 endef
    111 
    112 endif
    113