Issue 150122
Summary llvm build fails with CMake error `Compiler doesn't support generation of unwind tables if exception support is disabled.`
Labels new issue
Assignees
Reporter maksim-petukhov
    I'm trying to build llvm 20.1.8 like so, nothing fancy:
```
mkdir build; \
cd build; \
cmake ../llvm \
    -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_INSTALL_PREFIX=/install \
 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;openmp" \
 -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
 -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;WebAssembly;X86" \
 -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
    -DLLVM_PARALLEL_COMPILE_JOBS=8 \
 -DLLVM_PARALLEL_LINK_JOBS=1 \
 -DCLANG_CONFIG_FILE_SYSTEM_DIR=/etc/clang; \
ninja; \
ninja install;
```
I'm using CMake 3.31.8, gcc 14.3.0, binutils 2.41.

<details>
  <summary>Partial build log with the error</summary>

```
...

1660.9 [4694/6237] Creating directories for 'runtimes'
1660.9 [4695/6237] No download step for 'runtimes'
1660.9 [4696/6237] No update step for 'runtimes'
1660.9 [4697/6237] No patch step for 'runtimes'
1660.9 [4697/6237] Performing configure step for 'runtimes'
1660.9 Not searching for unused variables given on the command line.
1660.9 loading initial cache file /llvm-project-20.1.8.src/build/projects/runtimes/tmp/runtimes-cache-Release.cmake
1660.9 -- Performing bootstrapping runtimes build.
1660.9 CMake Deprecation Warning at /llvm-project-20.1.8.src/cmake/Modules/CMakePolicy.cmake:6 (cmake_policy):
1660.9   The OLD behavior for policy CMP0116 will be removed from a future version
1660.9   of CMake.
1660.9
1660.9   The cmake-policies(7) manual explains that the OLD behaviors of all
1660.9 policies are deprecated and that a policy should be set to OLD only under
1660.9   specific short-term circumstances.  Projects should be ported to the NEW
1660.9   behavior and not rely on setting a policy to OLD.
1660.9 Call Stack (most recent call first):
1660.9   CMakeLists.txt:18 (include)
1660.9
1660.9
1660.9 -- The C compiler identification is Clang 20.1.8
1661.0 -- The CXX compiler identification is Clang 20.1.8
1661.0 -- The ASM compiler identification is Clang with GNU-like command-line
1661.0 -- Found assembler: /llvm-project-20.1.8.src/build/bin/clang
1661.0 -- Detecting C compiler ABI info
1661.1 -- Detecting C compiler ABI info - failed
1661.1 -- Detecting C compile features
1661.1 -- Detecting C compile features - done
1661.1 -- Detecting CXX compiler ABI info
1661.2 -- Detecting CXX compiler ABI info - failed
1661.2 -- Detecting CXX compile features
1661.2 -- Detecting CXX compile features - done
1661.2 -- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.7")
1661.2 -- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.7")
1661.2 -- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG
1661.3 -- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG - Failed
1661.3 -- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG
1661.3 -- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Failed
1661.3 -- Performing Test C_SUPPORTS_START_NO_UNUSED_COMMAND_LINE_ARGUMENTS
1661.4 -- Performing Test C_SUPPORTS_START_NO_UNUSED_COMMAND_LINE_ARGUMENTS - Failed
1661.4 -- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
1661.4 -- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Failed
1661.4 CMake Warning (dev) at /usr/share/cmake-3.31/Modules/GNUInstallDirs.cmake:253 (message):
1661.4 Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
1661.4 target architecture is known.  Please enable at least one language before
1661.4   including GNUInstallDirs.
1661.4 Call Stack (most recent call first):
1661.4 /llvm-project-20.1.8.src/llvm/cmake/modules/AddLLVM.cmake:1 (include)
1661.4 CMakeLists.txt:181 (include)
1661.4 This warning is for project developers.  Use -Wno-dev to suppress it.
1661.4
1661.5 -- Linker detection: GNU ld
1661.5 -- Performing Test C_SUPPORTS_FPIC
1661.5 -- Performing Test C_SUPPORTS_FPIC - Failed
1661.5 -- Performing Test CXX_SUPPORTS_FPIC
1661.6 -- Performing Test CXX_SUPPORTS_FPIC - Failed
1661.6 CMake Warning at /llvm-project-20.1.8.src/llvm/cmake/modules/HandleLLVMOptions.cmake:367 (message):
1661.6   -fPIC is not supported.
1661.6 Call Stack (most recent call first):
1661.6 /llvm-project-20.1.8.src/llvm/cmake/modules/HandleLLVMOptions.cmake:427 (add_flag_or_print_warning)
1661.6   CMakeLists.txt:182 (include)
1661.6
1661.6
1661.6 -- Performing Test C_SUPPORTS_FNO_SEMANTIC_INTERPOSITION
1661.6 -- Performing Test C_SUPPORTS_FNO_SEMANTIC_INTERPOSITION - Failed
1661.6 -- Performing Test CXX_SUPPORTS_FNO_SEMANTIC_INTERPOSITION
1661.7 -- Performing Test CXX_SUPPORTS_FNO_SEMANTIC_INTERPOSITION - Failed
1661.7 -- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
1661.8 -- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Failed
1661.8 -- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG
1661.8 -- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG - Failed
1661.8 -- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
1661.9 -- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
1661.9 -- Performing Test C_SUPPORTS_MISLEADING_INDENTATION_FLAG
1661.9 -- Performing Test C_SUPPORTS_MISLEADING_INDENTATION_FLAG - Failed
1661.9 -- Performing Test CXX_SUPPORTS_MISLEADING_INDENTATION_FLAG
1662.0 -- Performing Test CXX_SUPPORTS_MISLEADING_INDENTATION_FLAG - Failed
1662.0 -- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
1662.0 -- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
1662.0 -- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
1662.1 -- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
1662.1 -- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
1662.1 -- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
1662.1 -- Looking for os_signpost_interval_begin
1662.2 -- Looking for os_signpost_interval_begin - not found
1662.3 -- Found Python3: /usr/local/bin/python3.9 (found version "3.9.16") found components: Interpreter
1662.3 -- LLVM host triple: x86_64-unknown-linux-gnu
1662.3 -- LLVM default target triple: x86_64-unknown-linux-gnu
1662.3 -- Using libunwind testing configuration: /llvm-project-20.1.8.src/libunwind/test/configs/llvm-libunwind-shared.cfg.in
1662.3 -- Looking for __mips_hard_float
1662.4 -- Looking for __mips_hard_float - not found
1662.4 -- Looking for _ABIO32
1662.4 -- Looking for _ABIO32 - not found
1662.4 -- Looking for fopen in c
1662.5 -- Looking for fopen in c - not found
1662.5 -- Looking for __gcc_personality_v0 in gcc_s
1662.5 -- Looking for __gcc_personality_v0 in gcc_s - not found
1662.5 -- Looking for __absvdi2 in gcc
1662.6 -- Looking for __absvdi2 in gcc - not found
1662.6 -- Performing Test C_SUPPORTS_NODEFAULTLIBS_FLAG
1662.6 -- Performing Test C_SUPPORTS_NODEFAULTLIBS_FLAG - Failed
1662.6 -- Performing Test C_SUPPORTS_COMMENT_LIB_PRAGMA
1662.7 -- Performing Test C_SUPPORTS_COMMENT_LIB_PRAGMA - Failed
1662.7 -- Looking for __arm__
1662.7 -- Looking for __arm__ - not found
1662.7 -- Looking for __USING_SJLJ_EXCEPTIONS__
1662.7 -- Looking for __USING_SJLJ_EXCEPTIONS__ - not found
1662.7 -- Looking for __ARM_DWARF_EH__
1662.8 -- Looking for __ARM_DWARF_EH__ - not found
1662.8 -- Looking for dladdr in dl
1662.8 -- Looking for dladdr in dl - not found
1662.8 -- Looking for pthread_once in pthread
1662.9 -- Looking for pthread_once in pthread - not found
1662.9 -- Performing Test CXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG
1662.9 -- Performing Test CXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG - Failed
1662.9 -- Performing Test CXX_SUPPORTS_FSTRICT_ALIASING_FLAG
1663.0 -- Performing Test CXX_SUPPORTS_FSTRICT_ALIASING_FLAG - Failed
1663.0 -- Performing Test CXX_SUPPORTS_EHSC_FLAG
1663.0 -- Performing Test CXX_SUPPORTS_EHSC_FLAG - Failed
1663.0 -- Performing Test CXX_SUPPORTS_FUNWIND_TABLES_FLAG
1663.1 -- Performing Test CXX_SUPPORTS_FUNWIND_TABLES_FLAG - Success
1663.1 -- Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG
1663.1 -- Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG - Failed
1663.1 -- Performing Test CXX_SUPPORTS_FNO_RTTI_FLAG
1663.2 -- Performing Test CXX_SUPPORTS_FNO_RTTI_FLAG - Failed
1663.2 CMake Error at /llvm-project-20.1.8.src/libunwind/src/CMakeLists.txt:107 (message):
1663.2 Compiler doesn't support generation of unwind tables if exception support
1663.2   is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
1663.2   library is not supported.
1663.2
1663.2
1663.2 -- Configuring incomplete, errors occurred!
```
  
</details>

The error is
```
CMake Error at /llvm-project-20.1.8.src/libunwind/src/CMakeLists.txt:107 (message):
1663.2 Compiler doesn't support generation of unwind tables if exception support
1663.2   is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
1663.2   library is not supported.
```

Here is the source of the error message:
https://github.com/llvm/llvm-project/blob/87f0227cb60147a26a1eeb4fb06e3b505e9c7261/libunwind/src/CMakeLists.txt#L104-L111

In my case I have

```
1663.0 -- Performing Test CXX_SUPPORTS_FUNWIND_TABLES_FLAG
1663.1 -- Performing Test CXX_SUPPORTS_FUNWIND_TABLES_FLAG - Success
1663.1 -- Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG
1663.1 -- Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG - Failed
```

So I have this error message because CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG test fails. Here is full CMakeConfigureLog.yaml file that can help understand why this happens:

[CMakeConfigureLog.yaml.txt](https://github.com/user-attachments/files/21376044/CMakeConfigureLog.yaml.txt)

For CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG we have this record:

```yaml
  -
 kind: "try_compile-v1"
    backtrace:
      - "/usr/share/cmake-3.31/Modules/Internal/CheckSourceCompiles.cmake:108 (try_compile)"
      - "/usr/share/cmake-3.31/Modules/Internal/CheckCompilerFlag.cmake:18 (cmake_check_source_compiles)"
      - "/usr/share/cmake-3.31/Modules/CheckCXXCompilerFlag.cmake:55 (cmake_check_compiler_flag)"
      - "/llvm-project-20.1.8.src/libunwind/cmake/Modules/HandleLibunwindFlags.cmake:73 (check_cxx_compiler_flag)"
      - "/llvm-project-20.1.8.src/libunwind/CMakeLists.txt:250 (add_cxx_compile_flags_if_supported)"
    checks:
      - "Performing Test CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG"
    directories:
      source: "/llvm-project-20.1.8.src/build/runtimes/runtimes-bins/CMakeFiles/CMakeScratch/TryCompile-IW0J16"
 binary: "/llvm-project-20.1.8.src/build/runtimes/runtimes-bins/CMakeFiles/CMakeScratch/TryCompile-IW0J16"
 cmakeVariables:
      CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND"
 CMAKE_CXX_COMPILER_TARGET: "x86_64-unknown-linux-gnu"
 CMAKE_CXX_FLAGS: " -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections"
      CMAKE_CXX_FLAGS_DEBUG: "-g"
 CMAKE_C_COMPILER_TARGET: "x86_64-unknown-linux-gnu"
 CMAKE_EXE_LINKER_FLAGS: ""
      CMAKE_MODULE_PATH: "/llvm-project-20.1.8.src/libunwind/cmake;/llvm-project-20.1.8.src/libunwind/cmake;/llvm-project-20.1.8.src/libunwind/cmake/Modules;/llvm-project-20.1.8.src/libunwind/../runtimes/cmake/Modules;/llvm-project-20.1.8.src/libunwind/../cmake;/llvm-project-20.1.8.src/libunwind/../cmake/Modules;/llvm-project-20.1.8.src/runtimes/cmake;/llvm-project-20.1.8.src/runtimes/cmake/modules;/llvm-project-20.1.8.src/runtimes/../cmake;/llvm-project-20.1.8.src/runtimes/../cmake/Modules;/llvm-project-20.1.8.src/runtimes/../llvm/cmake;/llvm-project-20.1.8.src/runtimes/../llvm/cmake/modules;/llvm-project-20.1.8.src/build/lib/cmake/llvm;/llvm-project-20.1.8.src/build/lib/cmake/llvm"
 buildResult:
      variable: "CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG"
 cached: true
      stdout: |
        Change Dir: '/llvm-project-20.1.8.src/build/runtimes/runtimes-bins/CMakeFiles/CMakeScratch/TryCompile-IW0J16'
 
        Run Build Command(s): /usr/local/bin/ninja -v cmTC_83ad1
 [1/2] /llvm-project-20.1.8.src/build/bin/clang++ --target=x86_64-unknown-linux-gnu -DCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-exceptions -MD -MT CMakeFiles/cmTC_83ad1.dir/src.cxx.o -MF CMakeFiles/cmTC_83ad1.dir/src.cxx.o.d -o CMakeFiles/cmTC_83ad1.dir/src.cxx.o -c /llvm-project-20.1.8.src/build/runtimes/runtimes-bins/CMakeFiles/CMakeScratch/TryCompile-IW0J16/src.cxx
 [2/2] : && /llvm-project-20.1.8.src/build/bin/clang++ --target=x86_64-unknown-linux-gnu -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections CMakeFiles/cmTC_83ad1.dir/src.cxx.o -o cmTC_83ad1   && :
        FAILED: cmTC_83ad1 
        : && /llvm-project-20.1.8.src/build/bin/clang++ --target=x86_64-unknown-linux-gnu -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections CMakeFiles/cmTC_83ad1.dir/src.cxx.o -o cmTC_83ad1   && :
 /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
 /usr/bin/ld: cannot find -lgcc: No such file or directory
        clang++: error: linker command failed with exit code 1 (use -v to see invocation)
 ninja: build stopped: subcommand failed.
        
      exitCode: 1
```

What am I missing? How to fix this? Didn't have this problem with LLVM 15.0.7 and CMake 3.27.7.

I did some digging. 
1. I found this issue https://github.com/llvm/llvm-project/issues/61488. There is an abandoned patch from @mordante there https://reviews.llvm.org/D145596 which I tried to apply and it didn't help.
2. I found out that patch was abandoned because @petrhosek had another patch in progress https://reviews.llvm.org/D142957
3. I also found this issue on CMake page https://gitlab.kitware.com/cmake/cmake/-/issues/24561, but it doesn't provide any solutions to the problem. 

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to