Skip to content

Commit

Permalink
kbuild: fix ld-option function
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
frantony authored and michal42 committed Apr 8, 2013
1 parent a937536 commit 5b83df2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Documentation/kbuild/makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/Kbuild.include
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b83df2

Please sign in to comment.