Skip to contentSkip to conversation

build: prepend OBJ_DIR to linker script

PATCH In review Wei Liu 3 participants 5 messages Dec 13, 2016 – Dec 14, 2016 Kbuild

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 build: prepend OBJ_DIR to linker script

After 5623e2d2 ("x86: use unified linker script") the linker script for x86 build is generated. But the special rule to generate linker script doesn't have OBJ_DIR prepended so in parallel build the same file is written multiple times. This is racy and would cause parallel build to fail.

Fix this by prepending OBJ_DIR to the path of linker script. Change other variables where necessary.

---
 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
index 1d2324c..74f2c31 100644
@@ -24,7 +24,7 @@ include minios.mk
 LDLIBS := 
 APP_LDLIBS := 
 LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
-LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(ARCH_LDFLAGS_FINAL)
+LDFLAGS_FINAL := -T $(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(ARCH_LDFLAGS_FINAL)
 
 # Prefix for global API names. All other symbols are localised before
 # linking with EXTRA_OBJS.
@@ -156,10 +156,10 @@ APP_O=$(OBJ_DIR)/$(TARGET)_app.o
 endif
 
 # Special rule for x86 for now
-arch/x86/minios-x86%.lds:  arch/x86/minios-x86.lds.S
+$(OBJ_DIR)/arch/x86/minios-x86%.lds:  arch/x86/minios-x86.lds.S
 	$(CPP) $(ASFLAGS) -P $< -o $@
 
-$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
+$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
 	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o [email protected]
 	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start [email protected] [email protected]
 	$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) [email protected] $(EXTRA_OBJS) -o $@
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw
Quoted 10 lines · Wei Liu

After 5623e2d2 ("x86: use unified linker script") the linker script for x86 build is generated. But the special rule to generate linker script doesn't have OBJ_DIR prepended so in parallel build the same file is written multiple times. This is racy and would cause parallel build to fail.

Fix this by prepending OBJ_DIR to the path of linker script. Change other variables where necessary.

This also needs to be backported to 4.8.

Quoted 33 lines
---
 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
index 1d2324c..74f2c31 100644
@@ -24,7 +24,7 @@ include minios.mk
 LDLIBS := 
 APP_LDLIBS := 
 LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
-LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(ARCH_LDFLAGS_FINAL)
+LDFLAGS_FINAL := -T $(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(ARCH_LDFLAGS_FINAL)
 
 # Prefix for global API names. All other symbols are localised before
 # linking with EXTRA_OBJS.
@@ -156,10 +156,10 @@ APP_O=$(OBJ_DIR)/$(TARGET)_app.o
 endif
 
 # Special rule for x86 for now
-arch/x86/minios-x86%.lds:  arch/x86/minios-x86.lds.S
+$(OBJ_DIR)/arch/x86/minios-x86%.lds:  arch/x86/minios-x86.lds.S
 	$(CPP) $(ASFLAGS) -P $< -o $@
 
-$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
+$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib $(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
 	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o [email protected]
 	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start [email protected] [email protected]
 	$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) [email protected] $(EXTRA_OBJS) -o $@
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Liu
Quoted 10 lines · Wei Liu

After 5623e2d2 ("x86: use unified linker script") the linker script for x86 build is generated. But the special rule to generate linker script doesn't have OBJ_DIR prepended so in parallel build the same file is written multiple times. This is racy and would cause parallel build to fail.

Fix this by prepending OBJ_DIR to the path of linker script. Change other variables where necessary.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 7 lines · Juergen Gross, on Tue 13 Dec 2016 16:18:07 +0100, wrote:
Quoted 6 lines · Wei Liu

After 5623e2d2 ("x86: use unified linker script") the linker script for x86 build is generated. But the special rule to generate linker script doesn't have OBJ_DIR prepended so in parallel build the same file is written multiple times. This is racy and would cause parallel build to fail.

Quoted 6 lines
Quoted 4 lines

Fix this by prepending OBJ_DIR to the path of linker script. Change other variables where necessary.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#4 lore raw
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Juergen Gross, on Tue 13 Dec 2016 16:18:07 +0100, wrote:
Quoted 6 lines · Wei Liu

After 5623e2d2 ("x86: use unified linker script") the linker script for x86 build is generated. But the special rule to generate linker script doesn't have OBJ_DIR prepended so in parallel build the same file is written multiple times. This is racy and would cause parallel build to fail.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Fix this by prepending OBJ_DIR to the path of linker script. Change other variables where necessary.

Thanks. Pushed.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel