mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.6k stars 1.63k forks source link

Wrong include path for OpenCL dependency #6846

Open borg323 opened 4 years ago

borg323 commented 4 years ago

Describe the bug The correct path would be C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include but instead only C:/Program Files/NVIDIA is used.

To Reproduce This is a build of lc0 (https://github.com/LeelaChessZero/lc0) with -Dopencl=true. The offending line is opencl_framework=dependency('OpenCL', required: false).

Expected behavior As above

system parameters

The meson-log.txt contains the following:

Determining dependency 'OpenCL' with CMake executable 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.EXE'
Try CMake generator: auto
None of 'CC' are defined in the environment, not changing global flags.
None of 'CFLAGS' are defined in the environment, not changing global flags.
None of 'LDFLAGS' are defined in the environment, not changing global flags.
None of 'CPPFLAGS' are defined in the environment, not changing global flags.
None of 'CC_LD' are defined in the environment, not changing global flags.
None of 'FC' are defined in the environment, not changing global flags.
Failed to find a fortran compiler for CMake. This might cause CMake to fail.
Called `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.EXE -DNAME=OpenCL -DARCHS= -DCOMPS= --trace --trace-expand --no-warn-unused-cli .` in C:\Users\User\lc0\build\meson-private\cmake_OpenCL -> 0
Guessed CMake target 'OpenCL::OpenCL'
CMake TARGET:
  -- name:      OpenCL::OpenCL
  -- type:      UNKNOWN
  -- imported:  True
  -- properties: {
      'IMPORTED_LOCATION': ['C:/Program Files/NVIDIA']
      'GPU': ['Computing Toolkit/CUDA/v10.0/include']
      'INTERFACE_INCLUDE_DIRECTORIES': ['C:/Program Files/NVIDIA']
     }
  -- tline: CMake TRACE: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.15/Modules/FindOpenCL.cmake:166 add_library(['OpenCL::OpenCL', 'UNKNOWN', 'IMPORTED'])
Include Dirs:         ['C:/Program Files/NVIDIA']
Compiler Definitions: []
Compiler Options:     []
Libraries:            ['C:/Program Files/NVIDIA']
Run-time dependency opencl found: YES 1.2

Seems the GPU part of the path matches a property name.

borg323 commented 4 years ago

This is probably related. If we bypass the wrong include path (by passing -Dcudnn=true which adds the correct -same- include path) we get link errors because the (still wrong) library path is used unquoted. See C:/Program Files/NVIDIA at the end of the penultimate line of the following fragment:

Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\link.exe /ERR
  ORREPORT:QUEUE /OUT:".\lc0.exe" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shel
  l32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v
  10.0/lib/x64/cublas.lib" "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/cudnn.lib" "C:/Program Fil
  es/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/cudart.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32
  .lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib "subprojects\zlib-1.2.11\libz.a" /MANIFEST /MANIFESTUA
  C:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FULL /PDB:".\lc0.pdb" /SUBSYSTEM:CONSOLE /LTCG:incremen
  tal /TLBID:1 /ENTRY:"mainCRTStartup" /RELEASE /DYNAMICBASE /NXCOMPAT /IMPLIB:".\lc0.lib" /MACHINE:X64 /OPT:REF C:/Pro
  gram Files/NVIDIA "lc0@exe\common_kernels.obj"