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

Failure in Building LLVM-16 on Windows. #1046

Open
miladHakimi opened this issue Jan 7, 2024 · 2 comments
Open

Failure in Building LLVM-16 on Windows. #1046

miladHakimi opened this issue Jan 7, 2024 · 2 comments

Comments

@miladHakimi
Copy link

miladHakimi commented Jan 7, 2024

Hi,
First of all, thank you for all the great products and documentation!

I was trying to install Remill on Windows 10 and I had to manually build the dependencies because Windows' binaries are no longer shipped with the new releases. Since I couldn't use the build_dependencies.sh script, I cloned vcpkg in the cxx-common root directory and ran the commands in the build_dependencies.sh manually:

.\vcpkg\bootstrap-vcpkg.bat 
.\vcpkg\vcpkg.exe fetch nuget
.\vcpkg\vcpkg.exe install --triplet x64-windows-static-md-rel  "llvm-16" "@overlays.txt" "@dependencies.txt"

I chose x64-windows-static-md-rel because it is used in the windows' CI.
The used vcpkg repository in vcpkg_info.txt breaks a lot when installing the dependencies. I finally fixed the issue by manually setting the CMAKE_PREFIX_PATH in vcpkg.cmake. With that, all the dependencies in the dependencies.txt were successfully installed. However, I have been struggling with installing llvm-16. The first problem was with the patches. The installation failed with an error about the patch 0021-fix-find_dependency.patch being corrupted. I commented the patch to let the installation continue but it failed again while building the project during linking. The problem was that it could not find the zstd library correctly. The same issue with zstd happens with llvm-17. In the case of llvm17, I didn't comment the patch because it didn't give me an error.

I switched to the main vcpkg repo. I didn't get the initial errors regarding the CMAKE_PREFIX_PATH but I still can't build llvm-16 and 17. Here is the log I received with llvm-17:

CMake Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/cmake/Modules/CompilerRTUtils.cmake:281 (message):
  LLVM_CONFIG_PATH is deprecated, please use LLVM_CMAKE_DIR instead
Call Stack (most recent call first):
  CMakeLists.txt:29 (load_llvm_config)


CMake Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/cmake/Modules/CompilerRTUtils.cmake:326 (message):
  LLVMTestingSupport not found in LLVM_AVAILABLE_LIBS
Call Stack (most recent call first):
  CMakeLists.txt:29 (load_llvm_config)


CMake Deprecation Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/cmake/Modules/AddCompilerRT.cmake:8 (cmake_policy):
  The OLD behavior for policy CMP0114 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:40 (include)


CMake Deprecation Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/cmake/Modules/CMakePolicy.cmake:6 (cmake_policy):
  The OLD behavior for policy CMP0114 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:6 (include)


CMake Error at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/llvm/cmake/modules/Findzstd.cmake:39 (string):
  string sub-command REGEX, mode REPLACE: regex "$" matched an empty string.
Call Stack (most recent call first):
  D:/cxx-common/vcpkg/downloads/tools/cmake-3.27.1-windows/cmake-3.27.1-windows-i386/share/cmake-3.27/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  D:/cxx-common/vcpkg/buildtrees/llvm-17/x64-windows-static-md-rel-rel/lib/cmake/llvm/LLVMConfig.cmake:212 (find_dependency)
  CMakeLists.txt:48 (find_package)


CMake Deprecation Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/cmake/Modules/CMakePolicy.cmake:6 (cmake_policy):
  The OLD behavior for policy CMP0114 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/CMakeLists.txt:9 (include)


CMake Deprecation Warning at D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/cmake/Modules/AddCompilerRT.cmake:8 (cmake_policy):
  The OLD behavior for policy CMP0114 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  D:/cxx-common/vcpkg/buildtrees/llvm-17/src/org-17.0.1-05e9215f6d/compiler-rt/lib/CMakeLists.txt:4 (include)

Can you please help me with this?

@ekilmer
Copy link
Collaborator

ekilmer commented Jan 8, 2024

Unfortunately, we have been unable to adequately test the Windows build process due to CI constraints, so it is unofficially supported, and the CI files are there to help attempt support again.

I would not have expected to see too many errors building the dependencies, but it's possible now because it has been a long time (a few LLVM versions) since the Windows CI was active.

I can try to find some time this week to debug this issue on my local Windows machine. Hopefully, it's an easy-ish fix.

Regardless, most of our tools (remill, anvill, mcsema, etc.) are not regularly tested on Windows and might not build with MSVC compiler. You would probably have the most luck with clang-cl, but even that is not well-tested.


In the meantime, if you are having issues building the upstream vcpkg llvm-17 package, then I would also recommend opening an issue there, but please make sure you are not building/using anything from this repo, or else they might close it because this repo could break their definitions. Try the following from upstream vcpkg repo:

bootstrap-vcpkg.bat
vcpkg.exe install --triplet x64-windows-static-release llvm

Note that the triplet x64-windows-static-md-rel in this repo doesn't exist in upstream. First, try building with the above, and if that doesn't work, report an issue.

If that works, then you can try copying x64-windows-static-md-rel.cmake into upstream's triplets/community directory and execute the following:

vcpkg.exe install --triplet x64-windows-static-md-rel llvm

to test if it fails. If that also works, then there's something wrong with the cxx-common packaging.

@miladHakimi
Copy link
Author

Thank you for the prompt response. I will go through the steps and come back with the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants