Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build LLVM with clang on master/stable 1.73 #116397

Closed
MasterAwesome opened this issue Oct 3, 2023 · 8 comments
Closed

Unable to build LLVM with clang on master/stable 1.73 #116397

MasterAwesome opened this issue Oct 3, 2023 · 8 comments
Assignees
Labels
C-bug Category: This is a bug. P-low Low priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@MasterAwesome
Copy link
Contributor

MasterAwesome commented Oct 3, 2023

Build steps

I tried this code:

./configure --enable-llvm-static-stdcpp --enable-optimize-llvm --enable-clang --set llvm.ninja=false --enable-lld
./x.py build src/llvm-project/ src/llvm-project/lld

LLVM configuration options

running: cd "/rust/build/x86_64-unknown-linux-gnu/llvm/build" && CMAKE_PREFIX_PATH="" DESTDIR="" "cmake" "/rust/src/llvm-project/llvm" "-DLLVM_ENABLE_ASSERTIONS=OFF" "-DLLVM_UNREACHABLE_OPTIMIZE=OFF" "-DLLVM_ENABLE_PLUGINS=OFF" "-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR;M68k;CSKY" "-DLLVM_INCLUDE_EXAMPLES=OFF" "-DLLVM_INCLUDE_DOCS=OFF" "-DLLVM_INCLUDE_BENCHMARKS=OFF" "-DLLVM_INCLUDE_TESTS=OFF" "-DLLVM_ENABLE_TERMINFO=OFF" "-DLLVM_ENABLE_LIBEDIT=OFF" "-DLLVM_ENABLE_BINDINGS=OFF" "-DLLVM_ENABLE_Z3_SOLVER=OFF" "-DLLVM_PARALLEL_COMPILE_JOBS=12" "-DLLVM_TARGET_ARCH=x86_64" "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu" "-DLLVM_ENABLE_WARNINGS=OFF" "-DLLVM_INSTALL_UTILS=ON" "-DLLVM_ENABLE_ZSTD=OFF" "-DLLVM_ENABLE_ZLIB=ON" "-DLLVM_ENABLE_LIBXML2=OFF" "-DLLVM_ENABLE_PROJECTS=clang" "-DLLVM_VERSION_SUFFIX=-rust-1.73.0-nightly" "-DCMAKE_INSTALL_MESSAGE=LAZY" "-DCMAKE_C_COMPILER=cc" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_ASM_COMPILER=cc" "-DCMAKE_C_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_SHARED_LINKER_FLAGS= -Wl,-Bsymbolic -static-libstdc++" "-DCMAKE_MODULE_LINKER_FLAGS= -Wl,-Bsymbolic -static-libstdc++" "-DCMAKE_EXE_LINKER_FLAGS= -Wl,-Bsymbolic -static-libstdc++" "-DCMAKE_INSTALL_PREFIX=/rust/build/x86_64-unknown-linux-gnu/llvm" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_BUILD_TYPE=Release"

I expected to see this happen: Build success

Instead, this happened:

[ 34%] Built target llvm-config
[ 34%] Building BPFGenRegisterInfo.inc...
[ 34%] Building LoongArchGenAsmMatcher.inc...
[ 34%] Building BPFGenSubtargetInfo.inc...
[ 34%] Building AArch64GenExegesis.inc...
[ 34%] Building ARMGenDAGISel.inc...
[ 34%] Building ARMGenDisassemblerTables.inc...
[ 34%] Building HexagonGenDAGISel.inc...
[ 34%] Building HexagonGenDFAPacketizer.inc...
[ 34%] Built target BPFCommonTableGen
[ 34%] Building MSP430GenAsmMatcher.inc...
[ 34%] Building LoongArchGenAsmWriter.inc...
In file included from /rust/src/llvm-project/clang/include/clang/Basic/Specifiers.h:20,
                 from /rust/src/llvm-project/clang/include/clang/Basic/Diagnostic.h:20,
                 from /rust/src/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h:18,
                 from /rust/src/llvm-project/clang/include/clang/AST/Type.h:21,
                 from /rust/src/llvm-project/clang/include/clang/AST/CanonicalType.h:17,
                 from /rust/src/llvm-project/clang/include/clang/AST/ASTContext.h:18,
                 from /rust/src/llvm-project/clang/lib/AST/AttrImpl.cpp:13:
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc: In static member functionstatic clang::AArch64SVEPcsAttr* clang::AArch64SVEPcsAttr::CreateImplicit(clang::ASTContext&, clang::SourceRange, Spelling)’:
/rust/src/llvm-project/llvm/include/llvm/Support/ErrorHandling.h:151:3: error: expected primary-expression beforedo151 |   do {                                                                         \
      |   ^~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:39:6: note: in expansion of macrollvm_unreachable39 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |      ^~~~~~~~~~~~~~~~
In file included from /rust/src/llvm-project/clang/lib/AST/AttrImpl.cpp:273:
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:39:6: error: expected ‘)’ beforedo39 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |     ~^
      |      )
/rust/src/llvm-project/llvm/include/llvm/Support/ErrorHandling.h:154:5: error: expected ‘)’ beforewhile154 |   } while (false)
      |     ^~~~~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:39:6: note: in expansion of macrollvm_unreachable39 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |      ^~~~~~~~~~~~~~~~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:35:56: note: to match this ‘(’
   35 |   AttributeCommonInfo I(Range, NoSemaHandlerAttribute, (
      |                                                        ^
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:39:172: error: expected ‘,’ or ‘;’ before ‘)’ token
   39 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |                                                                                                                                                                            ^
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc: In static member functionstatic clang::AArch64SVEPcsAttr* clang::AArch64SVEPcsAttr::Create(clang::ASTContext&, clang::SourceRange, Spelling)’:
/rust/src/llvm-project/llvm/include/llvm/Support/ErrorHandling.h:151:3: error: expected primary-expression beforedo151 |   do {                                                                         \
      |   ^~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:48:6: note: in expansion of macrollvm_unreachable48 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |      ^~~~~~~~~~~~~~~~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:48:6: error: expected ‘)’ beforedo48 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |     ~^
      |      )
/rust/src/llvm-project/llvm/include/llvm/Support/ErrorHandling.h:154:5: error: expected ‘)’ beforewhile154 |   } while (false)
      |     ^~~~~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:48:6: note: in expansion of macrollvm_unreachable48 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |      ^~~~~~~~~~~~~~~~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:44:56: note: to match this ‘(’
   44 |   AttributeCommonInfo I(Range, NoSemaHandlerAttribute, (
      |                                                        ^
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:48:172: error: expected ‘,’ or ‘;’ before ‘)’ token
   48 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |                                                                                                                                                                            ^
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc: In static member functionstatic clang::AArch64VectorPcsAttr* clang::AArch64VectorPcsAttr::CreateImplicit(clang::ASTContext&, clang::SourceRange, Spelling)’:
/rust/src/llvm-project/llvm/include/llvm/Support/ErrorHandling.h:151:3: error: expected primary-expression beforedo151 |   do {                                                                         \
      |   ^~
/rust/build/x86_64-unknown-linux-gnu/llvm/build/tools/clang/include/clang/AST/AttrImpl.inc:128:6: note: in expansion of macrollvm_unreachable128 |     (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
      |      ^~~~~~~~~~~~~~~~
gmake[2]: *** [tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/build.make:230: tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/AttrImpl.cpp.o] Error 1

Version it worked on

Rust stable 1.72.1 release with LLVM 16

Version with regression

Rust stable branch and master branch containing LLVM 17

Build environment details

name version
ubuntu 23.04
cmake 3.25.1
gcc 12.3.0
g++ 12.3.0
make 4.3

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged

@MasterAwesome MasterAwesome added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Oct 3, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-untriaged Untriaged performance or correctness regression. labels Oct 3, 2023
@MasterAwesome MasterAwesome changed the title Unable to build LLVM with clang Unable to build LLVM on master/stable 1.73 branch Oct 3, 2023
@MasterAwesome
Copy link
Contributor Author

This bug is not host compiler specific, fails when building on both clang 17 and gcc 12.3.0 host toolchains (x86_64 is my host). Build succeeds when --enable-clang is not set in ./configure.

@MasterAwesome MasterAwesome changed the title Unable to build LLVM on master/stable 1.73 branch Unable to build LLVM with clang on master/stable 1.73 Oct 3, 2023
@apiraino apiraino added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Oct 4, 2023
@Mark-Simulacrum Mark-Simulacrum added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 4, 2023
@Mark-Simulacrum
Copy link
Member

This looks like a low priority problem, likely upstream in LLVM to me. AFAIK, our CI does not test that we can build clang from the LLVM tree we check out.

@MasterAwesome
Copy link
Contributor Author

MasterAwesome commented Oct 4, 2023

This looks like a low priority problem, likely upstream in LLVM to me. AFAIK, our CI does not test that we can build clang from the LLVM tree we check out.

It does look like an upstream bug that occurs when LLVM_UNREACHABLE_OPTIMIZATIONS is set to OFF causing invalid codegen by clang-tblgen. When this is set to ON all works as expected. I will file a upstream issue and see what the solution is. I also found a related commit making ON the default due to incompatibilities with gcc. llvm/llvm-project@38d248a

I also think we should do this as a step in CI when we do upgrade LLVM submodule to ensure there are no regressions for these options offered by bootstrap.

@MasterAwesome
Copy link
Contributor Author

Filed an upstream bug: llvm/llvm-project#68237

@MasterAwesome
Copy link
Contributor Author

@rustbot claim

@Mark-Simulacrum
Copy link
Member

Given that we don't distribute clang, I'm not inclined to block our CI on it and spend time building it in one or more builders. Small patches are likely to be accepted to fix it but I don't want us to test every option that's possible.

@MasterAwesome
Copy link
Contributor Author

Given that we don't distribute clang, I'm not inclined to block our CI on it and spend time building it in one or more builders. Small patches are likely to be accepted to fix it but I don't want us to test every option that's possible.

Alright that makes sense, I'll fix this in upstream LLVM and submit a patch to our LLVM fork as per https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html#bugfix-updates

@MasterAwesome
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-low Low priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

5 participants