Index: runtime/compiler-rt/Makefile =================================================================== --- runtime/compiler-rt/Makefile +++ runtime/compiler-rt/Makefile @@ -121,13 +121,29 @@ $(1) $$cflags $(2) -o /dev/null > /dev/null 2> /dev/null ; \ echo $$?) +# Finding CompilerTargetArch copied from clang_linux.mk +CompilerTargetTriple := $(shell \ + LANG=C $(CC) -v 2>&1 | grep 'Target:' | cut -d' ' -f2) +ifeq ($(CompilerTargetTriple),) +$(error "unable to infer compiler target triple for $(CC)") +endif + +# Define configs only if arch in triple is i386 or x86_64 +CompilerTargetArch := $(firstword $(subst -, ,$(CompilerTargetTriple))) + # We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts. -Runtime32BitConfigs = \ +Runtime32Bit-i386Configs = \ builtins-i386.a profile-i386.a +Runtime32Bit-i686Configs = \ + builtins-i686.a profile-i686.a # We currently only try to generate runtime libraries on x86. ifeq ($(ARCH),x86) -RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs) +ifeq ($(CompilerTargetArch), i386) +RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs) +else ifeq ($(CompilerTargetArch), i686) +RuntimeLibrary.linux.Configs += $(Runtime32Bit-i686Configs) +endif endif ifeq ($(ARCH),x86_64) @@ -139,7 +155,7 @@ # executable. test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0) -RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs) +RuntimeLibrary.linux.Configs += $(Runtime32Bit-i386Configs) endif endif