Bug 260329 - archivers/7-zip: Fails to compile on 13-STABLE aarch64
Summary: archivers/7-zip: Fails to compile on 13-STABLE aarch64
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Max Brazhnikov
URL:
Keywords:
: 261384 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-12-11 00:39 UTC by Daniel Engberg
Modified: 2022-08-18 17:19 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (makc)


Attachments
v0 (3.36 KB, patch)
2021-12-15 12:24 UTC, Mikael Urankar
no flags Details | Diff
Patch for C/7zCrc.c (520 bytes, patch)
2022-01-30 17:57 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2021-12-11 00:39:43 UTC
===>   7-zip-21.06 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by 7-zip-21.06 for building
===>  Extracting for 7-zip-21.06
=> SHA256 Checksum OK for 7z2106-src.7z.
===>  Patching for 7-zip-21.06
===>   Converting DOS text files to UNIX text files
===>  Applying FreeBSD patches for 7-zip-21.06 from /usr/ports/archivers/7-zip/files
echo > /usr/ports/archivers/7-zip/work/7-zip-21.06/CPP/7zip/warn_clang.mak
===>   7-zip-21.06 depends on package: gmake>=4.3 - found
===>   7-zip-21.06 depends on shared library: libsysinfo.so - found (/usr/local/lib/libsysinfo.so)
===>  Configuring for 7-zip-21.06
===>  Building for 7-zip-21.06
gmake[2]: Entering directory '/usr/ports/archivers/7-zip/work/7-zip-21.06/CPP/7zip/Bundles/Alone2'
mkdir -p b/c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/7zBuf2.o ../../../../C/7zBuf2.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/7zStream.o ../../../../C/7zStream.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Alloc.o ../../../../C/Alloc.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Bcj2.o ../../../../C/Bcj2.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Bcj2Enc.o ../../../../C/Bcj2Enc.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Blake2s.o ../../../../C/Blake2s.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Bra.o ../../../../C/Bra.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Bra86.o ../../../../C/Bra86.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/BraIA64.o ../../../../C/BraIA64.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/BwtSort.o ../../../../C/BwtSort.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/CpuArch.o ../../../../C/CpuArch.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/Delta.o ../../../../C/Delta.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/HuffEnc.o ../../../../C/HuffEnc.c
clang  -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -O2 -c -Wall -Werror -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC -O2 -pipe -mcpu=cortex-a53  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing   -o b/c/LzFind.o ../../../../C/LzFind.c
../../../../C/CpuArch.c:424:10: fatal error: 'asm/hwcap.h' file not found
#include <asm/hwcap.h>
         ^~~~~~~~~~~~~
1 error generated.
gmake[2]: *** [../../7zip_gcc.mak:1049: b/c/CpuArch.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/usr/ports/archivers/7-zip/work/7-zip-21.06/CPP/7zip/Bundles/Alone2'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/archivers/7-zip
*** Error code 1

Stop.
make: stopped in /usr/ports/archivers/7-zip
Comment 1 Chris Hutchinson 2021-12-11 03:54:16 UTC
This port appears to essentially be a duplicate of archivers/p7zip
If archivers/p7zip works for you (as it should). This port
a moot. :-)
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2021-12-11 07:07:18 UTC
Hi Chris, p7zip is based on a several years old code base that has known vulns and is abandoned. This is the "current" upstream and "official" code base.
Comment 3 Chris Hutchinson 2021-12-11 07:45:11 UTC
(In reply to Daniel Engberg from comment #2)
Ahh. OK fair enough. It was easy to get the impression this
was just another version of the same. I now see p7zip has
also been abandoned in the ports tree. Maybe this version
might add a comment to the effect that this is a replacement
for archivers/p7zip. Users might also benefit from having
p7zip being removed from the tree. I'll submit a pr with
an expiration date for it.

Thanks for the heads-up, Dan. :-)

--Chris
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2021-12-15 12:24:58 UTC
Created attachment 230136 [details]
v0

Try the attached patch.
Comment 5 Daniel Engberg freebsd_committer freebsd_triage 2021-12-19 19:38:02 UTC
Seems to work although I'm not sure if we should enforce the cflags instead of encouraging people to use CPUTYPE variable instead?
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-12-28 14:45:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b6bf306d87ea3b01bbdeb47688b2456fdca04ad7

commit b6bf306d87ea3b01bbdeb47688b2456fdca04ad7
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2021-12-28 14:32:52 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2021-12-28 14:32:57 +0000

    archivers/7-zip: Update to 21.07

    Merge patches to fix build on arm64 [1].

    PR:             260329 [1]
    Reported by:    diizzy@
    Submitted by:   mikael@

 archivers/7-zip/Makefile                           |  6 ++--
 archivers/7-zip/distinfo                           |  6 ++--
 .../7-zip/files/patch-CPP_Windows_SystemInfo.cpp   | 11 ++++++-
 archivers/7-zip/files/patch-C_CpuArch.c (new)      | 34 ++++++++++++++++++++++
 4 files changed, 50 insertions(+), 7 deletions(-)
Comment 7 Max Brazhnikov freebsd_committer freebsd_triage 2021-12-28 14:56:00 UTC
(In reply to Daniel Engberg from comment #5)
Daniel, Mikael could you enlighten me on this CPUTYPE/CFLAGS topic? I've just committed the patch without CFLAGS_aarch64 bits.
Comment 8 Daniel Engberg freebsd_committer freebsd_triage 2021-12-28 21:28:37 UTC
I think trying to handle CPU specific features within a port unless autodetection is broken and the amount of work to fix it is unreasonable should be avoided as it can easily become a mess when you have ports hardsetting CPU specific optimizations. While I haven't specifically looked  into 7-zip it may cause the application/library to be broken if there's no run-time detection in place for said feature(s) and we do have global variable to define a specific CPU these called CPUTYPE which gets passed on as -mcpu=XXX

https://cgit.freebsd.org/src/tree/share/examples/etc/make.conf#n25
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2022-01-17 08:09:40 UTC
(In reply to Max Brazhnikov from comment #7)
It's required because IIRC clang doesn't understand some attributes and fails to build 7zip:

../../../../C/7zCrc.c:158:1: warning: unknown architecture 'armv8-a+crc' in the 'target' attribute string; 'target' attribute ignored [-Wignored-attributes]                                                      
ATTRIB_CRC
snip
../../../../C/Sha256Opt.c:329:5: error: assigning to 'v128' (aka 'uint32x4_t') from incompatible type 'int'                                                                                                       
    R16 ( 0, NNN, NNN, SM1, NNN, SM1, SM2, SM1, SM2 );
Comment 10 Mikael Urankar freebsd_committer freebsd_triage 2022-01-30 16:17:17 UTC
*** Bug 261384 has been marked as a duplicate of this bug. ***
Comment 11 commit-hook freebsd_committer freebsd_triage 2022-01-30 17:31:04 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3d0da7220ca950600c5ddaf70797c27b00803a5c

commit 3d0da7220ca950600c5ddaf70797c27b00803a5c
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2022-01-30 17:29:49 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2022-01-30 17:29:49 +0000

    archivers/7-zip: set CFLAGS to fix build on aarch64

    The code will use CRC instructions at runtime if available.

    PR:     260329

 archivers/7-zip/Makefile | 1 +
 1 file changed, 1 insertion(+)
Comment 12 Max Brazhnikov freebsd_committer freebsd_triage 2022-01-30 17:32:09 UTC
Fixed now, thanks!
Comment 13 Dimitry Andric freebsd_committer freebsd_triage 2022-01-30 17:57:33 UTC
Created attachment 231450 [details]
Patch for C/7zCrc.c

Please try dropping the attached patch into archivers/7-zip/files, and recompiling for aarch64.
Comment 14 Max Brazhnikov freebsd_committer freebsd_triage 2022-01-30 20:27:03 UTC
Folks, rollback CFLAGS changes and test Dimitry's patch  please.
Comment 15 Mikael Urankar freebsd_committer freebsd_triage 2022-01-31 17:46:58 UTC
(In reply to Dimitry Andric from comment #13)
The issue is the same.
Comment 16 tech-lists 2022-02-01 01:33:01 UTC
I confirm the patch in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260329#c13 coes not fix the problem
Comment 17 Daniel Engberg freebsd_committer freebsd_triage 2022-08-18 17:19:54 UTC
Compiles on aarch64 for a few months by now