xen/arch: Simplify $(TARGET)-syms rule
PATCH 1/1 xen/arch: Simplify $(TARGET)-syms rule
In all cases, "-T $(obj)/xen.lds" can be factored out by appending to XEN_LDFLAGS. This takes the $(LD) commands from multi-line to single-line.
x86 uses $(build_id_linker) for all links, so factor that out too.
No functional change.
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Shawn Anastasio <[email protected]>
CC: Oleksii Kurochko <[email protected]>
This is based on top of Roger's "xen: remove -N from the linker command line".
x86 might want to follow ARM's lead and only use $(build_id_linker) on the final link. It also wants extending to PPC/RISC-V
$(orphan-handling-y) needs making common and using ouside of x86 too.
--- xen/arch/arm/Makefile | 10 ++++------ xen/arch/ppc/Makefile | 10 ++++------ xen/arch/riscv/Makefile | 10 ++++------ xen/arch/x86/Makefile | 10 ++++------ 4 files changed, 16 insertions(+), 24 deletions(-)
xen/arch/arm/Makefile +4 -6
@@ -96,21 +96,19 @@ ifeq ($(CONFIG_ARM_64),y) ln -sf $(@F) [email protected] endif +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(dot-target).0.o -o $(dot-target).1 + $(LD) $(XEN_LDFLAGS) $< $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $@ + $(LD) $(XEN_LDFLAGS) $< $(build_id_linker) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected]
xen/arch/ppc/Makefile +4 -6
@@ -11,21 +11,19 @@ obj-y += tlb-radix.o $(TARGET): $(TARGET)-syms cp -f $< $@ +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(dot-target).0.o -o $(dot-target).1 + $(LD) $(XEN_LDFLAGS) $< $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $@ + $(LD) $(XEN_LDFLAGS) $< $(build_id_linker) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected]
xen/arch/riscv/Makefile +4 -6
@@ -15,21 +15,19 @@ obj-y += vm_event.o $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(dot-target).0.o -o $(dot-target).1 + $(LD) $(XEN_LDFLAGS) $< $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $@ + $(LD) $(XEN_LDFLAGS) $< $(build_id_linker) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected]
xen/arch/x86/Makefile +4 -6
@@ -138,21 +138,19 @@ $(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds $(build_id_linker) $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).0.o -o $(dot-target).1 + $(LD) $(XEN_LDFLAGS) $< $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(orphan-handling-y) $(dot-target).1.o -o $@ + $(LD) $(XEN_LDFLAGS) $< $(orphan-handling-y) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected]
base-commit: debe8bf537ec2c69a4734393cd2b0c7f57f74c0c
prerequisite-patch-id: 7911818c8833f061c9476332975b9aecb69bc26d
Signature · 1 line
2.39.5
Quoted 8 lines · Andrew Cooper
In all cases, "-T $(obj)/xen.lds" can be factored out by appending to
XEN_LDFLAGS. This takes the $(LD) commands from multi-line to single-line.x86 uses $(build_id_linker) for all links, so factor that out too.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
However, ...
Quoted 19 lines
--- a/xen/arch/arm/Makefile
xen/arch/x86/Makefile +3
-4@@ -138,21 +138,19 @@ $(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds $(build_id_linker) $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).0.o -o $(dot-target).1 + $(LD) $(XEN_LDFLAGS) $< $(dot-target).0.o -o $(dot-target).1
xen/arch/x86/Makefile $(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 · line 156
Quoted 10 lines
xen/arch/x86/Makefile +1
-2$(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(orphan-handling-y) $(dot-target).1.o -o $@ + $(LD) $(XEN_LDFLAGS) $< $(orphan-handling-y) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected]
... any reason not to do the same for xen.efi's EFI_LDFLAGS and its -T $(obj)/efi.lds? I'd really like to keep the two rules as closely in sync as possible, to make it a little easier to eventually split them into a chain of smaller rules.
Jan
xen/arch/arm/Makefile ifeq ($(CONFIG_ARM_64),y) · line 99
Quoted 9 lines · Andrew Cooper
xen/arch/arm/Makefile +1
-0@@ -96,21 +96,19 @@ ifeq ($(CONFIG_ARM_64),y) ln -sf $(@F) [email protected] endif +$(TARGET)-syms: XEN_LDFLAGS += -T $(obj)/xen.lds
I would advise againts this change. Target-specific variables values tend to apply to prerequist as well, so XEN_LDFLAGS will also be modified when building prelink.o and xen.lds. It's might be ok in this case because xen.lds doesn't use it, and prelink.o happen to be linked in a different Makefile, but that's kind of setting a trap for someone to fall into.
There's a keyword to keep the variable change strictly to $(TARGET)-syms but that requires a more recent version of GNU make. That would be "private" if we could use it. Looks like we need GNU make 3.82 to use "private":
"GNU make 3.82 is now available"
https://lists.gnu.org/archive/html/info-gnu/2010-07/msg00023.html
xen/arch/arm/Makefile ifeq ($(CONFIG_ARM_64),y) · line 101
Quoted 4 lines
xen/arch/arm/Makefile +1
-2$(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ - $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(LD) $(XEN_LDFLAGS) $< $(objtree)/common/symbols-dummy.o -o $(dot-target).0
Cheers,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech