!47 [sync] PR-46: [平行宇宙] Support build with clang

From: @openeuler-sync-bot 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2024-04-16 09:22:29 +00:00 committed by Gitee
commit 1e0b652e11
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 84 additions and 2 deletions

View File

@ -0,0 +1,73 @@
From 3ac162e9f6ff4b138f3141af2b5c345b9c9b4ee1 Mon Sep 17 00:00:00 2001
From: Cheng Li <cheng@kubuds.cn>
Date: Tue, 9 Apr 2024 13:46:50 +0000
Subject: [PATCH] unzip-6.0-support-clang-build
---
unix/Makefile | 15 +++++++++------
unix/configure | 2 ++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/unix/Makefile b/unix/Makefile
index ab32270..3de8873 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -42,12 +42,12 @@
# such as -DDOSWILD).
# UnZip flags
-CC = cc# try using "gcc" target rather than changing this (CC and LD
+CC ?= cc# try using "gcc" target rather than changing this (CC and LD
LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
AS = as
LOC = $(D_USE_BZ2) $(LOCAL_UNZIP)
AF = $(LOC)
-CFLAGS = -O
+CFLAGS ?= -O
CF_NOOPT = -I. -I$(IZ_BZIP2) -DUNIX $(LOC)
CF = $(CFLAGS) $(CF_NOOPT)
LFLAGS1 =
@@ -547,6 +547,9 @@ generic: flags # now try autoconfigure first
generic_gcc:
$(MAKE) $(MAKEF) generic CC=gcc IZ_BZIP2="$(IZ_BZIP2)"
+generic_clang:
+ $(MAKE) $(MAKEF) generic CC=clang IZ_BZIP2="$(IZ_BZIP2)"
+
# extensions to perform SVR4 package-creation after compilation
generic_pkg: generic svr4package
generic_gccpkg: generic_gcc svr4package
@@ -594,13 +597,13 @@ generic_shlib: unix_make
@echo\
'which is UnZip linked with the DLL). This target is an example only.'
@echo ""
- $(MAKE) objsdll CC=gcc CFLAGS="-O3 -Wall -fPIC -DDLL"
- gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL)
+ $(MAKE) objsdll CFLAGS="-O3 -Wall -fPIC -DDLL"
+ $(CC) -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL)
$(RM) libunzip.so.0 libunzip.so
$(LN) -s libunzip.so.0.4 libunzip.so.0
$(LN) -s libunzip.so.0 libunzip.so
- gcc -c -O unzipstb.c
- gcc -o unzip_shlib unzipstb.o -L. -lunzip
+ $(CC) -c -O unzipstb.c
+ $(CC) -o unzip_shlib unzipstb.o -L. -lunzip
#----------------------------------------------------------------------------
# "Autoconfig" group, aliases for the generic targets using configure:
diff --git a/unix/configure b/unix/configure
index 4d6f867..c231721 100755
--- a/unix/configure
+++ b/unix/configure
@@ -432,6 +432,8 @@ if [ $? -ne 0 ]; then
done
if [ ${OPT} ]; then
LFLAGS2="${LFLAGS2} ${OPT}"
+ elif [ "$CC" == "clang" ]; then
+ CFLAGSR="${CFLAGSR}"
else
CFLAGSR="${CFLAGSR} -DNO_DIR"
fi
--
2.41.0

View File

@ -1,6 +1,6 @@
Name: unzip Name: unzip
Version: 6.0 Version: 6.0
Release: 51 Release: 52
Summary: A utility for unpacking zip files Summary: A utility for unpacking zip files
License: Info-ZIP,Public Domain License: Info-ZIP,Public Domain
URL: http://www.info-zip.org/UnZip.html URL: http://www.info-zip.org/UnZip.html
@ -29,6 +29,7 @@ Patch0020: unzip-6.0-alt-iconv-utf8-print.patch
Patch0021: 0001-Fix-CVE-2016-9844-rhbz-1404283.patch Patch0021: 0001-Fix-CVE-2016-9844-rhbz-1404283.patch
Patch0022: unzip-6.0-timestamp.patch Patch0022: unzip-6.0-timestamp.patch
Patch0023: unzip-6.0-cve-2018-1000035-heap-based-overflow.patch Patch0023: unzip-6.0-cve-2018-1000035-heap-based-overflow.patch
Patch0024: unzip-6.0-support-clang-build.patch
Patch6000: CVE-2018-18384.patch Patch6000: CVE-2018-18384.patch
Patch6001: CVE-2019-13232-pre.patch Patch6001: CVE-2019-13232-pre.patch
@ -58,8 +59,13 @@ Package help includes man pages for unzip.
%build %build
export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -fPIE" export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -fPIE"
%make_build -f unix/Makefile CF_NOOPT="-I. -DUNIX $RPM_OPT_FLAGS -DNOMEMCPY -DIZ_HAVE_UXUIDGID -DNO_LCHMOD" \ %if "%{?toolchain}" == "clang"
%make_build -f unix/Makefile CF_NOOPT="-I. -DUNIX $RPM_OPT_FLAGS -DNOMEMCPY -DIZ_HAVE_UXUIDGID -DNO_LCHMOD" \
LFLAGS2="-Wl,-z,relro -pie" generic_clang
%else
%make_build -f unix/Makefile CF_NOOPT="-I. -DUNIX $RPM_OPT_FLAGS -DNOMEMCPY -DIZ_HAVE_UXUIDGID -DNO_LCHMOD" \
LFLAGS2="-Wl,-z,relro -pie" generic_gcc LFLAGS2="-Wl,-z,relro -pie" generic_gcc
%endif
%install %install
%make_install -f unix/Makefile prefix=$RPM_BUILD_ROOT%{_prefix} MANDIR=$RPM_BUILD_ROOT%{_mandir}/man1 INSTALL="cp -p" %make_install -f unix/Makefile prefix=$RPM_BUILD_ROOT%{_prefix} MANDIR=$RPM_BUILD_ROOT%{_mandir}/man1 INSTALL="cp -p"
@ -76,6 +82,9 @@ make check -f unix/Makefile
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Sun Apr 7 2024 licheng <cheng@kubuds.cn> - 6.0-52
- add support for clang
* Sat Mar 4 2023 yanglongkang <yanglongkang@h-partners.com> - 6.0-51 * Sat Mar 4 2023 yanglongkang <yanglongkang@h-partners.com> - 6.0-51
- add "PIE" compiler options - add "PIE" compiler options