PixarAnimationStudios / OpenSubdiv

An Open-Source subdivision surface library.
graphics.pixar.com/opensubdiv
Other
2.89k stars 561 forks source link

Compile errors while building with Ninja Release 3_4_4 #1269

Closed roquo closed 1 year ago

roquo commented 2 years ago

Hello,

I tried to build OpenSubdiv with Ninja. Unfortunately, I get a lot of warnings that are treated as errors and the build fails.

My setup:

Microsoft Visual Studio Professional LTSC 2022 17.2.3
Windows Kits SDK 10.0.19041.0
CMake 3.20.5
Ninja 1.10.2

The commands I run:

git clone https://github.com/PixarAnimationStudios/OpenSubdiv
cd OpenSubdiv
mkdir build
mkdir install
cd build
set INCLUDE=C:/Program Files/Microsoft Visual Studio/2022/17.2/VC/Tools/MSVC/14.32.31326/ATLMFC/include;C:/Program Files/Microsoft Visual Studio/2022/17.2/VC/Tools/MSVC/14.32.31326/include;C:/Program Files/Windows Kits/NETFXSDK/4.8/include/um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
set LIB=C:/Program Files/Microsoft Visual Studio/2022/17.2//VC/Tools/MSVC\14.32.31326\lib\x64;C:/Program Files/Microsoft Visual Studio/2022/17.2/VC/Tools/MSVC/14.32.31326/ATLMFC/lib/x64
cmake -G Ninja .. -DNO_EXAMPLES=1 -DNO_TUTORIALS=1 -DNO_REGRESSION=1 -DNO_PTEX=1 -DNO_DOC=1 -DNO_OMP=1 -DNO_TBB=1 -DNO_CUDA=1 -DNO_OPENCL=1 -DNO_CLEW=1 -DNO_OPENGL=1 -DNO_METAL=1 -DNO_DX=1 -DNO_TESTS=1 -DNO_GLTESTS=1 -DNO_GLEW=1 -DNO_GLFW=1 -DNO_GLFW_X11=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\install
ninja install

Output after running CMake:

-- The C compiler identification is MSVC 19.32.31329.0
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/17.2/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/17.2/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:27 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Compiling OpenSubdiv version v3_4_4
-- Using cmake version 3.20.5
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Test/OpenSubdiv/build

Output after running ninja install: openSubdiv_errorLog.txt

davidgyu commented 2 years ago

Filed as internal issue #OSD-388

davidgyu commented 2 years ago

Have you tried using the dev branch or v3_5_0_RC1? We've recently merged some fixes which suppress some of these warnings and we've verified those fixes with the Visual Studio generator (and GCC and Xcode) but not Ninja.

We've noticed that the Ninja build appears to be using a different set of compiler flags than the Visual Studio generator. This isn't entirely surprising, but it is something that we haven't really looked into yet and would need to be addressed. That could be a good pull request contribution!

That said, I took a quick look and I was able to get the dev branch to build with ninja using the configuration you describe after disabling the following additional MSVC warnings: /wd4710 /wd4711 /wd4738 /wd5045

svenstaro commented 2 years ago

I also get ninja failures on 3.5.0:

ninja: Entering directory `build'
ninja: warning: phony target 'documentation/search.html' names itself as an input; ignoring [-w phonycycle=warn]
ninja: error: build.ninja:5613: multiple rules generate documentation/search.html
davidgyu commented 1 year ago

We've collected ninja related issues here since this issue is paired with a PR which addresses some aspects of the problem.

While this didn't make the cut for v3.5.1 we've been starting work to true-up the compiler warning settings across different build configurations and we'll try to address these ninja related discrepancies as part of that work.

LazyDodo commented 1 year ago

The root cause still remains unaddressed in the PR's I have seen sofar, people appear to be addressing symptoms by twiddling with the individual warning flags rather than dealing with the fact that passing both /W3 and /Wall is causing these issues in the first place. (further details #1284)

davidgyu commented 1 year ago

Thanks @LazyDodo! That's why we've linked all of these issues together so that we don't loose track of your notes over there.

davidgyu commented 1 year ago

Fixed by #1318 and #1323