tools/7z: Allow building on alpine
authorOlliver Schinagl <oliver@schinagl.nl>
Thu, 16 Feb 2023 14:25:12 +0000 (15:25 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 2 Apr 2023 18:35:15 +0000 (20:35 +0200)
When using alpine as host, things start to fail. Lets pull in the
upstream alpine patches to make things work. This should not affect
other hosts.

Note, that Alpine has the '_GNU_SOURCE' define in the APKBUILD file, but
here we add this flag to the needed fix flags patch, which does similar
things too.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
tools/7z/patches/7-zip-flags.patch [new file with mode: 0644]
tools/7z/patches/7-zip-musl.patch [new file with mode: 0644]

diff --git a/tools/7z/patches/7-zip-flags.patch b/tools/7z/patches/7-zip-flags.patch
new file mode 100644 (file)
index 0000000..ed5b508
--- /dev/null
@@ -0,0 +1,27 @@
+--- a/CPP/7zip/7zip_gcc.mak
++++ b/CPP/7zip/7zip_gcc.mak
+@@ -18,13 +18,13 @@ PROGPATH_STATIC = $(O)/$(PROG)s
\r
\r
+ ifneq ($(CC), xlc)\r
+-CFLAGS_WARN_WALL = -Wall -Werror -Wextra\r
++CFLAGS_WARN_WALL = -Wall -Wextra\r
+ endif\r
\r
+ # for object file\r
+ CFLAGS_BASE_LIST = -c\r
+ # CFLAGS_BASE_LIST = -S\r
+-CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \\r
++CFLAGS_BASE = $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) -D_GNU_SOURCE \\r
+  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \\r
+  -fPIC\r
\r
+@@ -192,7 +192,7 @@ all: $(O) $(PROGPATH) $(STATIC_TARGET)
+ $(O):\r
+       $(MY_MKDIR) $(O)\r
\r
+-LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)\r
++LFLAGS_ALL = $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2)\r
+ $(PROGPATH): $(OBJS)\r
+       $(CXX) -o $(PROGPATH) $(LFLAGS_ALL)\r
\r
diff --git a/tools/7z/patches/7-zip-musl.patch b/tools/7z/patches/7-zip-musl.patch
new file mode 100644 (file)
index 0000000..cf3386e
--- /dev/null
@@ -0,0 +1,59 @@
+--- a/C/CpuArch.c
++++ b/C/CpuArch.c
+@@ -421,8 +421,6 @@ BoolInt CPU_IsSupported_AES (void) { ret
\r
+ #ifdef USE_HWCAP\r
\r
+-#include <asm/hwcap.h>\r
+-\r
+   #define MY_HWCAP_CHECK_FUNC_2(name1, name2) \\r
+   BoolInt CPU_IsSupported_ ## name1() { return (getauxval(AT_HWCAP)  & (HWCAP_  ## name2)) ? 1 : 0; }\r
\r
+--- a/C/Threads.c
++++ b/C/Threads.c
+@@ -257,7 +257,7 @@ WRes Thread_Create_With_CpuSet(CThread *
+       */\r
\r
+       // ret2 =\r
+-      pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet);\r
++      //pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet);\r
+       // if (ret2) ret = ret2;\r
+       #endif\r
+     }\r
+@@ -267,14 +267,12 @@ WRes Thread_Create_With_CpuSet(CThread *
+     if (!ret)\r
+     {\r
+       p->_created = 1;\r
+-      /*\r
+       if (cpuSet)\r
+       {\r
+         // ret2 =\r
+         pthread_setaffinity_np(p->_tid, sizeof(*cpuSet), cpuSet);\r
+         // if (ret2) ret = ret2;\r
+       }\r
+-      */\r
+     }\r
+   }\r
+   // ret2 =\r
+--- a/C/Threads.h
++++ b/C/Threads.h
+@@ -19,6 +19,7 @@
+ #endif\r
\r
+ #include <pthread.h>\r
++#include <sched.h>\r
\r
+ #endif\r
\r
+--- a/CPP/Windows/SystemInfo.cpp
++++ b/CPP/Windows/SystemInfo.cpp
+@@ -36,9 +36,6 @@
+ #endif\r
+ */\r
\r
+-#ifdef MY_CPU_ARM_OR_ARM64\r
+-#include <asm/hwcap.h>\r
+-#endif\r
+ #endif\r
\r
+ #ifdef __linux__\r