Invalid template argument kind

(Eben ) #1

Hi,
I'm getting an odd error when compiling on 64-bit ARM, Debian Linux.
This is the latest code from github.

[1067/1080][ 98%][28131.728s] Performing build step for 'compiler-rt'
[26/658][ 3%][5.487s] Building CXX object lib/sanitizer_co...zerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.
FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o
/home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/./bin/clang++ -DHAVE_RPC_XDR_H=0 -DHAVE_TIRPC_RPC_XDR_H=0 -I/home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/.. -Wall -std=c++11 -Wno-unused-parameter -O3 -DNDEBUG -march=armv8-a -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fno-rtti -Wframe-larger-than=570 -Wglobal-constructors -MD -MT lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o -MF lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o.d -o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o -c /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
Invalid TemplateArgument Kind!
UNREACHABLE executed at /home/swift/swift-source/llvm/tools/clang/lib/AST/TemplateBase.cpp:283!
Stack dump:
0. Program arguments: /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/bin/clang-7 -cc1 -triple aarch64-unknown-linux-gnu -emit-obj -disable-free -main-file-name sanitizer_allocator.cc -mrelocation-model pic -pic-level 2 -mthread-model posix -mllvm -warn-stack-size=570 -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu generic -target-feature +neon -target-abi aapcs -fallow-half-arguments-and-returns -dwarf-column-info -debug-info-kind=line-tables-only -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/tools/clang/runtime/compiler-rt-bins/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.gcno -resource-dir /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/lib/clang/7.0.0 -dependency-file lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o.d -sys-header-deps -MT lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o -D HAVE_RPC_XDR_H=0 -D HAVE_TIRPC_RPC_XDR_H=0 -I /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/.. -D NDEBUG -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/6.3.0/../../../../include/aarch64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/6.3.0/../../../../include/aarch64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/local/include -internal-isystem /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wall -Wno-unused-parameter -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -Wglobal-constructors -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/tools/clang/runtime/compiler-rt-bins -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -fno-builtin -fno-rtti -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.aarch64.dir/sanitizer_allocator.cc.o -x c++ /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc -faddrsig

  1. /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc:88:77: current parser token ']'
  2. /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc:22:1: parsing namespace '__sanitizer'
  3. /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h:26:7: instantiating class definition '__sanitizer::CombinedAllocator<__sanitizer::SizeClassAllocator32<__sanitizer::AP32>, __sanitizer::SizeClassAllocatorLocalCache<__sanitizer::SizeClassAllocator32<__sanitizer::AP32> >, __sanitizer::LargeMmapAllocator<__sanitizer::NoOpMapUnmapCallback, __sanitizer::LargeMmapAllocatorPtrArrayStatic, __sanitizer::LocalAddressSpaceView>, __sanitizer::LocalAddressSpaceView>'
  4. /home/swift/swift-source/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h:49:7: instantiating class definition '__sanitizer::SizeClassAllocator32<__sanitizer::AP32>'
    #0 0x0000000001bbfc40 PrintStackTraceSignalHandler(void*) (/home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/bin/clang-7+0x1bbfc40)
    clang-7: error: unable to execute command: Aborted
    clang-7: error: clang frontend command failed due to signal (use -v to see invocation)
    clang version 7.0.0 (https://github.com/apple/swift-clang.git 2c0904089bbdbe1d00bcb58b3c4e5de778054e2c) (https://github.com/apple/swift-llvm.git 23d88de9b54e3dc0f3ee9d32d14e82423a227e28)
    Target: aarch64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/./bin
    clang-7: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
    clang-7: note: diagnostic msg:
    PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
    Preprocessed source(s) and associated run script(s) are located at:
    clang-7: note: diagnostic msg: /tmp/sanitizer_allocator-a49e65.cpp
    clang-7: note: diagnostic msg: /tmp/sanitizer_allocator-a49e65.sh
    clang-7: note: diagnostic msg:
    [31/658][ 4%][9.561s] Building CXX object lib/sanitizer_co...nitizerCommonNoTermination.aarch64.dir/sanitizer_linux.cc.
    ninja: build stopped: subcommand failed.
    [1070/1080][ 99%][28141.445s] Building CXX object utils/benchmark/src/CMakeFiles/benchmark.dir/statistics.cc.o
    FAILED: tools/clang/runtime/compiler-rt-stamps/compiler-rt-build
    cd /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/tools/clang/runtime/compiler-rt-bins && /usr/bin/cmake --build . && /usr/bin/cmake -E touch /home/swift/swift-source/build/Ninja-ReleaseAssert/llvm-linux-aarch64/tools/clang/runtime/compiler-rt-stamps//compiler-rt-build
    [1072/1080][ 99%][28148.184s] Building CXX object utils/benchmark/src/CMakeFiles/benchmark.dir/statistics.cc.o
    ninja: build stopped: subcommand failed.
    utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Can someone point me to a recent release of Swift that is most likely to compile successfully on GNU/Linux? Thanks.

(Neil Jones) #2

If you are trying to build swift-5.0-branch or higher on Debian 9 you will to do 2 things.

1: Install clang-6.0 and update alternatives. As clang-6.0 is not available in the standard debian repository you will need to add the stretch-backports repo first.

sudo apt-add-repository "deb http://deb.debian.org/debian stretch-backports main"
sudo apt update
sudo apt install clang-6.0
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 1000
sudo update-alternatives --install /usr/bin/clang++ clang /usr/bin/clang-3.8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 1000

2: Check the version of swig and/or swig3.0 installed. By default Debian 9 installs swig 3.0.10 which will cause the swift build to fail. Swig version must not be 3.0.9 or 3.0.10. Successful builds have been obtained using the latest release 3.0.12.
To install swig 3.0.12 you can either -
Build from source - https://sourceforge.net/projects/swig/files/swig/swig-3.0.12/

sudo apt remove swig swig3.0
sudo apt-get install libpcre3 libpcre3-dev
wget http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz
tar xzf swig-3.0.12.tar.gz
cd swig-3.0.12
./configure
make
sudo make install

or install from the swift-arm/build-tools repo

sudo apt remove swig swig3.0
curl -s https://packagecloud.io/install/repositories/swift-arm/build_tools/script.deb.sh | sudo bash
sudo apt-get install swig=3.0.12-1

These changes should enable you build swift-5.0-branch and the master.
Note:
Make sure you do a new clean build.
Not all the AArch64 tests are passing so you will need to choose the --preset=buildbot_linux,no_test option to complete the build.