Clang is segfaulting on CURRENT when building devel/aws-checksums. It stops at this assertion: Assertion failed: (i == DstIdx || !MI->getOperand(i).isReg() || MI->getOperand(i).getReg() != RegA), function processTiedPairs, file /usr/src/contrib/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp, line 1544. TwoAddressInstructionPass.cpp:1544. #ifndef NDEBUG // First, verify that we don't have a use of "a" in the instruction // (a = b + a for example) because our transformation will not // work. This should never occur because we are in SSA form. for (unsigned i = 0; i != MI->getNumOperands(); ++i) assert(i == DstIdx || !MI->getOperand(i).isReg() || MI->getOperand(i).getReg() != RegA); #endif The target file (source/intel/crc32c_sse42_asm.c) has a lot of assembly inline code.
Created attachment 200322 [details] crc32c_sse42_asm-43f9ae.c
Created attachment 200323 [details] crc32c_sse42_asm-43f9ae.sh
Also affects Clang 8 (soon to be in -CURRENT). $ poudriere jail -cj clang8 -v projects/clang800-import -m svn+https $ poudriere testport -j clang8 devel/aws-checksums [...] Assertion failed: (i == DstIdx || !MI->getOperand(i).isReg() || MI->getOperand(i).getReg() != RegA), function processTiedPairs, file /poudriere/jails/headamd64PR236062/usr/src/contrib/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp, line 1547. 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 8.0.0 (branches/release_80 354799) (based on LLVM 8.0.0) Target: x86_64-unknown-freebsd13.0 Thread model: posix InstalledDir: /usr/bin http://package18.nyi.freebsd.org/data/headamd64PR236062-default/2019-03-01_06h42m53s/logs/errors/aws-checksums-0.1.2,1.log
This reproduces even with very old versions of clang, e.g. it has been in there for a long time; though assertions need to be enabled. Minimized and submitted upstream here: https://bugs.llvm.org/show_bug.cgi?id=40985
Remove the blocking against 230355 as llvm/clang 7 has landed already
fwiw, this package builds fine on PowerPC64 using base clang 9.0.1.
(In reply to Alfredo Dal'Ava Junior from comment #6) It's to be expected, since the failing test case is x86_64 specific. :) I just re-tested with a very recent llvmorg-12-init-10988-g43df29e2062, and it still asserts. No movement at all from upstream.
It builds fine in 13.0.0 and 10.0.1, fails in 14.0.5 Is there a relation between OS version/clang version or something to understand why it works on some clang versions?
(In reply to Nuno Teixeira from comment #8) Yes, -CURRENT has llvm/clang assertions enabled, but -STABLE branches do not. So while the latter can appear to work, note that if assertions are known to be violated, care should be taken with the results...
(In reply to Dimitry Andric from comment #9) It builds fine on CURRENT >=1400091 Clang 16 --- .if (${OSVERSION} >= 1400000 && ${OSVERSION} < 1400091) USE_GCC= yes .endif --- Should I commit it or wait for an explanation of why build success on clang16?
(In reply to Nuno Teixeira from comment #10) This was fixed and/or worked around by aws-checksums upstream in <https://github.com/awslabs/aws-checksums/commit/ad53be196a25bbefa3700a01187fdce573a7d2d0>, where they changed the inline asm constraints. See also <https://github.com/awslabs/aws-checksums/issues/49> and <https://github.com/awslabs/aws-checksums/pull/57>. Note that the clang bug is still open, and there are even 4 different bug reports for it: <https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+processTiedPairs> :) However, the clang assertion is not triggered anymore due to the changes in aws-checksums. So, the whole USE_GCC thing can be deleted now.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=b8f8609d334536eb49a450cbbb1ce547887c19a0 commit b8f8609d334536eb49a450cbbb1ce547887c19a0 Author: Nuno Teixeira <eduardo@FreeBSD.org> AuthorDate: 2023-07-11 13:37:06 +0000 Commit: Nuno Teixeira <eduardo@FreeBSD.org> CommitDate: 2023-07-11 13:44:48 +0000 devel/aws-checksums: Remove USE_GCC Clang assertion is not triggered anymore due to the changes in aws-checksums 0.1.14, so removing USE_GCC on affected OSVERSION. See also: https://github.com/awslabs/aws-checksums/releases/tag/v0.1.14 PR: 234232 devel/aws-checksums/Makefile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
(In reply to Dimitry Andric from comment #11) Thanks very much Dimitry. I missed that upstream fix. Cheers
This can be closed now?
The port is now building but because the port itself changed. Our current version of clang still crashes with the reproducer attached $ clang -v FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67) Target: x86_64-unknown-freebsd15.0 Thread model: posix InstalledDir: /usr/bin
^Triage: clear stale flags.