All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] livepatch-build-tools: allow livepatching version.c
@ 2023-12-14  8:54 Roger Pau Monne
  2023-12-15 11:47 ` Ross Lagerwall
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Pau Monne @ 2023-12-14  8:54 UTC (permalink / raw)
  To: xen-devel
  Cc: Konrad Rzeszutek Wilk, Ross Lagerwall, Roger Pau Monne,
	Andrew Cooper

Currently version.o is explicitly ignored as the file would change as a result
of the orignal and the patched build having possibly different dates, times or
changeset strings (by the patched build appending -dirty).

Fix such difference by exporting the date and time from the build script, so
that both builds share the same build time.  The changeset string gets set in
.scmversion, and is cleaned on script exit if it wasn't present initially. This
allows checking for changes in version.c, since the rest of fields need to be
manually changed in order to produce different output.

Setting XEN_BUILD_{DATE,TIME} as an environment variable and .scmversion has
been supported since before livepatch support was added to Xen, so it's safe to
export those variables unconditionally.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - Also ensure consistent changeset version.
---
 livepatch-build | 14 ++++++++++++++
 livepatch-gcc   |  2 --
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/livepatch-build b/livepatch-build
index e2ccce4f7fd7..332d26f5c6b6 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -392,6 +392,10 @@ echo "Output directory: $outputarg"
 echo "================================================"
 echo
 
+cleanup_version() {
+    rm -rf "${SRCDIR}/xen/.scmversion"
+}
+
 if [ "${SKIP}" != "build" ]; then
     # Make sure output directory doesn't exist, and create it.
     [ -e "$outputarg" ] && die "Output directory exists"
@@ -417,6 +421,16 @@ if [ "${SKIP}" != "build" ]; then
 
     export CROSS_COMPILE="${TOOLSDIR}/livepatch-gcc "
 
+    # Force same date and time to prevent unwanted changes in version.c
+    export XEN_BUILD_DATE=`LC_ALL=C date`
+    export XEN_BUILD_TIME=`LC_ALL=C date +%T`
+
+    # Ensure uniform changeset between builds
+    if [ ! -e "${SRCDIR}/xen/.scmversion" ]; then
+        trap cleanup_version EXIT
+        echo "unavailable" > "${SRCDIR}/xen/.scmversion"
+    fi
+
     echo "Perform full initial build with ${CPUS} CPU(s)..."
     build_full
 
diff --git a/livepatch-gcc b/livepatch-gcc
index fcad80551aa0..e4cb6fb59029 100755
--- a/livepatch-gcc
+++ b/livepatch-gcc
@@ -33,7 +33,6 @@ if [[ "$TOOLCHAINCMD" =~ $GCC_RE ]] ; then
             obj=$2
             [[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/}
             case "$(basename $obj)" in
-            version.o|\
             debug.o|\
             check.o|\
             *.xen-syms.*.o|\
@@ -63,7 +62,6 @@ done
 elif [[ "$TOOLCHAINCMD" =~ $OBJCOPY_RE ]] ; then
     obj="${!#}"
     case "$(basename $obj)" in
-        version.o|\
         debug.o|\
         check.o|\
         boot.o|\

base-commit: 0ed8ef88dc300750696a64e89efa3b82502f6dc7
-- 
2.43.0



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

* Re: [PATCH v2] livepatch-build-tools: allow livepatching version.c
  2023-12-14  8:54 [PATCH v2] livepatch-build-tools: allow livepatching version.c Roger Pau Monne
@ 2023-12-15 11:47 ` Ross Lagerwall
  2023-12-15 13:53   ` Roger Pau Monné
  0 siblings, 1 reply; 3+ messages in thread
From: Ross Lagerwall @ 2023-12-15 11:47 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Konrad Rzeszutek Wilk, Andrew Cooper

On Thu, Dec 14, 2023 at 8:54 AM Roger Pau Monne <roger.pau@citrix.com> wrote:
>
> Currently version.o is explicitly ignored as the file would change as a result
> of the orignal and the patched build having possibly different dates, times or
> changeset strings (by the patched build appending -dirty).
>
> Fix such difference by exporting the date and time from the build script, so
> that both builds share the same build time.  The changeset string gets set in
> .scmversion, and is cleaned on script exit if it wasn't present initially. This
> allows checking for changes in version.c, since the rest of fields need to be
> manually changed in order to produce different output.
>
> Setting XEN_BUILD_{DATE,TIME} as an environment variable and .scmversion has
> been supported since before livepatch support was added to Xen, so it's safe to
> export those variables unconditionally.
>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Changes since v1:
>  - Also ensure consistent changeset version.
> ---
>  livepatch-build | 14 ++++++++++++++
>  livepatch-gcc   |  2 --
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/livepatch-build b/livepatch-build
> index e2ccce4f7fd7..332d26f5c6b6 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -392,6 +392,10 @@ echo "Output directory: $outputarg"
>  echo "================================================"
>  echo
>
> +cleanup_version() {
> +    rm -rf "${SRCDIR}/xen/.scmversion"
> +}
> +
>  if [ "${SKIP}" != "build" ]; then
>      # Make sure output directory doesn't exist, and create it.
>      [ -e "$outputarg" ] && die "Output directory exists"
> @@ -417,6 +421,16 @@ if [ "${SKIP}" != "build" ]; then
>
>      export CROSS_COMPILE="${TOOLSDIR}/livepatch-gcc "
>
> +    # Force same date and time to prevent unwanted changes in version.c
> +    export XEN_BUILD_DATE=`LC_ALL=C date`
> +    export XEN_BUILD_TIME=`LC_ALL=C date +%T`
> +
> +    # Ensure uniform changeset between builds
> +    if [ ! -e "${SRCDIR}/xen/.scmversion" ]; then
> +        trap cleanup_version EXIT
> +        echo "unavailable" > "${SRCDIR}/xen/.scmversion"

Shouldn't this be "${SRCDIR}/.scmversion" since Xen runs
"$(srctree)/tools/scmversion $(XEN_ROOT)"?

Otherwise I still get spurious version.o changes...

With the 3 uses of that changed (can change during commit),

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>


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

* Re: [PATCH v2] livepatch-build-tools: allow livepatching version.c
  2023-12-15 11:47 ` Ross Lagerwall
@ 2023-12-15 13:53   ` Roger Pau Monné
  0 siblings, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2023-12-15 13:53 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: xen-devel, Konrad Rzeszutek Wilk, Andrew Cooper

On Fri, Dec 15, 2023 at 11:47:18AM +0000, Ross Lagerwall wrote:
> On Thu, Dec 14, 2023 at 8:54 AM Roger Pau Monne <roger.pau@citrix.com> wrote:
> >
> > Currently version.o is explicitly ignored as the file would change as a result
> > of the orignal and the patched build having possibly different dates, times or
> > changeset strings (by the patched build appending -dirty).
> >
> > Fix such difference by exporting the date and time from the build script, so
> > that both builds share the same build time.  The changeset string gets set in
> > .scmversion, and is cleaned on script exit if it wasn't present initially. This
> > allows checking for changes in version.c, since the rest of fields need to be
> > manually changed in order to produce different output.
> >
> > Setting XEN_BUILD_{DATE,TIME} as an environment variable and .scmversion has
> > been supported since before livepatch support was added to Xen, so it's safe to
> > export those variables unconditionally.
> >
> > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Changes since v1:
> >  - Also ensure consistent changeset version.
> > ---
> >  livepatch-build | 14 ++++++++++++++
> >  livepatch-gcc   |  2 --
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/livepatch-build b/livepatch-build
> > index e2ccce4f7fd7..332d26f5c6b6 100755
> > --- a/livepatch-build
> > +++ b/livepatch-build
> > @@ -392,6 +392,10 @@ echo "Output directory: $outputarg"
> >  echo "================================================"
> >  echo
> >
> > +cleanup_version() {
> > +    rm -rf "${SRCDIR}/xen/.scmversion"
> > +}
> > +
> >  if [ "${SKIP}" != "build" ]; then
> >      # Make sure output directory doesn't exist, and create it.
> >      [ -e "$outputarg" ] && die "Output directory exists"
> > @@ -417,6 +421,16 @@ if [ "${SKIP}" != "build" ]; then
> >
> >      export CROSS_COMPILE="${TOOLSDIR}/livepatch-gcc "
> >
> > +    # Force same date and time to prevent unwanted changes in version.c
> > +    export XEN_BUILD_DATE=`LC_ALL=C date`
> > +    export XEN_BUILD_TIME=`LC_ALL=C date +%T`
> > +
> > +    # Ensure uniform changeset between builds
> > +    if [ ! -e "${SRCDIR}/xen/.scmversion" ]; then
> > +        trap cleanup_version EXIT
> > +        echo "unavailable" > "${SRCDIR}/xen/.scmversion"
> 
> Shouldn't this be "${SRCDIR}/.scmversion" since Xen runs
> "$(srctree)/tools/scmversion $(XEN_ROOT)"?
> 
> Otherwise I still get spurious version.o changes...
> 
> With the 3 uses of that changed (can change during commit),
> 
> Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Great, I had a stale .scmversion in my Xen root and that's why I
wasn't seeing the path not being effective.

Please adjust on commit.

Thanks, Roger.


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

end of thread, other threads:[~2023-12-15 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14  8:54 [PATCH v2] livepatch-build-tools: allow livepatching version.c Roger Pau Monne
2023-12-15 11:47 ` Ross Lagerwall
2023-12-15 13:53   ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.