templight
templight copied to clipboard
templight++ aborts with an error
On the latest main
of llvm, the generated C++ compiler (templight++
) aborts with an error:
-- Check for working CXX compiler: /Users/calum/projects/llvm-project/build/bin/templight++ - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.20.1/share/cmake/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler
"/Users/calum/projects/llvm-project/build/bin/templight++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/calum/projects/fei-parser/build-templight/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_cf156/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_cf156.dir/build.make CMakeFiles/cmTC_cf156.dir/build
Building CXX object CMakeFiles/cmTC_cf156.dir/testCXXCompiler.cxx.o
/Users/calum/projects/llvm-project/build/bin/templight++ -arch arm64 -o CMakeFiles/cmTC_cf156.dir/testCXXCompiler.cxx.o -c /Users/calum/projects/fei-parser/build-templight/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Assertion failed: (isSafeToReferenceAfterResize(Elt, NewSize) && "Attempting to reference an element of the vector in an operation " "that invalidates it"), function assertSafeToReferenceAfterResize, file /Users/calum/projects/llvm-project/llvm/include/llvm/ADT/SmallVector.h, line 177.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 templight++ 0x0000000103ff741c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 templight++ 0x0000000103ff640c llvm::sys::RunSignalHandlers() + 72
2 templight++ 0x0000000103ff7a88 SignalHandler(int) + 304
3 libsystem_platform.dylib 0x000000019ded2c44 _sigtramp + 56
4 libsystem_pthread.dylib 0x000000019de8743c pthread_kill + 292
5 libsystem_c.dylib 0x000000019ddcf454 abort + 124
6 libsystem_c.dylib 0x000000019ddce8d4 err + 0
7 templight++ 0x000000010617e72c main.cold.32 + 0
8 templight++ 0x0000000102276324 main + 9540
9 libdyld.dylib 0x000000019dea5430 start + 4
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /Users/calum/projects/llvm-project/build/bin/templight++ -arch arm64 -o CMakeFiles/cmTC_cf156.dir/testCXXCompiler.cxx.o -c /Users/calum/projects/fei-parser/build-templight/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
make[2]: *** [CMakeFiles/cmTC_cf156.dir/testCXXCompiler.cxx.o] Abort trap: 6
make[1]: *** [cmTC_cf156/fast] Error 2
A few minor and probably insignificant details, are that (a) I needed to patch the source code a bit to make it compile, (b) I'm running on Apple Silicon (arm64_osx) and (c) I'm using a release build of clang (-DCMAKE_BUILD_TYPE=Release
) because I needed the performance.
Steps to reproduce
- Follow the installation instructions,
- Clone clang
- Clone template++ into the
tools
folder - Update the
CMakeLists.txt
- Additional step: Patch up the templight source code so that it builds again
- Additional step (which may not be relevant): Configure cmake with
-DCMAKE_BUILD_TYPE=Release
- Build clang with templight++
- Configure the target project, in CMake, with
CMAKE_CXX_COMPILER:STRING=/Users/calum/projects/llvm-project/build/bin/templight++
- Build the target project, using make.
Causes
I'm not very familiar with llvm and templight yet, so here are some guesses
- My patching of the source code was incorrect
- Templight doesn't work on the latest llvm
- Something has gone wrong on Apple Silicon (arm64)
Any pointers would be appreciated!
I also experienced this issue, but this only appears to happen with the debug build (which is what CMake will build by default). Trying adding -D CMAKE_BUILD_TYPE=Release
when invoking CMake to ensure you build the release configuration. With the assets removed in the release build then the program will run.