Make Clang host builds hermetic on Linux.

This lays the groundwork for making builds hermetic on Darwin as well.
That will be fixed in a future patch.

bug 13435344

Change-Id: Iae82d0b9efad0598d682ff5fd4daa737aa607866
This commit is contained in:
Tim Murray 2014-03-20 13:48:35 -07:00
parent 8c1bbdb96e
commit 02cefc93a8
6 changed files with 82 additions and 10 deletions

View File

@ -1,8 +1,13 @@
include $(BUILD_SYSTEM)/clang/x86.mk
include $(BUILD_SYSTEM)/clang/x86_common.mk
ifeq ($(HOST_OS),linux)
CLANG_CONFIG_x86_HOST_TRIPLE := i686-linux-gnu
CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
endif
ifeq ($(HOST_OS),darwin)
CLANG_CONFIG_x86_HOST_TRIPLE := i686-apple-darwin
@ -15,25 +20,29 @@ CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS := \
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
$(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
-target $(CLANG_CONFIG_x86_HOST_TRIPLE) \
$(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS) \
-target $(CLANG_CONFIG_x86_HOST_TRIPLE)
CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS := \
$(CLANG_CONFIG_EXTRA_CFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS)
CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS := \
$(CLANG_CONFIG_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS) \
-target $(CLANG_CONFIG_x86_HOST_TRIPLE)
CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS := \
$(CLANG_CONFIG_EXTRA_LDFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
$(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
-target $(CLANG_CONFIG_x86_HOST_TRIPLE) \
$(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS) \
-target $(CLANG_CONFIG_x86_HOST_TRIPLE)
define convert-to-host-clang-flags
$(strip \

View File

@ -1,8 +1,13 @@
include $(BUILD_SYSTEM)/clang/x86_64.mk
include $(BUILD_SYSTEM)/clang/x86_common.mk
ifeq ($(HOST_OS),linux)
CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-linux-gnu
CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
endif
ifeq ($(HOST_OS),darwin)
CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-apple-darwin
@ -15,25 +20,29 @@ CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS := \
$(CLANG_CONFIG_EXTRA_ASFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
$(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
-target $(CLANG_CONFIG_x86_64_HOST_TRIPLE) \
$(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS) \
-target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS := \
$(CLANG_CONFIG_EXTRA_CFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS) \
$(CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS)
CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS := \
$(CLANG_CONFIG_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
$(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS) \
-target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS := \
$(CLANG_CONFIG_EXTRA_LDFLAGS) \
$(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
$(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
-target $(CLANG_CONFIG_x86_64_HOST_TRIPLE) \
$(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS) \
-target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
define convert-to-host-clang-flags
$(strip \

View File

@ -38,10 +38,10 @@ CLANG_CONFIG_UNKNOWN_CFLAGS := \
-Wno-unused-but-set-parameter
# Clang flags for all host rules
CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
CLANG_CONFIG_HOST_EXTRA_ASFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG)
CLANG_CONFIG_HOST_EXTRA_CFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG)
CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG)
CLANG_CONFIG_HOST_EXTRA_LDFLAGS := --gcc-toolchain=$(HOST_TOOLCHAIN_FOR_CLANG)
# Clang flags for all target rules
CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
@ -50,7 +50,11 @@ CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
# HOST config
ifneq ($(strip $(BUILD_HOST_64bit)),)
include $(BUILD_SYSTEM)/clang/HOST_x86_64.mk
else
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
endif
# TARGET config
clang_2nd_arch_prefix :=

42
core/clang/x86_common.mk Normal file
View File

@ -0,0 +1,42 @@
ifeq ($(HOST_OS),darwin)
# nothing required here yet
endif
ifeq ($(HOST_OS),linux)
ifneq ($(strip $(BUILD_HOST_64bit)),)
# Needs to be updated along with gcc
HOST_ARCH_DESCRIPTOR_FOR_CLANG := x86_64-linux
else
# Needs to be updated along with gcc
HOST_ARCH_DESCRIPTOR_FOR_CLANG := i686-linux
endif
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS := \
--sysroot=$(HOST_TOOLCHAIN_FOR_CLANG)/sysroot
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS :=
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \
--sysroot=$(HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-isystem $(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/include/c++/4.6.x-google \
-isystem $(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/include/c++/4.6.x-google/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG) \
-isystem $(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/include/c++/4.6.x-google/backward \
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \
--sysroot=$(HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-B$(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/bin \
-B$(HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/4.6.x-google \
-L$(HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/4.6.x-google
ifneq ($(strip $(BUILD_HOST_64bit)),)
# need to add lib64 if building 64-bit, otherwise lib
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS += -L$(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/lib64/
else
CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS += -L$(HOST_TOOLCHAIN_FOR_CLANG)/$(HOST_ARCH_DESCRIPTOR_FOR_CLANG)/lib/
endif
endif # linux
ifeq ($(HOST_OS),windows)
# nothing required here yet
endif

View File

@ -156,3 +156,7 @@ endef
define get-file-size
stat -f "%z" $(1)
endef
# gcc location for clang; to be updated when clang is updated
# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT)

View File

@ -41,10 +41,14 @@ ifneq ($(strip $(BUILD_HOST_64bit)),)
# which can benefit from 64-bit host arch.
HOST_GLOBAL_CFLAGS += -m64 -Wa,--noexecstack
HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack
# gcc location for clang; to be updated when clang is updated
HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/
else
# We expect SSE3 floating point math.
HOST_GLOBAL_CFLAGS += -mstackrealign -msse3 -mfpmath=sse -m32 -Wa,--noexecstack
HOST_GLOBAL_LDFLAGS += -m32 -Wl,-z,noexecstack
# gcc location for clang; to be updated when clang is updated
HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/
endif # BUILD_HOST_64bit
ifneq ($(strip $(BUILD_HOST_static)),)