llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.78k stars 11.9k forks source link

LLVM build failed for WebAssembly target #92279

Closed spino17 closed 5 months ago

spino17 commented 5 months ago

I used the following command to build the LLVM for WebAssembly target on my mac: cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../llvm -DLLVM_TARGETS_TO_BUILD="WebAssembly" The make command after running the above cmake failed by having the following error:

[ 76%] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/Sparc.cpp.o
/Users/bhavyabhatt/Desktop/bhavya/projects/wasm-llvm/llvm-project/clang/lib/CodeGen/Targets/Sparc.cpp:269:7: error: no matching function for call to 'max'
      std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), 1UL), 64));
      ^~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:40:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('llvm::details::FixedOrScalableQuantity<llvm::TypeSize, unsigned long long>::ScalarTy' (aka 'unsigned long long') vs. 'unsigned long')
max(const _Tp& __a, const _Tp& __b)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:51:1: note: candidate template ignored: could not match 'initializer_list<_Tp>' against 'llvm::details::FixedOrScalableQuantity<llvm::TypeSize, unsigned long long>::ScalarTy' (aka 'unsigned long long')
max(initializer_list<_Tp> __t, _Compare __comp)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:61:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided
max(initializer_list<_Tp> __t)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:31:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
1 error generated.
make[2]: *** [tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/Sparc.cpp.o] Error 1
make[1]: *** [tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/all] Error 2
make: *** [all] Error 2

The output of command clang --version is

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
llvmbot commented 5 months ago

@llvm/issue-subscribers-clang-codegen

Author: Bhavya Bhatt (spino17)

I used the following command to build the LLVM for `WebAssembly` target on my mac: `cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../llvm -DLLVM_TARGETS_TO_BUILD="WebAssembly"` The `make` command after running the above `cmake` failed by having the following error: ``` [ 76%] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/Sparc.cpp.o /Users/bhavyabhatt/Desktop/bhavya/projects/wasm-llvm/llvm-project/clang/lib/CodeGen/Targets/Sparc.cpp:269:7: error: no matching function for call to 'max' std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), 1UL), 64)); ^~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:40:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('llvm::details::FixedOrScalableQuantity<llvm::TypeSize, unsigned long long>::ScalarTy' (aka 'unsigned long long') vs. 'unsigned long') max(const _Tp& __a, const _Tp& __b) ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:51:1: note: candidate template ignored: could not match 'initializer_list<_Tp>' against 'llvm::details::FixedOrScalableQuantity<llvm::TypeSize, unsigned long long>::ScalarTy' (aka 'unsigned long long') max(initializer_list<_Tp> __t, _Compare __comp) ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:61:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided max(initializer_list<_Tp> __t) ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/max.h:31:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ 1 error generated. make[2]: *** [tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/Sparc.cpp.o] Error 1 make[1]: *** [tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/all] Error 2 make: *** [all] Error 2 ``` The output of command `clang --version` is ``` Apple clang version 14.0.3 (clang-1403.0.22.14.1) Target: arm64-apple-darwin23.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin ```
aheejin commented 5 months ago

This is not a WebAssembly problem; it seems to be caused by #90338. It looks fixes are being tried in https://github.com/llvm/llvm-project/commit/da116bd82c0a78d2022c34b56e45cf6e4f91eaed and https://github.com/llvm/llvm-project/commit/8a4cbeada930bf11fe740a2038bd5a3230712284. Given that they are fixing it now, I hope the build will clear soon, and I think we can close this.

spino17 commented 5 months ago

Thanks a lot @aheejin for mentioning those. Just to make sure that I would change the line mentioned in https://github.com/llvm/llvm-project/commit/8a4cbeada930bf11fe740a2038bd5a3230712284 and rebuild it right ?

aheejin commented 5 months ago

Yeah it looks that commit has fixed the issue.

spino17 commented 5 months ago

Yeah, checked out just now! Thanks a lot for the help @aheejin . I believe working with stable source is much more safer given I just want to build clang library for AST.