Skip to contentSkip to conversation

include: fix 'ulong' definition on musl targets

PATCH New Sergei Trofimovich 2 participants 6 messages Dec 16, 2019 – Dec 30, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include: fix 'ulong' definition on musl targets

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
In file included from tools/env/../../env/flags.c:7,
                 from tools/env/env_flags.c:1:
include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'?
  159 | ulong env_get_ulong(const char *name, int base, ulong default_val);
      | ^~~~~
      | long
```

Note: 'ulong' is not defined there.

On glibc 'ulong' comes from <sys/types.h>:

```c
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
```

On musl it comes from <sys/types.h> as well but from under different guards:

```c
typedef unsigned long u_long, ulong;
```

The change inlines 'ulong' define similar to 'uint' define.

---
 include/compiler.h   | 2 +-
 include/u-boot/crc.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
include/compiler.h +1 -1
index 29507f9840..90372f239c 100644
@@ -46,7 +46,6 @@
 # include <byteswap.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
-typedef unsigned long ulong;
 #endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
@@ -66,6 +65,7 @@ typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 #define uswap_16(x) \
 	((((x) & 0xff00) >> 8) | \
include/u-boot/crc.h +2 -0
index 1086d2168c..b96b50d98b 100644
@@ -8,6 +8,8 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
+#include <compiler.h> /* unit definition */
+
 /**
  * crc8() - Calculate and return CRC-8 of the data
  *
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/1 include: fix 'ulong' definition on musl targets

Quoted 66 lines · Sergei Trofimovich

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
In file included from tools/env/../../env/flags.c:7,
                 from tools/env/env_flags.c:1:
include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'?
  159 | ulong env_get_ulong(const char *name, int base, ulong default_val);
      | ^~~~~
      | long
```

Note: 'ulong' is not defined there.

On glibc 'ulong' comes from <sys/types.h>:

```c
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
```

On musl it comes from <sys/types.h> as well but from under different guards:

```c
typedef unsigned long u_long, ulong;
```

The change inlines 'ulong' define similar to 'uint' define.

---
 include/compiler.h   | 2 +-
 include/u-boot/crc.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
include/compiler.h +1 -1
index 29507f9840..90372f239c 100644
@@ -46,7 +46,6 @@
 # include <byteswap.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
-typedef unsigned long ulong;
 #endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
@@ -66,6 +65,7 @@ typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 #define uswap_16(x) \
        ((((x) & 0xff00) >> 8) | \
include/u-boot/crc.h +0 -0
index 1086d2168c..b96b50d98b 100644

include/u-boot/crc.h line 15

Quoted 8 lines
include/u-boot/crc.h +2 -0
@@ -8,6 +8,8 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
+#include <compiler.h> /* unit definition */
+
 /**
  * crc8() - Calculate and return CRC-8 of the data
  *

From the build log, 'ulong' in include/env.h is causing the error. So, 664689f1dcb178ccb36842d0564ea8a6e8a7e648
added <compiler.h> to it.

I do not see 'ulong' in include/u-boot/crc.h at all. Why do you need to touch include/u-boot/crc.h ?

--
Best Regards
Masahiro Yamada

#2 lore raw

PATCH 1/1 include: fix 'ulong' definition on musl targets

Quoted 82 lines · On Mon, 30 Dec 2019 20:24:08 +0900 Masahiro Yamada <[email protected]> wrote:
Quoted 66 lines · Sergei Trofimovich

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
In file included from tools/env/../../env/flags.c:7,
                 from tools/env/env_flags.c:1:
include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'?
  159 | ulong env_get_ulong(const char *name, int base, ulong default_val);
      | ^~~~~
      | long
```

Note: 'ulong' is not defined there.

On glibc 'ulong' comes from <sys/types.h>:

```c
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
```

On musl it comes from <sys/types.h> as well but from under different guards:

```c
typedef unsigned long u_long, ulong;
```

The change inlines 'ulong' define similar to 'uint' define.

---
 include/compiler.h   | 2 +-
 include/u-boot/crc.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
include/compiler.h +1 -1
index 29507f9840..90372f239c 100644
@@ -46,7 +46,6 @@
 # include <byteswap.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
-typedef unsigned long ulong;
 #endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
@@ -66,6 +65,7 @@ typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 #define uswap_16(x) \
        ((((x) & 0xff00) >> 8) | \
include/u-boot/crc.h +0 -0
index 1086d2168c..b96b50d98b 100644

include/u-boot/crc.h line 15

Quoted 8 lines
include/u-boot/crc.h +2 -0
@@ -8,6 +8,8 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
+#include <compiler.h> /* unit definition */
+
 /**
  * crc8() - Calculate and return CRC-8 of the data
  *  

From the build log, 'ulong' in include/env.h is causing the error. So, 664689f1dcb178ccb36842d0564ea8a6e8a7e648
added <compiler.h> to it.

Quoted 2 lines

I do not see 'ulong' in include/u-boot/crc.h at all. Why do you need to touch include/u-boot/crc.h ?

Oh, I forgot to post another build failure in commit message:

```
include/u-boot/crc.h:37:44: error: unknown type name 'uint'; did you mean 'int'?
   37 | void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
      |                                            ^~~~
      |                                            int
```
Signature · 1 line
  Sergei
#3 lore raw

PATCH 1/1 include: fix 'ulong' definition on musl targets

Quoted 89 lines · Sergei Trofimovich
Quoted 82 lines · On Mon, 30 Dec 2019 20:24:08 +0900 Masahiro Yamada <[email protected]> wrote:
Quoted 66 lines · Sergei Trofimovich

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
In file included from tools/env/../../env/flags.c:7,
                 from tools/env/env_flags.c:1:
include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'?
  159 | ulong env_get_ulong(const char *name, int base, ulong default_val);
      | ^~~~~
      | long
```

Note: 'ulong' is not defined there.

On glibc 'ulong' comes from <sys/types.h>:

```c
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
```

On musl it comes from <sys/types.h> as well but from under different guards:

```c
typedef unsigned long u_long, ulong;
```

The change inlines 'ulong' define similar to 'uint' define.

---
 include/compiler.h   | 2 +-
 include/u-boot/crc.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
include/compiler.h +1 -1
index 29507f9840..90372f239c 100644
@@ -46,7 +46,6 @@
 # include <byteswap.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
-typedef unsigned long ulong;
 #endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
@@ -66,6 +65,7 @@ typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 #define uswap_16(x) \
        ((((x) & 0xff00) >> 8) | \
include/u-boot/crc.h +0 -0
index 1086d2168c..b96b50d98b 100644

include/u-boot/crc.h line 15

Quoted 8 lines
include/u-boot/crc.h +2 -0
@@ -8,6 +8,8 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
+#include <compiler.h> /* unit definition */
+
 /**
  * crc8() - Calculate and return CRC-8 of the data
  *

From the build log, 'ulong' in include/env.h is causing the error. So, 664689f1dcb178ccb36842d0564ea8a6e8a7e648
added <compiler.h> to it.

Quoted 2 lines

I do not see 'ulong' in include/u-boot/crc.h at all. Why do you need to touch include/u-boot/crc.h ?

Quoted 9 lines

Oh, I forgot to post another build failure in commit message:

```
include/u-boot/crc.h:37:44: error: unknown type name 'uint'; did you mean 'int'?
   37 | void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
      |                                            ^~~~
      |                                            int
```

Maybe, this can be split into two patches ?
I think this patch is addressing two issues.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

PATCH v2 1/2 include: fix 'ulong' definition on musl targets

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
In file included from tools/env/../../env/flags.c:7,
                 from tools/env/env_flags.c:1:
include/env.h:159:1: error: unknown type name 'ulong'; did you mean 'long'?
  159 | ulong env_get_ulong(const char *name, int base, ulong default_val);
      | ^~~~~
      | long
```

Note: 'ulong' is not defined there.

On glibc 'ulong' comes from <sys/types.h>:

```c
/* Old compatibility names for C types.  */
typedef unsigned long int ulong;
```

On musl it comes from <sys/types.h> as well but from under different guards:

```c
typedef unsigned long u_long, ulong;
```

The change inlines 'ulong' define similar to 'uint' define.

---
 include/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/compiler.h +1 -1
index 29507f9840..90372f239c 100644
@@ -46,7 +46,6 @@
 # include <byteswap.h>
 #elif defined(__MACH__) || defined(__FreeBSD__)
 # include <machine/endian.h>
-typedef unsigned long ulong;
 #endif
 #ifdef __FreeBSD__
 # include <sys/endian.h> /* htole32 and friends */
@@ -66,6 +65,7 @@ typedef uint8_t __u8;
 typedef uint16_t __u16;
 typedef uint32_t __u32;
 typedef unsigned int uint;
+typedef unsigned long ulong;
 
 #define uswap_16(x) \
 	((((x) & 0xff00) >> 8) | \
Signature · 1 line
2.24.1
#5 lore raw

PATCH v2 2/2 include/u-boot/crc.h: pull 'uint' definition on musl targets

The build failure was originally reported on arm64-musl target at https://bugs.gentoo.org/703132. Here is the amd64-musl variant:

```
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-only_defconfig -j$(nproc)
$ LANG=C make CROSS_COMPILE=x86_64-gentoo-linux-musl- tools-all            -j$(nproc)
...
include/u-boot/crc.h:37:44: error: unknown type name 'uint'; did you mean 'int'?
   37 | void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
      |                                            ^~~~
      |                                            int
```

Note: 'uint' is not defined there.

On glibc 'uint' comes from <sys/types.h> and happens to work on most .c files.

The change imports 'uint' declaration from '<compiler.h>'.

---
 include/u-boot/crc.h | 2 ++
 1 file changed, 2 insertions(+)
include/u-boot/crc.h +2 -0
index 1086d2168c..bfd477f31d 100644
@@ -8,6 +8,8 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
+#include <compiler.h> /* 'uint*' definitions */
+
 /**
  * crc8() - Calculate and return CRC-8 of the data
  *
Signature · 1 line
2.24.1