Skip to contentSkip to conversation

kbuild: fix reading CROSS_COMPILE from .config

PATCH New Wu Fengguang 1 participant 1 message Aug 23, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 kbuild: fix reading CROSS_COMPILE from .config

Fix compile error

        $ ARCH=x86_64 CROSS_COMPILE=x86_64-linux-gnu- make
        ...
        cc1: error: unrecognized command line option "-m64"
        cc1: error: unrecognized command line option "-mno-red-zone"
        cc1: error: unrecognized command line option "-mcmodel=kernel"
        cc1: error: unrecognized command line option "-maccumulate-outgoing-args"

The error was introduced by patch kbuild-fix-config_cross_compile-issue-in-config.patch:

  -CROSS_COMPILE  ?= $(CONFIG_CROSS_COMPILE:"%"=%)
  +CROSS_COMPILE  := $(shell grep CONFIG_CROSS_COMPILE .config | cut -d'"' -f2)

That patch does two things:
1) It grep for CONFIG_CROSS_COMPILE because we may not have incldued .config
2) It no longer pick up CROSS_COMPILE from the environment.

Traditionally we have picked up ARCH and CROSS_COMPILE from the environment, hence the use of "?=".
"?=" says - perform this assignment unless lhs is already defined. And lhs may be already defined is we have the symbol defined in the environment.

I think the original submitter changed from ?= to := without realizing this. So the patch should be adjusted to use ?= again before it is applied.

---

Andrew: it's an -mm tree only bug for now
Sam: I copied so many of your nice comments to the changelog, so that I added your Signed-off-by :)

Makefile +1 -2
index 276d642..a2d3ded 100644
@@ -189,8 +189,7 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 export KBUILD_BUILDHOST := $(SUBARCH)
 ARCH		?= $(SUBARCH)
-CROSS_COMPILE	?=
-CROSS_COMPILE	:= $(shell grep CONFIG_CROSS_COMPILE .config | cut -d'"' -f2)
+CROSS_COMPILE	?= $(shell grep CONFIG_CROSS_COMPILE .config | cut -d'"' -f2)
 
 # Architecture as present in compile.h
 UTS_MACHINE 	:= $(ARCH)