1# Copyright (C) 2011 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 15LOCAL_PATH:= $(call my-dir) 16 17ifeq ($(TARGET_ARCH),arm) 18 arch := arm 19else ifeq ($(TARGET_ARCH),x86) 20 arch := x86 21endif 22ifdef arch 23 24common_cflags := \ 25 -Wall -Wno-deprecated -fno-exceptions -fno-stack-protector \ 26 -DTS_VALGRIND=1 \ 27 -DTS_VERSION=\"exported\" \ 28 -DVGA_$(arch)=1 \ 29 -DVGO_linux=1 \ 30 -DVGP_$(arch)_linux=1 \ 31 -DVG_PLATFORM=\"$(arch)-linux\" \ 32 -D_STLP_NO_IOSTREAMS=1 33 34common_includes := \ 35 external/valgrind/main \ 36 external/valgrind/main/include \ 37 external/valgrind/main/VEX/pub \ 38 external/valgrind/dynamic_annotations 39 40ifeq ($(TARGET_ARCH),arm) 41tool_ldflags := -static -Wl,--build-id=none,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -u _start -e_start 42else 43tool_ldflags := -static -Wl,-Ttext=0x38000000 -nodefaultlibs -nostartfiles -u _start -e_start 44endif 45 46preload_ldflags := -nodefaultlibs -Wl,-z,interpose,-z,initfirst 47# Remove this when the all toolchains are GCC 4.4 48ifeq ($(TARGET_ARCH),arm) 49 preload_ldflags += -Wl,--icf=none 50endif 51 52# TODO(eugenis): Add ts_event_names.h generation step 53 54# Build tsan-$(arch)-linux 55include $(CLEAR_VARS) 56 57LOCAL_MODULE := tsan-$(arch)-linux 58LOCAL_MODULE_TAGS := optional 59LOCAL_MODULE_CLASS := SHARED_LIBRARIES 60LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind 61LOCAL_ARM_MODE := arm 62LOCAL_FORCE_STATIC_EXECUTABLE := true 63LOCAL_NO_CRT := true 64LOCAL_SYSTEM_SHARED_LIBRARIES := 65LOCAL_CPP_EXTENSION := .cc 66LOCAL_SRC_FILES := \ 67 thread_sanitizer.cc \ 68 ts_valgrind.cc \ 69 ts_valgrind_libc.cc \ 70 ts_util.cc \ 71 suppressions.cc \ 72 ignore.cc \ 73 common_util.cc \ 74 ts_race_verifier.cc 75LOCAL_C_INCLUDES := \ 76 bionic \ 77 external/stlport/stlport \ 78 $(common_includes) 79LOCAL_LDFLAGS := $(tool_ldflags) 80LOCAL_CFLAGS := $(common_cflags) 81LOCAL_CXXFLAGS := $(common_cxxflags) 82LOCAL_RTTI_FLAG := -fno-rtti 83LOCAL_STATIC_LIBRARIES := libcoregrind-$(arch)-linux libvex-$(arch)-linux 84 85include $(BUILD_EXECUTABLE) 86 87 88# Build vgpreload_tsan-$(arch)-linux.so 89include $(CLEAR_VARS) 90 91LOCAL_MODULE := vgpreload_tsan-$(arch)-linux 92LOCAL_MODULE_TAGS := optional 93LOCAL_MODULE_CLASS := SHARED_LIBRARIES 94LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/valgrind 95LOCAL_ARM_MODE := arm 96LOCAL_STRIP_MODULE := false 97LOCAL_NO_CRT := true 98LOCAL_PRELINK_MODULE := false 99LOCAL_SRC_FILES := \ 100 ts_valgrind_intercepts.c 101LOCAL_C_INCLUDES := $(common_includes) 102LOCAL_LDFLAGS := $(preload_ldflags) 103LOCAL_CFLAGS := $(common_cflags) 104LOCAL_RTTI_FLAG := -fno-rtti 105 106include $(BUILD_SHARED_LIBRARY) 107 108endif 109