llvm / llvm-project

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

The 18.1.2 binary windows release (the .tar.xz file) has a dependency on visual studio 2019 professional #86250

Open ThosRTanner opened 7 months ago

ThosRTanner commented 7 months ago

Trying to build a cmake project with visual studio 2022 community after unpacking "clang+llvm-18.1.2-x86_64-pc-windows-msvc.tar.xz" results in this output:

------ Build started: Project: CMakeLists, Configuration: Debug ------ C:\Users\Dad\Repositories\github\Include What You Use\include-what-you-use\out\build\x64-Clang-Debug\ninja : error : 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK/lib/amd64/diaguids.lib', needed by 'bin/include-what-you-use.exe', missing and no known rule to make it

Build failed.

zufuliu commented 7 months ago

https://discourse.llvm.org/t/llvm-17-0-0-rc2-tagged/72643/8

cc @zmodem

zmodem commented 7 months ago

I don't think building against the .lib files in that package is likely to work in general. If anyone wants to try to make it work, patches are welcome.

zufuliu commented 7 months ago

I don't think building against the .lib files in that package is likely to work in general. If anyone wants to try to make it work, patches are welcome.

I'm sorry, I think I misread OP's question: using the package to build "include-what-you-use", and CMake doesn't find diaguids.lib from Visual Studio 2022's DIA SDK but strangely refer to Visual Studio 2019's.

@ThosRTanner I think you need to run CMake under "x64 Native Tools Command Prompt for VS 2022" (or similar) to correct set build environments for Visual Studio's DIA SDK. So, maybe this is not a LLVM problem or some CMake files in the package hard-coded MSVC_DIA_SDK_DIR, need time to check.

zufuliu commented 7 months ago

I find following (line 475 to 478) from clang+llvm-18.1.2-x86_64-pc-windows-msvc\lib\cmake\llvm\LLVMExports.cmake:

# Create imported target LLVMDebugInfoPDB
add_library(LLVMDebugInfoPDB STATIC IMPORTED)

set_target_properties(LLVMDebugInfoPDB PROPERTIES
  INTERFACE_LINK_LIBRARIES "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"
)
ThosRTanner commented 7 months ago

That looks very like a hardcoded reference that I can't avoid however I build.

zufuliu commented 4 months ago

https://discourse.llvm.org/t/llvm-assumes-specific-visual-studio-installation-after-build/79857/3

ZLangJIT commented 4 months ago

ok this can be fixed via

      - name: install DIA SDK
        run: |
          set -x
          mkdir -p "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional" || true
          cp -rv "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK"
Ziqi-Yang commented 3 months ago

ok this can be fixed via

      - name: install DIA SDK
        run: |
          set -x
          mkdir -p "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional" || true
          cp -rv "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK"
      - name: install DIA SDK
        if: runner.os == 'Windows'
        shell: bash
        run: |
          set -x
          mkdir -p "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional" || true
          cp -rv "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK"
makslevental commented 3 months ago

So other than copying from where it is on the current machine to where LLVM expects it to be, what's the fix here?