Bug 223072 - emulators/qemu-user-static: poudriere bulk with arm building zstd-1.3.2 failed with clang-bug
Summary: emulators/qemu-user-static: poudriere bulk with arm building zstd-1.3.2 faile...
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
: 223693 223809 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-10-17 21:17 UTC by punasipuli
Modified: 2018-12-22 13:29 UTC (History)
5 users (show)

See Also:


Attachments
fatal error: error in backend: Found 2 machine code errors. (212.99 KB, application/x-xz-compressed-tar)
2017-10-20 20:53 UTC, punasipuli
no flags Details
patch (518 bytes, patch)
2017-11-27 09:52 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description punasipuli 2017-10-17 21:17:55 UTC
Compiling zstd-1.3.2 with poudriere faild with clang-bug:

*** Bad machine code: Using an undefined physical register ***
- function:    ZSTD_compress_generic
- basic block: BB#13 if.end26 (0x803d13230)
- instruction: %R1<def> = SBCri
- operand 6:   %CPSR<imp-use,kill>

*** Bad machine code: Using an undefined physical register ***
- function:    ZSTD_compress_generic
- basic block: BB#17 if.else (0x803d13d70)
- instruction: %R0<def> = SBCri
- operand 6:   %CPSR<imp-use,kill>
fatal error: error in backend: Found 2 machine code errors.
make: Working in: /usr/ports/archivers/zstd
make: Working in: /usr/ports/archivers/zstd
cc: error: clang frontend command failed with exit code 70 (use -v to see invocation)
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: armv6--freebsd12.0-gnueabihf
Thread model: posix
InstalledDir: /nxb-bin/usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
cc: note: diagnostic msg: 


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/entropy_common-7aec92.c
cc: note: diagnostic msg: /tmp/error_private-f44dfb.c
cc: note: diagnostic msg: /tmp/fse_decompress-a48448.c
cc: note: diagnostic msg: /tmp/pool-cf8b86.c
cc: note: diagnostic msg: /tmp/threading-91279d.c
cc: note: diagnostic msg: /tmp/xxhash-11d006.c
cc: note: diagnostic msg: /tmp/zstd_common-20f28f.c
cc: note: diagnostic msg: /tmp/fse_compress-dba9c1.c
cc: note: diagnostic msg: /tmp/huf_compress-1b8fa5.c
cc: note: diagnostic msg: /tmp/zstd_compress-957e02.c
cc: note: diagnostic msg: /tmp/zstd_double_fast-55c4ae.c
cc: note: diagnostic msg: /tmp/zstd_fast-002820.c
cc: note: diagnostic msg: /tmp/zstd_lazy-659321.c
cc: note: diagnostic msg: /tmp/zstd_ldm-c1e6e3.c
cc: note: diagnostic msg: /tmp/zstd_opt-a2323d.c
cc: note: diagnostic msg: /tmp/zstdmt_compress-2bf1bc.c
cc: note: diagnostic msg: /tmp/huf_decompress-6a9bcd.c
cc: note: diagnostic msg: /tmp/zstd_decompress-a9b023.c
cc: note: diagnostic msg: /tmp/cover-2d97d9.c
cc: note: diagnostic msg: /tmp/divsufsort-c567c9.c
cc: note: diagnostic msg: /tmp/zdict-aa1a6e.c
cc: note: diagnostic msg: /tmp/zstd_v04-1642bc.c
cc: note: diagnostic msg: /tmp/zstd_v05-aef18f.c
cc: note: diagnostic msg: /tmp/zstd_v06-9f0f57.c
cc: note: diagnostic msg: /tmp/zstd_v07-81cff0.c
cc: note: diagnostic msg: /tmp/entropy_common-7aec92.sh
cc: note: diagnostic msg: 

********************
gmake[2]: *** [Makefile:151: zstd] Error 70
gmake[2]: Leaving directory '/wrkdirs/usr/ports/archivers/zstd/work/zstd-1.3.2/programs'
gmake[1]: *** [Makefile:63: zstd-release] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/archivers/zstd/work/zstd-1.3.2'
*** Error code 1

Stop.
make: stopped in /usr/ports/archivers/zstd
=>> Cleaning up wrkdir
===>  Cleaning for zstd-1.3.2
build of archivers/zstd | zstd-1.3.2 ended at Tue Oct 17 22:42:55 CEST 2017
build time: 00:01:23
!!! build failure encountered !!!

Unfortunately I don't know how to retrieve the files for the bug report from the jail. maybe someone has a hint.
Comment 1 Baptiste Daroussin freebsd_committer freebsd_triage 2017-10-19 05:09:33 UTC
Back to triage this is not a portmgr bug, more a qemu bug, very probably a resource exhaustion problem (because qemu)
Comment 2 Mikael Urankar freebsd_committer freebsd_triage 2017-10-19 15:32:30 UTC
it's a clang bug not a qemu one, it happens on real hw:


Assertion failed: (LiveCPSR && "CPSR liveness tracking is wrong!"), function UpdateCPSRUse, file /usr/src/contrib/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp, line 961.
cc -O -pipe  -fno-strict-aliasing    -I. -I./common -DXXH_NAMESPACE=ZSTD_ -I./legacy -DZSTD_LEGACY_SUPPORT=4  -c -o legacy/zstd_v04.o legacy/zstd_v04.c
cc -O -pipe  -fno-strict-aliasing    -I. -I./common -DXXH_NAMESPACE=ZSTD_ -I./legacy -DZSTD_LEGACY_SUPPORT=4  -c -o legacy/zstd_v05.o legacy/zstd_v05.c
cc: error: unable to execute command: Abort trap (core dumped)
cc: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 5.0.0 (branches/release_50 311219) (based on LLVM 5.0.0svn)
Target: armv6-unknown-freebsd12.0-gnueabihf
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/entropy_common-038a7d.c
cc: note: diagnostic msg: /tmp/error_private-763251.c
cc: note: diagnostic msg: /tmp/fse_decompress-c60546.c
cc: note: diagnostic msg: /tmp/pool-85db80.c
cc: note: diagnostic msg: /tmp/threading-0e7bbe.c
cc: note: diagnostic msg: /tmp/xxhash-fb5059.c
cc: note: diagnostic msg: /tmp/zstd_common-d9cb88.c
cc: note: diagnostic msg: /tmp/fse_compress-02f51d.c
cc: note: diagnostic msg: /tmp/huf_compress-ec3742.c
cc: note: diagnostic msg: /tmp/zstd_compress-85f117.c
cc: note: diagnostic msg: /tmp/zstd_double_fast-bd3b0f.c
cc: note: diagnostic msg: /tmp/zstd_fast-44dcb2.c
cc: note: diagnostic msg: /tmp/zstd_lazy-d23ebb.c
cc: note: diagnostic msg: /tmp/zstd_ldm-63d49e.c
cc: note: diagnostic msg: /tmp/zstd_opt-6463b7.c
cc: note: diagnostic msg: /tmp/zstdmt_compress-4717c0.c
cc: note: diagnostic msg: /tmp/huf_decompress-b22416.c
cc: note: diagnostic msg: /tmp/zstd_decompress-28083a.c
cc: note: diagnostic msg: /tmp/cover-e68d0c.c
cc: note: diagnostic msg: /tmp/divsufsort-7cafd1.c
cc: note: diagnostic msg: /tmp/zdict-37b40e.c
cc: note: diagnostic msg: /tmp/zstd_v04-1612a6.c
cc: note: diagnostic msg: /tmp/zstd_v05-12d71e.c
cc: note: diagnostic msg: /tmp/zstd_v06-04ba5e.c
cc: note: diagnostic msg: /tmp/zstd_v07-170312.c
cc: note: diagnostic msg: /tmp/entropy_common-038a7d.sh
cc: note: diagnostic msg:
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2017-10-19 20:52:01 UTC
Can somebody please attach the /tmp/*.{c,sh} files that were dropped by the assertion failure?
Comment 4 punasipuli 2017-10-20 19:08:27 UTC
I'm not sure, if that is really a clang bug.

I could build the package on RPi Zero (FreeBSD 11.0-STABLE - armv6kz--freebsd11.0-gnueabihf) without any problems.

Also I could build on amd64 VM.

==> building with threading support
==> building zstd with .gz compression support
==> building zstd with .xz/.lzma compression support
==> no liblz4, building zstd without .lz4 support
cc  -I../lib -I../lib/common -I../lib/compress -I../lib/dictBuilder -DZSTD_NEWAPI -DXXH_NAMESPACE=ZSTD_    -I../lib/legacy -DZSTD_MULTITHREAD -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS -DZSTD_LZMACOMPRESS -DZSTD_LZMADECOMPRESS  -DZSTD_LEGACY_SUPPORT=4 -O -pipe  -fno-strict-aliasing   -pthread -lz -llzma  ../lib/common/entropy_common.c ../lib/common/error_private.c ../lib/common/fse_decompress.c ../lib/common/pool.c ../lib/common/threading.c ../lib/common/xxhash.c ../lib/common/zstd_common.c ../lib/compress/fse_compress.c ../lib/compress/huf_compress.c ../lib/compress/zstd_compress.c ../lib/compress/zstd_double_fast.c ../lib/compress/zstd_fast.c ../lib/compress/zstd_lazy.c ../lib/compress/zstd_ldm.c ../lib/compress/zstd_opt.c ../lib/compress/zstdmt_compress.c ../lib/decompress/huf_decompress.c ../lib/decompress/zstd_decompress.c ../lib/dictBuilder/cover.c ../lib/dictBuilder/divsufsort.c ../lib/dictBuilder/zdict.c ../lib/legacy/zstd_v04.c ../lib/legacy/zstd_v05.c ../lib/legacy/zstd_v06.c ../lib/legacy/zstd_v07.c zstdcli.o fileio.o bench.o datagen.o dibio.o  -o zstd -pthread -lz -llzma 
gmake[2]: Leaving directory '/usr/ports/archivers/zstd/work/zstd-1.3.2/programs'
cp programs/zstd .
gmake[1]: Leaving directory '/usr/ports/archivers/zstd/work/zstd-1.3.2'
===>  Staging for zstd-1.3.2
===>   Generating temporary packing list
gmake[1]: Entering directory '/usr/ports/archivers/zstd/work/zstd-1.3.2'
gmake[2]: Entering directory '/usr/ports/archivers/zstd/work/zstd-1.3.2/lib'
creating pkgconfig
Installing libraries
Installing includes
zstd static and shared library installed
gmake[2]: Leaving directory '/usr/ports/archivers/zstd/work/zstd-1.3.2/lib'
gmake[2]: Entering directory '/usr/ports/archivers/zstd/work/zstd-1.3.2/programs'
Installing binaries
Installing man pages
zstd installation completed
gmake[2]: Leaving directory '/usr/ports/archivers/zstd/work/zstd-1.3.2/programs'
gmake[1]: Leaving directory '/usr/ports/archivers/zstd/work/zstd-1.3.2'
====> Compressing man pages (compress-man)
Comment 5 punasipuli 2017-10-20 20:53:55 UTC
Created attachment 187335 [details]
fatal error: error in backend: Found 2 machine code errors.

cc: note: diagnostic msg:
Comment 6 punasipuli 2017-10-20 20:56:01 UTC
I've compiled with an interactive poudriere jail and collected the files.

 *** Bad machine code: Using an undefined physical register ***
- function:    ZSTD_compress_generic
- basic block: BB#13 if.end26 (0x803c46230)
- instruction: %R1<def> = SBCri
- operand 6:   %CPSR<imp-use,kill>

*** Bad machine code: Using an undefined physical register ***
- function:    ZSTD_compress_generic
- basic block: BB#17 if.else (0x803c46d70)
- instruction: %R0<def> = SBCri
- operand 6:   %CPSR<imp-use,kill>
fatal error: error in backend: Found 2 machine code errors.
cc: error: clang frontend command failed with exit code 70 (use -v to see invocation)
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: armv6--freebsd12.0-gnueabihf
Thread model: posix
InstalledDir: /nxb-bin/usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:

See attachment
Comment 7 Dimitry Andric freebsd_committer freebsd_triage 2017-10-21 11:06:37 UTC
Hm, it is strange that there is only one .sh script in the attachment, which compiles entropy_common-054cd0.c.  For me, this compiles fine, with clang 3.8.0, 3.9.0, 4.0.0 and 5.0.0.

I'm interested in how the port compiles the files; does it by any chance pass a whole bunch of .c files on one compiler command line?  Or does it attempt to use link time optimization (LTO)?
Comment 8 Dimitry Andric freebsd_committer freebsd_triage 2017-10-21 11:10:22 UTC
Oh actually when you compile zstd_compress-de7ce5.c with the same options as entropy_common-054cd0.c, you get 'Assertion failed: (LiveCPSR && "CPSR liveness tracking is wrong!"), function UpdateCPSRUse' with clang 5.0.0, and 'error in backend: Found 2 machine code errors' with clang 3.8.0.

I'll analyze this and try to reduce.
Comment 9 Dimitry Andric freebsd_committer freebsd_triage 2017-10-21 12:02:45 UTC
I have reduced zstd_compress-de7ce5.c to a small test case, and reported the bug upstream, here:

https://bugs.llvm.org/show_bug.cgi?id=35023
Comment 10 Michal Meloun freebsd_committer freebsd_triage 2017-11-16 04:52:26 UTC
*** Bug 223693 has been marked as a duplicate of this bug. ***
Comment 11 Jan Beich freebsd_committer freebsd_triage 2017-11-26 12:16:51 UTC
*** Bug 223809 has been marked as a duplicate of this bug. ***
Comment 12 Mikael Urankar freebsd_committer freebsd_triage 2017-11-27 09:52:49 UTC
Created attachment 188311 [details]
patch

Can we patch the ports the same way we patched the src tree? base r326232

fwiw the "dev" branch of zstd doesn't trigger the clang bug
Comment 13 Dimitry Andric freebsd_committer freebsd_triage 2018-12-22 13:29:56 UTC
The upstream bug has finally been fixed, but for some reason I can't reproduce the "Bad machine code" error anymore.  At least, neither with clang 6.0.1 from stable/{11,12}, nor with clang 7.0.1 from head.

Therefore I'm closing this as Overcome By Events, please feel free to reopen if you can still reproduce it.