[PATCH] D150688: [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 01:47:13 PDT 2023


hans added a comment.

In D150688#4347610 <https://reviews.llvm.org/D150688#4347610>, @mstorsjo wrote:

> Out of curiosity - what are the symptoms that this change fixes, and which build configurations does it affect? (I would expect that regular builds with just llvm+clang would pass at least?) But I do agree that the new behaviour of `CMP0091` probably does conflict with `ChooseMSVCCRT.cmake`.

I've seen two issues so far, but there could also be others.

1. Some compiler-rt tests failed to link: (from https://github.com/llvm/llvm-project/issues/62719)

  > cmake -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=X86 ..\llvm && ninja check-fuzzer
  [...]
  [2985/2987] Generating Fuzzer-x86_64-Test.exe
  FAILED: projects/compiler-rt/lib/fuzzer/tests/Fuzzer-x86_64-Test.exe
  cmd.exe /C "cd /D C:\src\llvm-project\build.nana\projects\compiler-rt\lib\fuzzer\tests && C:\src\llvm-project\build.nana\.\bin\clang++.exe FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o FuzzerTestObjects.gtest-all.cc.x86_64.o C:/src/llvm-project/build.nana/projects/compiler-rt/lib/fuzzer/tests/RTFuzzerTest.x86_64.lib -o C:/src/llvm-project/build.nana/projects/compiler-rt/lib/fuzzer/tests/./Fuzzer-x86_64-Test.exe --driver-mode=g++ -Wl,-defaultlib:libcmt,-defaultlib:oldnames"
  RTFuzzerTest.x86_64.lib(FuzzerIOWindows.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o

It seems the test object ended up with `/MT` but the library got `/MD` for some reason.

2. Builting with a custom allocator, `-DLLVM_INTEGRATED_CRT_ALLOC` (from https://bugs.chromium.org/p/chromium/issues/detail?id=1445671):

  lld-link: error: duplicate symbol: calloc
  >>> defined at LLVMSupport.lib(rpmalloc.c.obj)
  >>> defined at api-ms-win-crt-heap-l1-1-0.dll

It seems we're still seeing some crt related link errors (https://bugs.chromium.org/p/chromium/issues/detail?id=1445671#c7) so maybe this wasn't enough.

> Tangentially; for libc++ builds, `ChooseMSVCCRT.cmake` isn't ever included and used so far. So for the sake of libc++ at the moment, I'd go with keeping `CMP0091` set to the new behaviour - which probably is the more convenient way of interacting with the choice of CRT going forward.
>
> I do see that `CMakePolicy.cmake` doesn't get included in libc++ builds either, so I think that should all be fine.

Does libc++ do anything else to choose crt? compiler-rt has seems to have its own thing in https://github.com/llvm/llvm-project/blob/llvmorg-16.0.3/compiler-rt/CMakeLists.txt#L398


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150688/new/

https://reviews.llvm.org/D150688



More information about the llvm-commits mailing list