I'm worried about tool chain problems, so I wanted to be able to build with
a cross compiler.  This patch adds that functionality to Kconfig.

This is most of the way there, but doesn't work when CONFIG_CROSS_COMPILE is
set.

+ifeq ($(CONFIG_CROSS_COMPILE),y)
+CC=$(CONFIG_CROSS_COMPILER)
+CCSTRING="XCC"
+endif

If I change it to

ifneq ($(CONFIG_CROSS_COMPILE),n)
...
endif

It always uses the cross compiler.

Can someone spot what I did wrong, please?

xgcc_debug.diff just prints out the compiler information when you do make
clean.  It was a faster way for me to try things, but I still didn't find
the correct way to do it.

Signed-off-by: Myles Watson <[email protected]>

Thanks,
Myles
Index: svn/Makefile
===================================================================
--- svn.orig/Makefile
+++ svn/Makefile
@@ -60,12 +60,19 @@ ifneq ($(Q),)
 endif
 endif
 
-CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
+CCSTRING="CC "
+
+ifeq ($(CONFIG_CROSS_COMPILE),y)
+CC=$(CONFIG_CROSS_COMPILER)
+CCSTRING="XCC"
+endif
+
+CPP= $(CC) -x assembler-with-cpp -DASSEMBLY -E
 HOSTCC = gcc
 HOSTCXX = g++
 HOSTCFLAGS := -I$(srck) -I$(objk) -g
 HOSTCXXFLAGS := -I$(srck) -I$(objk)
-LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
+LIBGCC_FILE_NAME = $(shell $(CC) -print-libgcc-file-name )
 
 DESTDIR = /opt
 
@@ -159,49 +166,49 @@ endef
 
 define objs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define objs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define initobjs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define initobjs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define drivers_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define drivers_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define smmobjs_c_template
 $(obj)/$(1)%.o: src/$(1)%.c
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
 define smmobjs_S_template
 $(obj)/$(1)%.o: src/$(1)%.S
-	@printf "    CC         $$(subst $$(shell pwd)/,,$$(@))\n"
+	@printf "    $(CCSTRING)        $$(subst $$(shell pwd)/,,$$(@))\n"
 	$(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
 endef
 
Index: svn/src/Kconfig
===================================================================
--- svn.orig/src/Kconfig
+++ svn/src/Kconfig
@@ -47,6 +47,17 @@ config LOCALVERSION
 	  the coreboot version number, so that you can easily distinguish
 	  boot logs of different boards from each other.
 
+config CROSS_COMPILE
+	bool "Specify a specific compiler"
+	default n
+	help
+	  Use a specific compiler to build coreboot.
+
+config CROSS_COMPILER
+	string "Path to a cross compiler"
+	depends on CROSS_COMPILE
+	default "util/crossgcc/xgcc/bin/i386-elf-gcc"
+
 endmenu
 
 source src/mainboard/Kconfig
Index: svn/src/arch/i386/Makefile.inc
===================================================================
--- svn.orig/src/arch/i386/Makefile.inc
+++ svn/src/arch/i386/Makefile.inc
@@ -75,12 +75,12 @@ $(obj)/build_opt_tbl: $(top)/util/option
 # Build the coreboot_ram (stage 2)
 
 $(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/config/coreboot_ram.ld #ldoptions
-	@printf "    CC         $(subst $(obj)/,,$(@))\n"
+	@printf "    $(CCSTRING)        $(subst $(obj)/,,$(@))\n"
 	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/config/coreboot_ram.ld $(obj)/coreboot_ram.o
 	$(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
 
 $(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
-	@printf "    CC         $(subst $(obj)/,,$(@))\n"
+	@printf "    $(CCSTRING)        $(subst $(obj)/,,$(@))\n"
 	$(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,-\( $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,-\)
 
 $(obj)/coreboot.a: $(objs)
Index: svn/Makefile
===================================================================
--- svn.orig/Makefile
+++ svn/Makefile
@@ -296,6 +296,10 @@ doxygen-clean:
 	rm -rf $(DOXYGEN_OUTPUT_DIR)
 
 clean: doxygen-clean
+	echo CC=$(CC)
+	echo CCSTRING=$(CCSTRING)
+	echo CROSS?=$(CONFIG_CROSS_COMPILE)
+	echo XCC=$(CONFIG_CROSS_COMPILER)
 	rm -f $(allobjs) build/coreboot* .xcompile
 	rm -f build/option_table.* build/crt0_includes.h build/ldscript
 	rm -f $(obj)/mainboard/$(MAINBOARDDIR)/static.c $(obj)/mainboard/$(MAINBOARDDIR)/config.py $(obj)/mainboard/$(MAINBOARDDIR)/static.dot
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to