Skip to contentSkip to conversation

tools: Remove #include <version.h>

PATCH New Pali Rohár 3 participants 7 messages Jan 27, 2021 – Feb 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: Remove #include <version.h>

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +1 -1
index e5481435a7..54c2517c9e 100644
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 
tools/mkenvimage.c +1 -1
index b05f83415f..6482ca6ee9 100644
@@ -23,7 +23,7 @@
 
 #include "compiler.h"
 #include <u-boot/crc.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 #define CRC_SIZE sizeof(uint32_t)
 
tools/mkimage.c +1 -1
index 68d5206cb4..d5e274c504 100644
@@ -11,7 +11,7 @@
 #include "mkimage.h"
 #include "imximage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void copy_file(int, const char *, int);
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 tools: Remove #include <version.h>

Quoted 10 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

Quoted 7 lines
---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
#2 lore raw

PATCH 1/1 tools: Remove #include <version.h>

In reply to Pali Rohár
Quoted 21 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +0 -0
index e5481435a7..54c2517c9e 100644

tools/dumpimage.c line 13

Quoted 8 lines
tools/dumpimage.c +1 -1
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 

I don't know if I really like this approach. It also seems inconsistent as we have for example tools/fit-image.c that has content from generated/version_autogenerated.h but wasn't changed by this patch (nor the rest of the series).

I think a bit more invasive approach is required here. I like the <version_string.h> approach you used elsewhere, and as best I can see, the only place U_BOOT_VERSION_STRING, which is where we have the timestamp itself, is used is cmd/version.c (and defined in version.h). We should isolate the file that has the date such that it's only in one file and referenced in one file. This means probably removing the version_string global from arch/{powerpc,m68k} and dropping __weak from cmd/version.c and seeing what happens, as well.

Do you see where I'm thinking with this, or do I need to try and explain a bit more? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210201/85338a69/attachment.sig>
#3 lore raw

PATCH 1/1 tools: Remove #include <version.h>

Quoted 46 lines · On Monday 01 February 2021 16:20:18 Tom Rini wrote:
Quoted 21 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +0 -0
index e5481435a7..54c2517c9e 100644

tools/dumpimage.c line 13

Quoted 8 lines
tools/dumpimage.c +1 -1
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 

I don't know if I really like this approach. It also seems inconsistent as we have for example tools/fit-image.c that has content from generated/version_autogenerated.h but wasn't changed by this patch (nor the rest of the series).

I think a bit more invasive approach is required here. I like the <version_string.h> approach you used elsewhere, and as best I can see, the only place U_BOOT_VERSION_STRING, which is where we have the timestamp itself, is used is cmd/version.c (and defined in version.h). We should isolate the file that has the date such that it's only in one file and referenced in one file. This means probably removing the version_string global from arch/{powerpc,m68k} and dropping __weak from cmd/version.c and seeing what happens, as well.

Quoted 2 lines

Do you see where I'm thinking with this, or do I need to try and explain a bit more? Thanks!

Hello Tom! I think I understood what you mean. I would need to look at all places where version strings and timestamps in any forms are used as this approach would need some other cleanup...

Quoted 3 lines
Signature · 2 lines
-- 
Tom
#4 lore raw

PATCH 1/1 tools: Remove #include <version.h>

In reply to Tom Rini
Quoted 37 lines · On Monday 01 February 2021 16:20:18 Tom Rini wrote:
Quoted 21 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +0 -0
index e5481435a7..54c2517c9e 100644

tools/dumpimage.c line 13

Quoted 8 lines
tools/dumpimage.c +1 -1
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 

I don't know if I really like this approach. It also seems inconsistent as we have for example tools/fit-image.c that has content from generated/version_autogenerated.h but wasn't changed by this patch (nor the rest of the series).

Quoted 8 lines

I think a bit more invasive approach is required here. I like the <version_string.h> approach you used elsewhere, and as best I can see, the only place U_BOOT_VERSION_STRING, which is where we have the timestamp itself, is used is cmd/version.c (and defined in version.h). We should isolate the file that has the date such that it's only in one file and referenced in one file. This means probably removing the version_string global from arch/{powerpc,m68k} and dropping __weak from cmd/version.c and seeing what happens, as well.

Hello! I have looked at dropping this weak property from version_string but seem it is not so easy... powerpc platforms have following code:

file arch/powerpc/cpu/mpc85xx/start.S:

.globl _start
_start:

       .long   0x27051956              /* U-BOOT Magic Number */
       .globl  version_string
version_string:
       .ascii U_BOOT_VERSION_STRING, "\0"

I do not know how it is used, but for me it looks like that on these platforms is somehow null-term U-Boot version string important to be put after some magic number at specific location (start of the binary?).

How could we handle this situation? I do not have any of those powerpc platforms and I do not know any details about them.

If we cannot remove version string from this location, it is possible to tweak linker to put at this location version string from compiled cmd/version.o object file (at the time when building final u-boot binary)?

CCing powerpc maintainers.

Quoted 5 lines

Do you see where I'm thinking with this, or do I need to try and explain a bit more? Thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 1/1 tools: Remove #include <version.h>

Quoted 66 lines · On Wednesday 03 February 2021 12:10:13 Pali Roh?r wrote:
Quoted 37 lines · On Monday 01 February 2021 16:20:18 Tom Rini wrote:
Quoted 21 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +0 -0
index e5481435a7..54c2517c9e 100644

tools/dumpimage.c line 13

Quoted 8 lines
tools/dumpimage.c +1 -1
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 

I don't know if I really like this approach. It also seems inconsistent as we have for example tools/fit-image.c that has content from generated/version_autogenerated.h but wasn't changed by this patch (nor the rest of the series).

Quoted 8 lines

I think a bit more invasive approach is required here. I like the <version_string.h> approach you used elsewhere, and as best I can see, the only place U_BOOT_VERSION_STRING, which is where we have the timestamp itself, is used is cmd/version.c (and defined in version.h). We should isolate the file that has the date such that it's only in one file and referenced in one file. This means probably removing the version_string global from arch/{powerpc,m68k} and dropping __weak from cmd/version.c and seeing what happens, as well.

Hello! I have looked at dropping this weak property from version_string but seem it is not so easy... powerpc platforms have following code:

file arch/powerpc/cpu/mpc85xx/start.S:

.globl _start
_start:

       .long   0x27051956              /* U-BOOT Magic Number */
       .globl  version_string
version_string:
       .ascii U_BOOT_VERSION_STRING, "\0"

I do not know how it is used, but for me it looks like that on these platforms is somehow null-term U-Boot version string important to be put after some magic number at specific location (start of the binary?).

How could we handle this situation? I do not have any of those powerpc platforms and I do not know any details about them.

Quoted 6 lines

If we cannot remove version string from this location, it is possible to tweak linker to put at this location version string from compiled cmd/version.o object file (at the time when building final u-boot binary)?

CCing powerpc maintainers.

Hello! Do you have any details? Can be version_string at beginning dropped? Or it is required?

Quoted 8 lines
Quoted 6 lines

Do you see where I'm thinking with this, or do I need to try and explain a bit more? Thanks!

Signature · 1 line
Tom
#6 lore raw

PATCH 1/1 tools: Remove #include <version.h>

Quoted 72 lines · Pali Roh?r
Quoted 71 lines · On Wednesday 03 February 2021 12:10:13 Pali Roh?r wrote:
Quoted 37 lines · On Monday 01 February 2021 16:20:18 Tom Rini wrote:
Quoted 21 lines · Pali Roh?r

Header file version.h includes also autogenerated file timestamp.h which is recompiled on every time when SOURCE_DATE_EPOCH change.

Tools do not use build time therefore they do not have to include timestamp.h file.

This change prevents recompiling tools every time when SOURCE_DATE_EPOCH changes.

---
 tools/dumpimage.c  | 2 +-
 tools/mkenvimage.c | 2 +-
 tools/mkimage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tools/dumpimage.c +0 -0
index e5481435a7..54c2517c9e 100644

tools/dumpimage.c line 13

Quoted 8 lines
tools/dumpimage.c +1 -1
@@ -7,7 +7,7 @@
 
 #include "dumpimage.h"
 #include <image.h>
-#include <version.h>
+#include "generated/version_autogenerated.h"
 
 static void usage(void);
 

I don't know if I really like this approach. It also seems inconsistent as we have for example tools/fit-image.c that has content from generated/version_autogenerated.h but wasn't changed by this patch (nor the rest of the series).

Quoted 8 lines

I think a bit more invasive approach is required here. I like the <version_string.h> approach you used elsewhere, and as best I can see, the only place U_BOOT_VERSION_STRING, which is where we have the timestamp itself, is used is cmd/version.c (and defined in version.h). We should isolate the file that has the date such that it's only in one file and referenced in one file. This means probably removing the version_string global from arch/{powerpc,m68k} and dropping __weak from cmd/version.c and seeing what happens, as well.

Hello! I have looked at dropping this weak property from version_string but seem it is not so easy... powerpc platforms have following code:

file arch/powerpc/cpu/mpc85xx/start.S:

.globl _start
_start:

       .long   0x27051956              /* U-BOOT Magic Number */
       .globl  version_string
version_string:
       .ascii U_BOOT_VERSION_STRING, "\0"

I do not know how it is used, but for me it looks like that on these platforms is somehow null-term U-Boot version string important to be put after some magic number at specific location (start of the binary?).

How could we handle this situation? I do not have any of those powerpc platforms and I do not know any details about them.

If we cannot remove version string from this location, it is possible to tweak linker to put at this location version string from compiled cmd/version.o object file (at the time when building final u-boot binary)?

Quoted 4 lines
Quoted 1 line

CCing powerpc maintainers.

Hello! Do you have any details? Can be version_string at beginning dropped? Or it is required?

Should probably just go with trying linker games at this point, thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210225/e9e84b06/attachment.sig>