[coreboot-gerrit] New patch to review for coreboot: 9233f12 build: Corrent compiler-rt linkage for clang builds
Edward O'Callaghan (eocallaghan@alterapraxis.com)
gerrit at coreboot.org
Thu May 22 08:08:59 CEST 2014
Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5811
-gerrit
commit 9233f12f7bbe6f9b44f2ea5d4f5dea2f7c68831b
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date: Thu May 22 15:59:45 2014 +1000
build: Corrent compiler-rt linkage for clang builds
i.) Drop the libgcc runtime wrapping work-around in Clang builds.
ii.) Find -lclang_rt.i386 path via a upstream patch instead of using
-rtlib=compiler-rt The primary problem here is that when -target is
passed to the clang driver it attempts to use gcc as a frontend to
the linker i386-elf-ld from binutils, however gcc does not know anything
about clang's -rtlib argument. This is a bug in clang's tooling,
conversely clang currently offers no equivalent to
-print-libgcc-file-name for compiler-rt to enquiry the path to directly
give to the linker.
iii.) Pass the correct linker flags -Wl,--divide
Change-Id: Iba675ef7b3ec7419e62ed169434599602e08a0b4
Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
Makefile | 1 +
src/arch/x86/Makefile.inc | 8 ++++----
src/lib/Makefile.inc | 5 ++++-
toolchain.inc | 3 +++
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index cc2d27c..c4e3486 100644
--- a/Makefile
+++ b/Makefile
@@ -222,6 +222,7 @@ printall:
@echo allsrcs=$(allsrcs)
@echo DEPENDENCIES=$(DEPENDENCIES)
@echo LIBGCC_FILE_NAME=$(LIBGCC_FILE_NAME_$(class))
+ @echo LIBCLANG_RT_FILE_NAME=$(LIBCLANG_RT_FILE_NAME_$(class))
@$(foreach class,$(special-classes),echo $(class):='$($(class))'; )
endif
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index d560838..251471b 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -30,7 +30,7 @@ subdirs-y += smp
ifeq ($(CONFIG_COMPILER_GCC),y)
DISASSEMBLY=-Wa,-acdlns
else
-DISASSEMBLY=
+DISASSEMBLY=-Wa,--divide
endif
OPTION_TABLE_H:=
@@ -209,7 +209,7 @@ romstage-libs ?=
$(objcbfs)/romstage_null.debug: $$(romstage-objs) $(objgenerated)/romstage_null.ld $$(romstage-libs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
- $(LD_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --start-group $(romstage-objs) $(romstage-libs) $(LIBGCC_FILE_NAME_romstage) --end-group -T $(objgenerated)/romstage_null.ld
+ $(LD_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) --start-group $(romstage-objs) $(romstage-libs) $(LIBCLANG_RT_FILE_NAME_romstage) --end-group -T $(objgenerated)/romstage_null.ld
else
$(CC_romstage) $(CFLAGS_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/romstage_null.ld -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(romstage-objs) $(romstage-libs) $(LIBGCC_FILE_NAME_romstage) -Wl,--end-group
endif
@@ -221,7 +221,7 @@ endif
$(objcbfs)/romstage_xip.debug: $$(romstage-objs) $(objgenerated)/romstage_xip.ld $$(romstage-libs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
- $(LD_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --start-group $(romstage-objs) $(romstage-libs) $(LIBGCC_FILE_NAME_romstage) --end-group -T $(objgenerated)/romstage_xip.ld
+ $(LD_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) --start-group $(romstage-objs) $(romstage-libs) $(LIBCLANG_RT_FILE_NAME_romstage) --end-group -T $(objgenerated)/romstage_xip.ld
else
$(CC_romstage) $(CFLAGS_romstage) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(objgenerated)/romstage_xip.ld -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(romstage-objs) $(romstage-libs) $(LIBGCC_FILE_NAME_romstage) -Wl,--end-group
endif
@@ -332,7 +332,7 @@ endif
$(objgenerated)/ramstage.o: $$(ramstage-objs) $(LIBGCC_FILE_NAME_ramstage) $$(ramstage-libs)
@printf " CC $(subst $(obj)/,,$(@))\n"
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
- $(LD_ramstage) -m elf_i386 -r -o $@ --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --start-group $(ramstage-objs) $(ramstage-libs) $(LIBGCC_FILE_NAME_ramstage) --end-group
+ $(LD_ramstage) -m elf_i386 -r -o $@ --start-group $(ramstage-objs) $(ramstage-libs) $(LIBCLANG_RT_FILE_NAME_ramstage) --end-group
else
$(CC_ramstage) $(CFLAGS_ramstage) -nostdlib -r -o $@ -Wl,--wrap,__divdi3 -Wl,--wrap,__udivdi3 -Wl,--wrap,__moddi3 -Wl,--wrap,__umoddi3 -Wl,--start-group $(ramstage-objs) $(ramstage-libs) $(LIBGCC_FILE_NAME_ramstage) -Wl,--end-group
endif
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index f82a3fa..3e8cf7a 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -36,7 +36,11 @@ romstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
endif
romstage-y += compute_ip_checksum.c
+
+ifneq ($(CONFIG_COMPILER_LLVM_CLANG),y)
romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c
+ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
+endif
ramstage-y += hardwaremain.c
ramstage-y += selfboot.c
@@ -54,7 +58,6 @@ ramstage-y += cbfs.c
ramstage-y += lzma.c
#ramstage-y += lzmadecode.c
ramstage-y += stack.c
-ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
ramstage-y += clog2.c
romstage-y += clog2.c
ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
diff --git a/toolchain.inc b/toolchain.inc
index 2375f17..4c97f05 100644
--- a/toolchain.inc
+++ b/toolchain.inc
@@ -98,7 +98,10 @@ READELF_$(1) := $(READELF_$(2))
CFLAGS_$(1) = $$(CFLAGS_common) $$(CFLAGS_$(2))
CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2))
LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) $(CFLAGS_$(2)) -print-libgcc-file-name))
+LIBCLANG_RT_FILE_NAME_$(1) = /usr/local/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.i386.a
endef
+# FIXME ! Pending upstream patch to handle -print-libclang_rt-file-name
+# LIBCLANG_RT_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) $(CFLAGS_$(2)) -print-libclang_rt-file-name))
# initialize standard toolchain (CC,AS and others) for give stage
# @1 : stage for which the toolchain is to be initialized
More information about the coreboot-gerrit
mailing list