Hi Hamo,
Thanks for the patch. I know you need this for your ARM development, but we should wait for an ARM target before committing this.
This fundamentally changes how .xcompile is used and included by coreboot. I think that I would prefer that the xcompile script accept a flag for using the ARM toolchain over the x86 tools and still set the compiler variables.
Marc
On Mon, May 23, 2011 at 6:14 AM, Hamo hamo.by@gmail.com wrote:
This patch added arm toolchain support for coreboot building system.
xcompile will find the different toolchain for X86 and ARM architectures and when we decided the target architecture using `make menuconfig` or so, makefile will choose the right toolchain.
Signed-off-by: Yang Bai hamo.by@gmail.com
...
- if ${gccprefixes}as --32 -o ${TMPFILE}.o ${TMPFILE}; then
- TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o`
- if [ ${TARCH} == "i386" ]; then
- if ${gccprefixes}as --32 -o ${TMPFILE}.o ${TMPFILE}; then
- TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o | grep "file format"`
if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
- GCCPREFIX=$gccprefixes
- ASFLAGS=--32
- CFLAGS="-m32 "
- LDFLAGS="-b elf32-i386"
- break
- GCCPREFIX=$gccprefixes
- ASFLAGS=--32
- CFLAGS="-m32 "
- LDFLAGS="-b elf32-i386"
- break
fi
- fi
fi -done -rm -f $TMPFILE ${TMPFILE}.o
- done
- rm -f $TMPFILE ${TMPFILE}.o
Be careful with whitespace changes. Try not to put to many in with code changes.
-if [ "$GCCPREFIX" = "invalid" ]; then
- echo '$(error no suitable gcc found)'
- exit 1
-fi
-CC="${GCCPREFIX}gcc" -testcc "$CC" "$CFLAGS-Wa,--divide " && CFLAGS="$CFLAGS-Wa,--divide " -testcc "$CC" "$CFLAGS-fno-stack-protector " && CFLAGS="$CFLAGS-fno-stack-protector " -testcc "$CC" "$CFLAGS-Wl,--build-id=none " && CFLAGS="$CFLAGS-Wl,--build-id=none "
-if which gcc 2>/dev/null >/dev/null; then
- HOSTCC=gcc
-else
- HOSTCC=cc
-fi
-cat << EOF
- if [ "$GCCPREFIX" != "invalid" ]; then
- CC="${GCCPREFIX}gcc"
- testcc "$CC" "$CFLAGS-Wa,--divide " && CFLAGS="$CFLAGS-Wa,--divide "
- testcc "$CC" "$CFLAGS-fno-stack-protector " &&
CFLAGS="$CFLAGS-fno-stack-protector "
- testcc "$CC" "$CFLAGS-Wl,--build-id=none " &&
CFLAGS="$CFLAGS-Wl,--build-id=none "
- cat << EOF
# elf${TWIDTH}-${TARCH} toolchain -AS:=${GCCPREFIX}as ${ASFLAGS} -CC:=${GCCPREFIX}gcc ${CFLAGS} -AR:=${GCCPREFIX}ar -LD:=${GCCPREFIX}ld ${LDFLAGS} -STRIP:=${GCCPREFIX}strip -NM:=${GCCPREFIX}nm -OBJCOPY:=${GCCPREFIX}objcopy -OBJDUMP:=${GCCPREFIX}objdump
-# native toolchain -HOSTCC:=${HOSTCC} +AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS} +CC_${TARCH}:=${GCCPREFIX}gcc ${CFLAGS} +AR_${TARCH}:=${GCCPREFIX}ar +LD_${TARCH}:=${GCCPREFIX}ld ${LDFLAGS} +STRIP_${TARCH}:=${GCCPREFIX}strip +NM_${TARCH}:=${GCCPREFIX}nm +OBJCOPY_${TARCH}:=${GCCPREFIX}objcopy +OBJDUMP_${TARCH}:=${GCCPREFIX}objdump EOF
- else
- cat <<EOF
+# elf${TWIDTH}-${TARCH} toolchain +NO_${TARCH}_TOOLCHAIN:=1 +EOF
- fi
+unset AS CC AR LD STRIP NM OBJCOPY OBJDUMP GCCPREFIX ASFLAGS CFLAGS LDFLAGS CARCH
+done
Index: Makefile
--- Makefile (revision 6567) +++ Makefile (working copy) @@ -101,7 +101,42 @@
include $(HAVE_DOTCONFIG)
+# Set the toolchain variables +# FOR X86 +ifeq ($(CONFIG_ARCH_X86),y) +ifeq ($(NO_i386_TOOLCHAIN),1) +$(error No suitable gcc for X86 found) +else ifneq ($(INNER_SCANBUILD),y) +CC:=$(CC_i386) +endif +AS:=$(AS_i386) +AR:=$(AR_i386) +LD:=$(LD_i386) +STRIP:=$(STRIP_i386) +NM:=$(NM_i386) +OBJCOPY:=$(OBJCOPY_i386) +OBJDUMP:=$(OBJDUMP_i386) +endif +endif
+# FOR ARM +ifeq ($(CONFIG_ARCH_ARM),y) +ifeq ($(NO_littlearm_TOOLCHAIN),1) +$(error No suitable gcc for ARM found) +else +CC:=$(CC_littlearm) +AS:=$(AS_littlearm) +AR:=$(AR_littlearm) +LD:=$(LD_littlearm) +STRIP:=$(STRIP_littlearm) +NM:=$(NM_littlearm) +OBJCOPY:=$(OBJCOPY_littlearm) +OBJDUMP:=$(OBJDUMP_littlearm) +endif +endif
+ifneq ($(INNER_SCANBUILD),y) ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) CC:=clang -m32 HOSTCC:=clang
I think that these makefile changes shouldn't be needed as long as coreboot is including the correct settings from the .xcompile file.
Marc