Skip to content

Cannot build obj.clangAST when LLVM_UNREACHABLE_OPTIMIZATIONS are turned off #68237

Closed
llvm/llvm-project-release-prs
#726
@MasterAwesome

Description

@MasterAwesome

I'm trying to build clang in Release mode with LLVM_UNREACHABLE_OPTIMIZATIONS turned off; however, the file AttrImpl.cpp fails to compile. This happens in release/17.x branch and main.

cmake llvm \
    -DLLVM_ENABLE_PROJECTS=clang \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_ASM_COMPILER=clang \
    -DLLVM_UNREACHABLE_OPTIMIZE=OFF \
    -B build
cd build/
make obj.clangAST

This seems due to the fact that on CMAKE_BUILD_TYPE=Release + LLVM_UNREACHABLE_OPTIMIZE=OFF leads to

do { \
LLVM_BUILTIN_TRAP; \
LLVM_BUILTIN_UNREACHABLE; \
} while (false)
branch which causes the tblgen'd output (AttrImpl.inc) to not compile. All other variants work [(Release + LLVM_UNREACHABLE_OPTIMIZE=ON), (Debug + LLVM_UNREACHABLE_OPTIMIZE=[ON|OFF])]

This is bisected to clang-tblgen change b6d4d51#diff-58111c7c545672c3a67b1b31a37d4103b35d9c584a46c74b0be14cc37741491bR2642-R2646

Tested with both host toolchains clang 17.0.2 and gcc 13.2.0

For Rust specific issue: Rust defaults to LLVM_UNREACHABLE_OPTIMIZE=OFF for all LLVM builds and this causes a regression when LLVM is compiled in release mode. See rust-lang/rust#109373

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions