Bug 245550

Summary: security/botan2: Fails to build: Assertion failed: (!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!") on FreeBSD CURRENT (13)
Product: Ports & Packages Reporter: Keren Sky <keren_sky>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: dim, tremere
Priority: --- Keywords: needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (tremere)
koobs: maintainer-feedback? (dim)
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
this file was listed in the error msg
none
this cpp file was listed in the error msg for attaching to the bug report none

Description Keren Sky 2020-04-11 23:24:43 UTC
Created attachment 213310 [details]
this file was listed in the error msg

Hi,
I'm trying to install botan2 from ports. The build stops w/ the error:

Bash:

c++ -fPIC -fvisibility=hidden -fstack-protector -pthread -std=c++11 -D_REENTRANT  -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -DBOTAN_IS_BEING_BUILT -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual  -Ibuild/include -Ibuild/include/external -I/usr/local/include -c src/lib/block/threefish_512/threefish_512.cpp -o build/obj/lib/block_threefish_512.o
Assertion failed: (!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"), function Init, file /usr/src/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h, line 45.
Stack dump:
0.      Program arguments: c++ -fPIC -fvisibility=hidden -fstack-protector -pthread -std=c++11 -D_REENTRANT -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -DBOTAN_IS_BEING_BUILT -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -mavx2 -Ibuild/include -Ibuild/include/external -I/usr/local/include -c src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp -o build/obj/lib/block_shacal2_avx2.o
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      build/include/botan/internal/simd_avx2.h:113:40: Generating code for declaration 'Botan::SIMD_8x32::rho'
#0 0x0000000002fb127e PrintStackTrace /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
#1 0x0000000002faf457 RunSignalHandlers /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:69:18
#2 0x0000000002fb339e HandleCrash /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:77:5
#3 0x0000000002fb3521 CrashRecoverySignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:51
#4 0x000000080416b800 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
c++: 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.
c++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/shacal2_avx2-285064.cpp
c++: note: diagnostic msg: /tmp/shacal2_avx2-285064.sh
c++: note: diagnostic msg:

********************
gmake[2]: *** [Makefile:219: build/obj/lib/block_shacal2_avx2.o] Error 254
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/usr/ports/security/botan2/work/Botan-2.14.0'
===> 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/security/botan2
*** Error code 1
Comment 1 Keren Sky 2020-04-11 23:33:11 UTC
Created attachment 213311 [details]
this cpp file was listed in the error msg for attaching to the bug report
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2020-04-12 07:09:19 UTC
@Dim Are the produced artifacts indicative of and sufficient for a toolchain / Clang failure?
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2020-04-12 08:38:08 UTC
(In reply to Kubilay Kocak from comment #2)
Yep, I can reproduce. I'm going to reduce the test case.
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2020-04-12 10:54:23 UTC
The bug was already reported upstream here:

https://bugs.llvm.org/show_bug.cgi?id=44919

which was a duplicate of:

https://bugs.llvm.org/show_bug.cgi?id=45468

and fixed in:

https://github.com/llvm/llvm-project/commit/30588a739584bb8ac41715d68656d22bd85198e7

I'll import the upstream fix.
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-04-12 16:07:26 UTC
A commit references this bug:

Author: dim
Date: Sun Apr 12 16:07:00 UTC 2020
New revision: 359826
URL: https://svnweb.freebsd.org/changeset/base/359826

Log:
  Merge commit 30588a739 from llvm git (by Erich Keane):

    Make target features check work with ctor and dtor-

    The problem was reported in PR45468, applying target features to an
    always_inline constructor/destructor runs afoul of GlobalDecl
    construction assert when checking for target-feature compatibility.

    The core problem is fixed by using the version of the check that
    takes a FunctionDecl rather than the GlobalDecl. However, while
    writing the test, I discovered that source locations weren't properly
    set for this check on ctors/dtors. This patch also fixes constructors
    and CALLED destructors.

    Unfortunately, it doesn't seem too possible to get a meaningful
    source location for a 'cleanup' destructor, so those are still
    'frontend' level errors unfortunately. A fixme was added to the test
    to cover that situation.

  This should fix 'Assertion failed: (!isa<CXXConstructorDecl>(D) && "Use
  other ctor with ctor decls!"), function Init, file
  /usr/src/contrib/llvm-project/clang/include/clang/AST/GlobalDecl.h, line
  45' when compiling the security/botan2 port.

  PR:		245550
  MFC after:	6 weeks
  X-MFC-With:	358851

Changes:
  head/contrib/llvm-project/clang/lib/CodeGen/CGClass.cpp
  head/contrib/llvm-project/clang/lib/CodeGen/CGExprCXX.cpp
  head/contrib/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp