Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: fix ld-option function

The kbuild's ld-option function is broken because
the command
$(CC) /dev/null -c -o "$$TMPO"
does not create object file!

I have used a relatively old mips gcc 3.4.6 cross-compiler
and a relatively new gcc 4.7.2 to check this fact
but the results are the same.

EXAMPLE:
$ rm /tmp/1.o
$ mips-linux-gcc /dev/null -c -o /tmp/1.o
mips-linux-gcc: /dev/null: linker input file unused because linking not done
$ ls -la /tmp/1.o
ls: cannot access /tmp/1.o: No such file or directory

We can easily fix the problem by adding
the '-x c' compiler option.

EXAMPLE:
$ rm /tmp/1.o
$ mips-linux-gcc -x c /dev/null -c -o /tmp/1.o
$ ls -la /tmp/1.o
-rw-r--r-- 1 antony antony 778 Apr 2 20:40 /tmp/1.o

Also fix wrong ld-option example.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by

Antony Pavlov and committed by
Michal Marek
5b83df2b a937536b

+2 -2
+1 -1
Documentation/kbuild/makefiles.txt
··· 593 593 594 594 Example: 595 595 #Makefile 596 - LDFLAGS_vmlinux += $(call really-ld-option, -X) 596 + LDFLAGS_vmlinux += $(call ld-option, -X) 597 597 598 598 599 599 === 4 Host Program support
+1 -1
scripts/Kbuild.include
··· 148 148 # ld-option 149 149 # Usage: LDFLAGS += $(call ld-option, -X) 150 150 ld-option = $(call try-run,\ 151 - $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) 151 + $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) 152 152 153 153 # ar-option 154 154 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)