RenderKit / oidn

Intel® Open Image Denoise library
https://www.openimagedenoise.org/
Apache License 2.0
1.77k stars 164 forks source link

Build failure on Windows #61

Closed darbyjohnston closed 4 years ago

darbyjohnston commented 4 years ago

Hi,

I'm trying to build the latest OSPRay with the super build script, and am getting a failure with OpenImageDenoise when compiling the "oidn.rc.res" file:

[ 70%] Building RC object CMakeFiles/OpenImageDenoise.dir/common/oidn.rc.res
        C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe -DDNNL_ENABLE_CONCURRENT_EXEC -DNOMINMAX -DOpenImageDenoise_EXPORTS -D_CRT_SECURE_NO_WARNINGS -D_WIN -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__TBBMALLOC_NO_IMPLICIT_LINKAGE=1 -D__TBB_NO_IMPLICIT_LINKAGE=1 -I C:\dev\ospray-master-Release\oidn\build -I C:\dev\ospray-master-Release\oidn\src\include -I C:\dev\ospray-master-Release\oidn\src -I C:\dev\ospray-master-Release\oidn\src\mkl-dnn\include -I C:\dev\ospray-master-Release\oidn\build\mkl-dnn\include -I C:\dev\ospray-master-Release\oidn\src\mkl-dnn\src -I C:\dev\ospray-master-Release\oidn\src\mkl-dnn\src\common -I C:\dev\ospray-master-Release\oidn\src\mkl-dnn\src\cpu -I C:\dev\ospray-master-Release\oidn\src\mkl-dnn\src\cpu\xbyak -I C:\dev\ospray-master-Release\install\include -DWIN32   /Qpar /fo CMakeFiles\OpenImageDenoise.dir\common\oidn.rc.res C:\dev\ospray-master-Release\oidn\src\common\oidn.rc
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.

fatal error RC1107: invalid usage; use RC /? for Help
NMAKE : fatal error U1077: 'C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

It looks likes the error is coming from the /Qpar flag that is being passed to rc.exe. I think that flag is coming from line 135 of oidn_platform.cmake:

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  add_definitions(/Qpar)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")

I'm not sure why CMake is adding that to the rc.exe command-line, it seems like it is meant for the compiler to enable parallel builds.

This is using VS2017 on Windows 10 with CMake 3.17.1.

Thanks, Darby

atafra commented 4 years ago

Hi Darby,

Could you please post this issue to OSPRay as well? It seems to be specific to OSPRay's superbuild script.

Thanks, Attila

darbyjohnston commented 4 years ago

Hi Attila,

Thanks for the quick response; I tried building OpenImageDenoise on it's own and it completed successfully, so it does seem like it has to do with the OSPRay super build script. The odd thing is that the command-lines for rc.exe look quite different between the two; this is building OpenImageDenoise on it's own:

C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86\rc.exe
    /D WIN32
    /D _WINDOWS
    /D NDEBUG
    /D __STDC_LIMIT_MACROS
    /D __STDC_CONSTANT_MACROS
    /D _CRT_SECURE_NO_WARNINGS
    /D _WIN
    /D NOMINMAX
    /D __TBB_NO_IMPLICIT_LINKAGE=1
    /D __TBBMALLOC_NO_IMPLICIT_LINKAGE=1
    /D DNNL_ENABLE_CONCURRENT_EXEC
    /D "CMAKE_INTDIR=\\\"Release\\\""
    /D OpenImageDenoise_EXPORTS
    /l"0x0409"
    /IC:\dev\oidn\oidn\build
    /IC:\dev\oidn\oidn\include
    /IC:\dev\oidn\oidn
    /I"C:\dev\oidn\oidn\mkl-dnn\include"
    /I"C:\dev\oidn\oidn\build\mkl-dnn\include"
    /I"C:\dev\oidn\oidn\mkl-dnn\src"
    /I"C:\dev\oidn\oidn\mkl-dnn\src\common"
    /I"C:\dev\oidn\oidn\mkl-dnn\src\cpu"
    /I"C:\dev\oidn\oidn\mkl-dnn\src\cpu\xbyak"
    /IC:\dev\oidn\tbb\include
    /nologo
    /fo"OpenImageDenoise.dir\Release\oidn.res"
    C:\dev\oidn\oidn\common\oidn.rc 

And this is the command-line from the OSPRay super build script:

C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe
    -DDNNL_ENABLE_CONCURRENT_EXEC
    -DNOMINMAX
    -DOpenImageDenoise_EXPORTS
    -D_CRT_SECURE_NO_WARNINGS
    -D_WIN
    -D__STDC_CONSTANT_MACROS
    -D__STDC_LIMIT_MACROS
    -D__TBBMALLOC_NO_IMPLICIT_LINKAGE=1
    -D__TBB_NO_IMPLICIT_LINKAGE=1
    -I C:\dev\ospray-v2.1.0-Release\oidn\build
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\include
    -I C:\dev\ospray-v2.1.0-Release\oidn\src
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\mkl-dnn\include
    -I C:\dev\ospray-v2.1.0-Release\oidn\build\mkl-dnn\include
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\mkl-dnn\src
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\mkl-dnn\src\common
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\mkl-dnn\src\cpu
    -I C:\dev\ospray-v2.1.0-Release\oidn\src\mkl-dnn\src\cpu\xbyak
    -I C:\dev\ospray-v2.1.0-Release\install\include
    -DWIN32
    /Qpar
    /fo CMakeFiles\OpenImageDenoise.dir\common\oidn.rc.res
    C:\dev\ospray-v2.1.0-Release\oidn\src\common\oidn.rc

I'll look into it a bit more and open an issue on the OSPRay site.

Thanks, Darby

darbyjohnston commented 4 years ago

Hi, I created an issue for this on the OSPRay GitHub page but it looks like this is not specific to the OSPRay superbuild; @stukowski reported running into this when compiling OpenImageDenoise separately. The suggested fix is to replace add_definitions(/Qpar) with add_compile_options(/Qpar) which looks like a good change since /Qpar is a compiler option and not a preprocessor definition.

https://github.com/ospray/ospray/issues/413

atafra commented 4 years ago

Thanks, I could reproduce the issue. It seems it happens only when building with nmake. Your suggested fix indeed works. I pushed the fix to the devel branch.

darbyjohnston commented 4 years ago

Great, thanks for making the change!