Skip to contentSkip to conversation

package/zstd: fix build failure on Microblaze

PATCH In review Giulio Benetti 1 participant 2 messages Aug 14, 2022 Zstd

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/zstd: fix build failure on Microblaze

Building for Microblaze leads to error:

```
util.c: In function 'UTIL_utime':
util.c:173:27: error: 'stat_t' {aka 'const struct stat'} has no member named 'st_mtim'; did you mean 'st_mtime'?
  173 |     timebuf[1] = statbuf->st_mtim;
      |                           ^~~~~~~
      |                           st_mtime
```

Let's define _POSIX_C_SOURCE=199309L to make st_mtim struct member visible again. Let's do this by using the already present MOREFLAGS variable since CFLAGS gets overridden through zstd configuration.

Fixes:
http://autobuild.buildroot.net/results/aba/abaf20f73303bf7dfde7983f32b36d43db897ced/

---
 package/zstd/zstd.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
package/zstd/zstd.mk +6 -1
index e8f6315222..6c8fcebd89 100644
@@ -36,7 +36,12 @@ ZSTD_OPTS += HAVE_LZ4=0
 endif
 
 # zstd will append -O3 after $(CFLAGS), use MOREFLAGS to override again
-ZSTD_OPTS += MOREFLAGS="$(TARGET_OPTIMIZATION)"
+ZSTD_MOREFLAGS = $(TARGET_OPTIMIZATION)
+
+# with glibc 'struct stat's member 'st_mtim' requires _POSIX_C_SOURCE=199309L
+ZSTD_MOREFLAGS += -D_POSIX_C_SOURCE=199309L
+
+ZSTD_OPTS += MOREFLAGS="$(ZSTD_MOREFLAGS)"
 
 ZSTD_BUILD_LIBS_BASENAMES = libzstd.pc
 ifeq ($(BR2_STATIC_LIBS),y)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Ah, I've found only now Arnout's patch for this:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Please drop it.

Sorry for the noise

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 28 lines · Giulio Benetti

Building for Microblaze leads to error:

```
util.c: In function 'UTIL_utime':
util.c:173:27: error: 'stat_t' {aka 'const struct stat'} has no member named 'st_mtim'; did you mean 'st_mtime'?
   173 |     timebuf[1] = statbuf->st_mtim;
       |                           ^~~~~~~
       |                           st_mtime
```

Let's define _POSIX_C_SOURCE=199309L to make st_mtim struct member visible again. Let's do this by using the already present MOREFLAGS variable since CFLAGS gets overridden through zstd configuration.

Fixes:
http://autobuild.buildroot.net/results/aba/abaf20f73303bf7dfde7983f32b36d43db897ced/

---
  package/zstd/zstd.mk | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
package/zstd/zstd.mk +0 -0
index e8f6315222..6c8fcebd89 100644
@@ -36,7 +36,12 @@ ZSTD_OPTS += HAVE_LZ4=0
  endif
 
  # zstd will append -O3 after $(CFLAGS), use MOREFLAGS to override again

package/zstd/zstd.mk ZSTD_OPTS += HAVE_LZ4=0 · line 47

Quoted 10 lines
package/zstd/zstd.mk +6 -1
-ZSTD_OPTS += MOREFLAGS="$(TARGET_OPTIMIZATION)"
+ZSTD_MOREFLAGS = $(TARGET_OPTIMIZATION)
+
+# with glibc 'struct stat's member 'st_mtim' requires _POSIX_C_SOURCE=199309L
+ZSTD_MOREFLAGS += -D_POSIX_C_SOURCE=199309L
+
+ZSTD_OPTS += MOREFLAGS="$(ZSTD_MOREFLAGS)"
 
  ZSTD_BUILD_LIBS_BASENAMES = libzstd.pc
  ifeq ($(BR2_STATIC_LIBS),y)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot