Xen-Devel Archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] build: Make FILE symbol paths consistent
@ 2023-02-13 16:55 Ross Lagerwall
  2023-02-15  9:55 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Lagerwall @ 2023-02-13 16:55 UTC (permalink / raw
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Jan Beulich, Julien Grall,
	Stefano Stabellini, Wei Liu, Anthony PERARD, 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. Note that this doesn't
fix the behaviour for Clang < 6 which always embeds full paths.

Fixes: 7115fa562fe7 ("build: adding out-of-tree support to the xen build")
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---

In v2:
* Adjust commit description.
* Rename rel_path.

 xen/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 70b7489ea8..d6b7cec0a8 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -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
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] build: Make FILE symbol paths consistent
  2023-02-13 16:55 [PATCH v2] build: Make FILE symbol paths consistent Ross Lagerwall
@ 2023-02-15  9:55 ` Jan Beulich
  2023-02-15 10:15   ` Ross Lagerwall
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2023-02-15  9:55 UTC (permalink / raw
  To: Ross Lagerwall
  Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
	Wei Liu, Anthony PERARD, xen-devel

On 13.02.2023 17:55, Ross Lagerwall wrote:
> 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. Note that this doesn't
> fix the behaviour for Clang < 6 which always embeds full paths.

Is "fix" here actually correct? I.e. is there anything to fix in that
case? It looks to me as if "always absolute paths" is as good as
"always relative paths". In which case s/fix/alter/?

> Fixes: 7115fa562fe7 ("build: adding out-of-tree support to the xen build")
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

With the above clarified (a possible adjustment could be done while
committing):
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] build: Make FILE symbol paths consistent
  2023-02-15  9:55 ` Jan Beulich
@ 2023-02-15 10:15   ` Ross Lagerwall
  0 siblings, 0 replies; 3+ messages in thread
From: Ross Lagerwall @ 2023-02-15 10:15 UTC (permalink / raw
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
	Wei Liu, Anthony Perard, xen-devel@lists.xenproject.org

> From: Jan Beulich <jbeulich@suse.com>
> Sent: Wednesday, February 15, 2023 9:55 AM
> To: Ross Lagerwall <ross.lagerwall@citrix.com>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap <George.Dunlap@citrix.com>; Julien Grall <julien@xen.org>; Stefano Stabellini <sstabellini@kernel.org>; Wei Liu <wl@xen.org>; Anthony Perard <anthony.perard@citrix.com>; xen-devel@lists.xenproject.org <xen-devel@lists.xenproject.org>
> Subject: Re: [PATCH v2] build: Make FILE symbol paths consistent 
>  
> On 13.02.2023 17:55, Ross Lagerwall wrote:
> > 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. Note that this doesn't
> > fix the behaviour for Clang < 6 which always embeds full paths.
> 
> Is "fix" here actually correct? I.e. is there anything to fix in that
> case? It looks to me as if "always absolute paths" is as good as
> "always relative paths". In which case s/fix/alter/?
> 

If embedding absolute paths, the livepatch-build process will fail to
match symbols between the base xen-syms and the newly built, patched
objects unless they are built with the source directory at the exact
same path. So yes, I would consider this as not "fixed" for Clang < 6.

Thanks,
Ross

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-15 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-13 16:55 [PATCH v2] build: Make FILE symbol paths consistent Ross Lagerwall
2023-02-15  9:55 ` Jan Beulich
2023-02-15 10:15   ` Ross Lagerwall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).