Re: "build-id" changes break sparc64

From: Roland McGrath
Date: Mon Jul 23 2007 - 03:27:00 EST


> Should be doable without to much pain.
> Alan can you please share with us exactly why this is better and what we may
> run into of problems doing so.
> A sample script would be nice too....

This about does it. Polish left as an exercise to the reader.
ld does "interesting" things if the linker scripts are inside --start-group.

diff --git a/Makefile b/Makefile
index cd47845..0000000 100644
--- a/Makefile
+++ b/Makefile
@@ -613,12 +613,15 @@ vmlinux-all := $(vmlinux-init) $(vmlinu
vmlinux-lds := arch/$(ARCH)/kernel/vmlinux.lds
export KBUILD_VMLINUX_OBJS := $(vmlinux-all)

+vmlinux-link-main = $(filter-out %.a,$(vmlinux-main)) \
+ --start-group $(filter %.a,$(vmlinux-main)) --end-group
+
# Rule to link vmlinux - also used during CONFIG_KALLSYMS
# May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_vmlinux__ ?= LD $@
cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \
-T $(vmlinux-lds) $(vmlinux-init) \
- --start-group $(vmlinux-main) --end-group \
+ $(vmlinux-link-main) \
$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^)

# Generate new vmlinux version
@@ -747,7 +750,7 @@ endif # ifdef CONFIG_KALLSYMS
# relevant sections renamed as per the linker script.
quiet_cmd_vmlinux-modpost = LD $@
cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \
- $(vmlinux-init) --start-group $(vmlinux-main) --end-group \
+ $(vmlinux-init) $(vmlinux-link-main) \
$(filter-out $(vmlinux-init) $(vmlinux-main) $(vmlinux-lds) FORCE ,$^)
define rule_vmlinux-modpost
:
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 3f7b451..0000000 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -274,11 +274,11 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
# Rule to compile a set of .o files into one .o file
#
ifdef builtin-target
-quiet_cmd_link_o_target = LD $@
+quiet_cmd_link_o_target = LDS $@
# If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
- rm -f $@; $(AR) rcs $@)
+cmd_link_o_target = echo > $@.new $(if $(strip $(obj-y)),\
+ 'INPUT($(filter $(obj-y), $^))') && \
+ mv -f $@.new $@

$(builtin-target): $(obj-y) FORCE
$(call if_changed,link_o_target)
@@ -311,11 +311,11 @@ $(filter $(addprefix $(obj)/, \
$($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y)))), $^)

-quiet_cmd_link_multi-y = LD $@
-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
+quiet_cmd_link_multi-y = LDS $@
+cmd_link_multi-y = echo > $@.new 'INPUT($(link_multi_deps))' && mv -f $@.new $@

quiet_cmd_link_multi-m = LD [M] $@
-cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
+cmd_link_multi-m = $(cmd_link_multi-y)

# We would rather have a list of rules like
# foo.o: $(foo-objs)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/