mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
zip: fix configure check by using _Static_assert
It's incorrect to run a cross-compiled program on build machine to check if some feature is available or not. As these two checks in zip are basically just checking the size, we can use _Static_assert and sizeof to do such check at compile time. (From OE-Core rev: dda778d855b1838ae3004a9af310724b913490b4) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
From 9916fc6f1f93f3e092e3c6937c30dc8137c26d34 Mon Sep 17 00:00:00 2001
|
||||
From: Chen Qi <Qi.Chen@windriver.com>
|
||||
Date: Thu, 15 Jun 2023 18:31:26 +0800
|
||||
Subject: [PATCH] unix/configure: use _Static_assert to do correct detection
|
||||
|
||||
We're doing cross compilation, running a cross-compiled problem
|
||||
on host to detemine feature is not correct. Use _Static_assert
|
||||
to do the detection correctly.
|
||||
|
||||
Upstream-Status: Inactive-Upstream
|
||||
|
||||
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
|
||||
---
|
||||
unix/configure | 42 ++++++++++++------------------------------
|
||||
1 file changed, 12 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/unix/configure b/unix/configure
|
||||
index f2b3d02..f917086 100644
|
||||
--- a/unix/configure
|
||||
+++ b/unix/configure
|
||||
@@ -361,6 +361,10 @@ cat > conftest.c << _EOF_
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
+
|
||||
+_Static_assert(sizeof((struct stat){0}.st_uid) == 2, "sizeof st_uid is not 16 bit");
|
||||
+_Static_assert(sizeof((struct stat){0}.st_gid) == 2, "sizeof st_gid is not 16 bit");
|
||||
+
|
||||
int main()
|
||||
{
|
||||
struct stat s;
|
||||
@@ -385,21 +389,7 @@ if [ $? -ne 0 ]; then
|
||||
echo -- UID/GID test failed on compile - disabling old 16-bit UID/GID support
|
||||
CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
|
||||
else
|
||||
-# run it
|
||||
- ./conftest
|
||||
- r=$?
|
||||
- if [ $r -eq 1 ]; then
|
||||
- echo -- UID not 2 bytes - disabling old 16-bit UID/GID support
|
||||
- CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
|
||||
- elif [ $r -eq 2 ]; then
|
||||
- echo -- GID not 2 bytes - disabling old 16-bit UID/GID support
|
||||
- CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
|
||||
- elif [ $r -eq 3 ]; then
|
||||
- echo -- 16-bit UIDs and GIDs - keeping old 16-bit UID/GID support
|
||||
- else
|
||||
- echo -- test failed - conftest returned $r - disabling old 16-bit UID/GID support
|
||||
- CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
|
||||
- fi
|
||||
+ echo -- 16-bit UIDs and GIDs - keeping old 16-bit UID/GID support
|
||||
fi
|
||||
|
||||
|
||||
@@ -417,6 +407,10 @@ cat > conftest.c << _EOF_
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
+
|
||||
+_Static_assert(sizeof(off_t) < 8, "sizeof off_t < 8 failed");
|
||||
+_Static_assert(sizeof((struct stat){0}.st_size) < 8, "sizeof st_size < 8 failed");
|
||||
+
|
||||
int main()
|
||||
{
|
||||
off_t offset;
|
||||
@@ -436,24 +430,12 @@ _EOF_
|
||||
# compile it
|
||||
$CC -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
- echo -- no Large File Support
|
||||
+ echo -- yes we have Large File Support!
|
||||
+ CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
|
||||
else
|
||||
-# run it
|
||||
- ./conftest
|
||||
- r=$?
|
||||
- if [ $r -eq 1 ]; then
|
||||
- echo -- no Large File Support - no 64-bit off_t
|
||||
- elif [ $r -eq 2 ]; then
|
||||
- echo -- no Large File Support - no 64-bit stat
|
||||
- elif [ $r -eq 3 ]; then
|
||||
- echo -- yes we have Large File Support!
|
||||
- CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
|
||||
- else
|
||||
- echo -- no Large File Support - conftest returned $r
|
||||
- fi
|
||||
+ echo -- no Large File Support
|
||||
fi
|
||||
|
||||
-
|
||||
# Check for wide char for Unicode support
|
||||
# Added 11/24/2005 EG
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -19,6 +19,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/infozip/Zip%203.x%20%28latest%29/3.0/zip30.tar.
|
||||
file://0001-configure-Use-CFLAGS-and-LDFLAGS-when-doing-link-tes.patch \
|
||||
file://0001-configure-Specify-correct-function-signatures-and-de.patch \
|
||||
file://0002-unix.c-Do-not-redefine-DIR-as-FILE.patch \
|
||||
file://0001-unix-configure-use-_Static_assert-to-do-correct-dete.patch \
|
||||
"
|
||||
UPSTREAM_VERSION_UNKNOWN = "1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user