[git commit] build system: specify '-nostldlib' when linking to .o files

Denys Vlasenko vda.linux at googlemail.com
Wed Apr 2 10:12:46 UTC 2014

commit: http://git.busybox.net/busybox/commit/?id=7537406edd3e0adf11d117379cac4e519e746d35
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

For certain cross build scenarios the LD variable is overridden
to use the gcc executive to ensure all the target tuning parameters
are used.  In these cases, the executive errors out as shown below
but since this step is only linking to a .o file the standard libs
are not needed.

    $ make LD=gcc applets/built-in.o
      LD      applets/built-in.o
    /usr/bin/ld: cannot find -lgcc_s
    /usr/bin/ld: cannot find -lgcc_s
    collect2: ld returned 1 exit status
    make[1]: *** [applets/built-in.o] Error 1
    make: *** [applets_dir] Error 2

Signed-off-by: Drew Moseley <drew_moseley at mentor.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
 scripts/Makefile.build |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5685b5b..5eac45f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -255,8 +255,9 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 ifdef builtin-target
 quiet_cmd_link_o_target = LD      $@
 # If the list of objects to link is empty, just create an empty built-in.o
+# -nostdlib is added to make "make LD=gcc ..." work (some people use that)
 cmd_link_o_target = $(if $(strip $(obj-y)),\
-		$(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
+		$(LD) -nostdlib $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
 		rm -f $@; $(AR) rcs $@)
 $(builtin-target): $(obj-y) FORCE

More information about the busybox-cvs mailing list