diff mbox

[v2] kbuild: fix ld-option function

Message ID 1365000153-8318-1-git-send-email-antonynpavlov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Antony Pavlov April 3, 2013, 2:42 p.m. UTC
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>
---
 Documentation/kbuild/makefiles.txt |    2 +-
 scripts/Kbuild.include             |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Michal Marek April 8, 2013, 9:59 a.m. UTC | #1
On 3.4.2013 16:42, Antony Pavlov wrote:
> 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>
> ---
>  Documentation/kbuild/makefiles.txt |    2 +-
>  scripts/Kbuild.include             |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied to kbuild.git#kbuild, thanks.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5198b74..5836294 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -593,7 +593,7 @@  more details, with real examples.
 
 	Example:
 		#Makefile
-		LDFLAGS_vmlinux += $(call really-ld-option, -X)
+		LDFLAGS_vmlinux += $(call ld-option, -X)
 
 
 === 4 Host Program support
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 978416d..547e15d 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -148,7 +148,7 @@  cc-ldoption = $(call try-run,\
 # ld-option
 # Usage: LDFLAGS += $(call ld-option, -X)
 ld-option = $(call try-run,\
-	$(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
+	$(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)