Skip to contentSkip to conversation

build: Make FILE symbol paths consistent

PATCH Superseded Ross Lagerwall 2 participants 4 messages Feb 8, 2023 – Feb 9, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: Make FILE symbol paths consistent

The FILE symbols in out-of-tree builds may be either a relative path to the object dir or an absolute path depending on how the build is invoked. Fix the paths for C files so that they are consistent with in-tree builds - the path is relative to the "xen" directory (e.g. common/irq.c).

This fixes livepatch builds when the original Xen build was out-of-tree since livepatch-build always does in-tree builds.

---
 xen/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/Rules.mk +2 -1
index 70b7489ea8..6b9269a70c 100644
@@ -228,8 +228,9 @@ quiet_cmd_cc_o_c = CC      $@
 ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y)
     cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@
     ifneq ($(CONFIG_CC_IS_CLANG)$(call clang-ifversion,-lt,600,y),yy)
+        rel_path = $(patsubst $(abs_srctree)/%,%,$(call realpath,$(1)))
         cmd_objcopy_fix_sym = \
-	    $(OBJCOPY) --redefine-sym $(<F)=$< $(dot-target).tmp $@ && rm -f $(dot-target).tmp
+           $(OBJCOPY) --redefine-sym $(<F)=$(call rel_path,$<) $(dot-target).tmp $@ && rm -f $(dot-target).tmp
     else
         cmd_objcopy_fix_sym = mv -f $(dot-target).tmp $@
     endif
Signature · 1 line
2.31.1
#1 lore raw
Quoted 8 lines · Ross Lagerwall

The FILE symbols in out-of-tree builds may be either a relative path to the object dir or an absolute path depending on how the build is invoked. Fix the paths for C files so that they are consistent with in-tree builds - the path is relative to the "xen" directory (e.g. common/irq.c).

This fixes livepatch builds when the original Xen build was out-of-tree since livepatch-build always does in-tree builds.

Sounds all plausible, except that I was under the impression that as of 035ab75d8e37 ("build: fix enforce unique symbols for recent clang version") things were consistent already. To clarify - Anthony, was this aspect simply not considered at the time? What would help here is a Fixes: tag, both for the purpose of review and for the purpose of deciding whether to backport. It might be that 7a3bcd2babcc ("build: build everything from the root dir, use obj=$subdir") is to blame, but I'm not really sure.

xen/Rules.mk quiet_cmd_cc_o_c = CC $@ · line 230

Quoted 6 lines
xen/Rules.mk +0 -0
@@ -228,8 +228,9 @@ quiet_cmd_cc_o_c = CC      $@
 ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y)
     cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@
     ifneq ($(CONFIG_CC_IS_CLANG)$(call clang-ifversion,-lt,600,y),yy)

You're altering only logic for pre-6.0.0 Clang, aiui. This is something that's absolutely necessary to state the latest in the description, but perhaps already in the subject. Among other things that's also an aspect when it comes to considering whether to backport.

xen/Rules.mk quiet_cmd_cc_o_c = CC $@ · line 231

Quoted 1 line
xen/Rules.mk +1 -0
+        rel_path = $(patsubst $(abs_srctree)/%,%,$(call realpath,$(1)))

Personally I'm against use of underscores when dashes would do, and using a dash here would also be consistent with e.g. ...

xen/Rules.mk quiet_cmd_cc_o_c = CC $@ · line 236

Quoted 6 lines
xen/Rules.mk +1 -1
         cmd_objcopy_fix_sym = \
-	    $(OBJCOPY) --redefine-sym $(<F)=$< $(dot-target).tmp $@ && rm -f $(dot-target).tmp
+           $(OBJCOPY) --redefine-sym $(<F)=$(call rel_path,$<) $(dot-target).tmp $@ && rm -f $(dot-target).tmp
     else
         cmd_objcopy_fix_sym = mv -f $(dot-target).tmp $@
     endif

... the several visible uses of $(dot-target) here.

Jan

#2 lore raw
Quoted 16 lines

From: Jan Beulich <[email protected]>
Sent: Thursday, February 9, 2023 8:44 AM
To: Ross Lagerwall <[email protected]>; Anthony Perard <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Julien Grall <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] build: Make FILE symbol paths consistent

Quoted 8 lines · Ross Lagerwall

The FILE symbols in out-of-tree builds may be either a relative path to the object dir or an absolute path depending on how the build is invoked. Fix the paths for C files so that they are consistent with in-tree builds - the path is relative to the "xen" directory (e.g. common/irq.c).

This fixes livepatch builds when the original Xen build was out-of-tree since livepatch-build always does in-tree builds.

Quoted 7 lines

Sounds all plausible, except that I was under the impression that as of 035ab75d8e37 ("build: fix enforce unique symbols for recent clang version") things were consistent already. To clarify - Anthony, was this aspect simply not considered at the time? What would help here is a Fixes: tag, both for the purpose of review and for the purpose of deciding whether to backport. It might be that 7a3bcd2babcc ("build: build everything from the root dir, use obj=$subdir") is to blame, but I'm not really sure.

035ab75d8e37 ensures uniqueness for symbols but it doesn't ensure they are consistent when using out of tree builds, i.e. the FILE symbols are the same regardless of the value of "O=". Since this inconsistency could only happen after out-of-tree builds were introduced, I guess it should be:

Fixes 7115fa562fe7 ("build: adding out-of-tree support to the xen build")
Quoted 12 lines
Quoted 7 lines
xen/Rules.mk +0 -0
@@ -228,8 +228,9 @@ quiet_cmd_cc_o_c = CC      $@
   ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y)

      cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@ ifneq ($(CONFIG_CC_IS_CLANG)$(call clang-ifversion,-lt,600,y),yy)

You're altering only logic for pre-6.0.0 Clang, aiui. This is something that's absolutely necessary to state the latest in the description, but perhaps already in the subject. Among other things that's also an aspect when it comes to considering whether to backport.

I think that's backwards. The check is: if !(cc_is_clang && clang-version < 6)

I can mention in the description that this change doesn't cover older versions of clang (which presumably have never worked with livepatch-build-tools since it embeds full paths but that is a separate issue).

Quoted 6 lines
Quoted 2 lines

+        rel_path = $(patsubst $(abs_srctree)/%,%,$(call realpath,$(1)))

Personally I'm against use of underscores when dashes would do, and using a dash here would also be consistent with e.g. ...

Quoted 8 lines
Quoted 6 lines

          cmd_objcopy_fix_sym = \
-         $(OBJCOPY) --redefine-sym $(<F)=$< $(dot-target).tmp $@ && rm -f $(dot-target).tmp +           $(OBJCOPY) --redefine-sym $(<F)=$(call rel_path,$<) $(dot-target).tmp $@ && rm -f $(dot-target).tmp else
          cmd_objcopy_fix_sym = mv -f $(dot-target).tmp $@
      endif

... the several visible uses of $(dot-target) here.

I'm not sure if there is much consistency since other variables like abs_srctree and abs_objtree also use underscores but I can change it if you prefer.

Ross

#3 lore raw
Quoted 16 lines · Ross Lagerwall
Quoted 16 lines

From: Jan Beulich <[email protected]>
Sent: Thursday, February 9, 2023 8:44 AM

Quoted 1 line · Ross Lagerwall

+        rel_path = $(patsubst $(abs_srctree)/%,%,$(call realpath,$(1)))

Personally I'm against use of underscores when dashes would do, and using a dash here would also be consistent with e.g. ...

Quoted 6 lines

          cmd_objcopy_fix_sym = \
-         $(OBJCOPY) --redefine-sym $(<F)=$< $(dot-target).tmp $@ && rm -f $(dot-target).tmp +           $(OBJCOPY) --redefine-sym $(<F)=$(call rel_path,$<) $(dot-target).tmp $@ && rm -f $(dot-target).tmp else
          cmd_objcopy_fix_sym = mv -f $(dot-target).tmp $@
      endif

Quoted 5 lines
Quoted 1 line

... the several visible uses of $(dot-target) here.

I'm not sure if there is much consistency since other variables like abs_srctree and abs_objtree also use underscores but I can change it if you prefer.

These two variables had their names kept from their Linux origin, iirc, so they aren't an overly good target for comparison. Nor are, for the same reason, the various cmd_*. Linux, sadly, isn't consistent in that regard ...

Jan