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

error: 'llvm::operator-' has different definitions in different modules #58573

Open
cjdb opened this issue Oct 24, 2022 · 4 comments
Open

error: 'llvm::operator-' has different definitions in different modules #58573

cjdb opened this issue Oct 24, 2022 · 4 comments
Labels
build-problem clang:modules C++20 modules and Clang Header Modules

Comments

@cjdb
Copy link
Contributor

cjdb commented Oct 24, 2022

Details

LLVM hash: 00c2eb2
OS: Ubuntu 20.04.5 (GitHub Actions job)
Build toolchain: LLVM nightly

Config step

$ export CC=/usr/bin/clang-16 CXX=/usr/bin/clang++-16
$ cmake
  -G Ninja
  -S llvm-project/llvm
  -B build
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_CROSSCOMPILING=Yes
  -DCMAKE_INSTALL_PREFIX=/tmp/llvm
  -DLLVM_DEFAULT_TARGET_TRIPLE=${{ matrix.target.triple }}
  -DLLVM_ENABLE_LLD=Yes
  -DLLVM_ENABLE_LIBCXX=Yes
  -DLLVM_ENABLE_MODULES=Yes
  -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld;polly'
  -DLLVM_ENABLE_RUNTIMES='compiler-rt;libcxx;libcxxabi;libunwind'
  -DLLVM_ENABLE_ZLIB=Yes
  -DLLVM_TARGETS_TO_BUILD=${{ matrix.target.name }}

where ${{ matrix.target.triple }} can be x86_64-unknown-linux-gnu or armv7a-unknown-linux-gnu, and ${{ matrix.target.name }} respectively is X86 or ARM.

Diagnostic

/usr/bin/clang++-16 -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/runner/work/lah-toolchain/lah-toolchain/build/lib/Support -I/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support -I/home/runner/work/lah-toolchain/lah-toolchain/build/include -I/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/home/runner/work/lah-toolchain/lah-toolchain/build/module.cache -Xclang -fmodules-local-submodule-visibility -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections  -O3 -DNDEBUG -std=c++17  -fno-exceptions -fno-rtti -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o -c /home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support/APInt.cpp
In module 'LLVM_Utils' imported from /home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support/APInt.cpp:14:
/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include/llvm/Support/TypeSize.h:214:10: error: 'llvm::operator-' has different definitions in different modules; definition in module 'LLVM_Utils.Support.TypeSize' first difference is return type is 'std::enable_if_t<std::is_signed<U>::value, LeafTy>' (aka 'typename enable_if<std::is_signed<U>::value, type-parameter-0-0>::type')
  friend std::enable_if_t<std::is_signed<U>::value, LeafTy>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include/llvm/Support/TypeSize.h:96:10: note: but in 'LLVM_Utils.Support.TypeSize' found different return type 'typename std::enable_if_t<std::is_signed<U>::value, LeafTy>' (aka 'typename enable_if<std::is_signed<U>::value, type-parameter-0-0>::type')
  friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[11/4440] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o 
/usr/bin/clang++-16 -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/runner/work/lah-toolchain/lah-toolchain/build/lib/Support -I/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support -I/home/runner/work/lah-toolchain/lah-toolchain/build/include -I/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/home/runner/work/lah-toolchain/lah-toolchain/build/module.cache -Xclang -fmodules-local-submodule-visibility -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections  -O3 -DNDEBUG -std=c++17  -fno-exceptions -fno-rtti -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o -c /home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support/APFloat.cpp
In module 'LLVM_Utils' imported from /home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/lib/Support/APFloat.cpp:14:
/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include/llvm/Support/TypeSize.h:214:10: error: 'llvm::operator-' has different definitions in different modules; definition in module 'LLVM_Utils.Support.TypeSize' first difference is return type is 'std::enable_if_t<std::is_signed<U>::value, LeafTy>' (aka 'typename enable_if<std::is_signed<U>::value, type-parameter-0-0>::type')
  friend std::enable_if_t<std::is_signed<U>::value, LeafTy>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/lah-toolchain/lah-toolchain/llvm-project/llvm/include/llvm/Support/TypeSize.h:96:10: note: but in 'LLVM_Utils.Support.TypeSize' found different return type 'typename std::enable_if_t<std::is_signed<U>::value, LeafTy>' (aka 'typename enable_if<std::is_signed<U>::value, type-parameter-0-0>::type')
  friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[12/44[40](https://github.com/cjdb/lah-toolchain/actions/runs/3306277377/jobs/5457045424#step:7:41)] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o
ninja: build stopped: subcommand failed.
@EugeneZelenko EugeneZelenko added clang:modules C++20 modules and Clang Header Modules build-problem and removed new issue labels Oct 24, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2022

@llvm/issue-subscribers-clang-modules

@masx200
Copy link

masx200 commented May 17, 2023

[ 37%]: compiling.module.test leetcode_treenode_cpp.freeTreeNode
"C:\\Program Files\\LLVM\\bin\\clang" -c -x c++-module -fmodule-output=build\.gens\leetcode-treenode-cpp\windows\x64\test\rules\modules\cache\ec4a91a6\leetcode_treenode_cpp.freeTreeNode.pcm -fmodule-file=leetcode_treenode_cpp.TreeNode=build\.gens\leetcode-treenode-cpp\windows\x64\test\rules\modules\cache\ec4a91a6\leetcode_treenode_cpp.TreeNode.pcm -Qunused-arguments -m64 -std=c++20 -D__TEST__ -fexceptions -fcxx-exceptions -isystem C:\Users\Administrator\Documents\vcpkg-master\installed\x64-windows-static\include -fmodules-cache-path=build\.gens\leetcode-treenode-cpp\windows\x64\test\rules\modules\cache -fmodule-file=leetcode_treenode_cpp.TreeNode=build\.gens\leetcode-treenode-cpp\windows\x64\test\rules\modules\cache\ec4a91a6\leetcode_treenode_cpp.TreeNode.pcm -o build\.objs\leetcode-treenode-cpp\windows\x64\test\freeTreeNode.ixx.obj freeTreeNode.ixx
error: @programdir\modules\private\async\runjobs.lua:256: @programdir\rules\c++\modules\modules_support\clang.lua:270: @programdir\modules\core\tools\gcc.lua:721: In file included from traversalTreeNode.ixx:2:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\vector:11:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xmemory:14:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\new:11:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\exception:12:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\type_traits:2186:19: error: 'std::hash' has different definitions in different modules; first difference is defined here found method '_Do_hash' with no body
    static size_t _Do_hash(const _Kty& _Keyval) noexcept {
    ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\type_traits:2186:19: note: but in 'leetcode_treenode_cpp.TreeNode.<global>' found method '_Do_hash' with body
    static size_t _Do_hash(const _Kty& _Keyval) noexcept {
    ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from traversalTreeNode.ixx:2:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\vector:11:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xmemory:14:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\new:11:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\exception:12:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\type_traits:2167:23: error: 'std::_Conditionally_enabled_hash' has different definitions in different modules; first difference is defined here found method 'operator()' with no body
    _NODISCARD size_t operator()(const _Kty& _Keyval) const
               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\type_traits:2167:23: note: but in 'leetcode_treenode_cpp.TreeNode.<global>' found method 'operator()' with body
    _NODISCARD size_t operator()(const _Kty& _Keyval) const
               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

@dwblaikie
Copy link
Collaborator

A reduced test case would eb nice - though they are a pain to produce for modular builds.

(is the expectation that this is a bug in LLVM's source, or in clang's modules implementation, or something else?)

@davidstone
Copy link
Contributor

@masx200: Your issue is #60027.

I wouldn't be surprised if the original issue is also that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-problem clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

6 participants