OpenNURBS cmake builds in Debug mode but fails in Release mode

Hello!

I have recently cloned opennurbs from GitHub - mcneel/opennurbs: OpenNURBS libraries allow anyone to read and write the 3DM file format without the need for Rhino., and I have used cmake to build the library, by creating a build/ directory in opennurbs. Also, I use VS2022.

Debug:

~$ cd opennurbs/build/
~$ cmake ..
~$ cmake --build . --clean-first

The build is successful and the library works as expected.

I attempted to build the library in Release mode as follows:

~$ cd opennurbs/build/
~$ cmake -DCMAKE_BUILD_TYPE=Release ..
~$ cmake --build . --config Release --clean-first

But the build failed with the following errors:

...
...
  Generating Code...
C:\OpenNURBS\opennurbs\opennurbs_lookup.cpp(700): fatal  error C1001: Internal compiler error.
[C:\OpenNURBS\opennurbs\build\OpenNURBS.vcxproj]
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c', line 234)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
 CL!RaiseException()+0x69
 CL!RaiseException()+0x69
 CL!InvokeCompilerPass()+0x26b
 CL!InvokeCompilerPassW()+0x142a6a
...
...
...
  Generating Code...
C:\OpenNURBS\opennurbs\opennurbs_lookup.cpp(700): fatal  error C1001: Internal compiler error.
[C:\OpenNURBS\opennurbs\build\opennurbsStatic.vcxproj]
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c', line 234)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
 CL!RaiseException()+0x69
 CL!RaiseException()+0x69
 CL!InvokeCompilerPass()+0x26b
 CL!InvokeCompilerPassW()+0x142a6a

Can you please advise how to resolve this issue?
Would it be a viable solution to build the library in VS2019 and use it VS2022?

I’ve seen this before and haven’t been able to figure out how to work around the compiler issue. I do think that the bug does not exist if compiling with VS2019. What happens if you open the vcxproj that cmake produces and try to compile while inside of VS2022?

Nice suggestion. Same issue I’m afraid. Just tried it.

4>Generating Code...
4>C:\OpenNURBS\opennurbs\opennurbs_lookup.cpp(700): fatal  error C1001: Internal compiler error.
4>(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c', line 234)
4> To work around this problem, try simplifying or changing the program near the locations listed above.
4>If possible please provide a repro here: https://developercommunity.visualstudio.com
4>Please choose the Technical Support command on the Visual C++
4> Help menu, or open the Technical Support help file for more information
4>  CL!RaiseException()+0x69
4>  CL!RaiseException()+0x69
4>  CL!InvokeCompilerPass()+0x26b
4>  CL!InvokeCompilerPassW()+0x142a6a
4>Done building project "OpenNURBS.vcxproj" -- FAILED.
5>------ Rebuild All started: Project: ALL_BUILD, Configuration: Release x64 ------
5>Building Custom Rule C:/OpenNURBS/opennurbs/CMakeLists.txt
6>------ Skipped Rebuild All: Project: INSTALL, Configuration: Release x64 ------
6>Project not selected to build for this solution configuration 
========== Rebuild All: 3 succeeded, 2 failed, 1 skipped ==========
========== Rebuild completed at 18:10 and took 30.979 seconds ==========

Update:
The OpenNURBS library builds successfully using cmake and VS2019 for both, Debug and Release, modes.

One more data point:

Loading the solution file (not command line cmake), VS2022 compiles the release version cleanly for a version of opennurbs from a few months ago. I don’t have a reason to believe that the current one won’t; I just haven’t updated.

I don’t recall making any significant changes; I might have turned off precompiled headers.

Based on previous help from Dale while I had been trying to use the C++ SDK in VS 2022, I do have some of the VS2019 components installed and that may have something to do with my success here:

Screenshot (475)

Thanks for your reply Nathan! To be 100% sure, remove all instances/components of VS2019 and try to clean rebuild. I think I tried to build the lib from VS too but it didn’t work for both modes (release and debug). One failed if I remember correctly…

I don’t have any part of the VS 2019 development package installed from VS 2019, but from within the VS 2022 installer I have added these components:
Screenshot (481)

If you have a cmake to run I can give that a whirl to see what happens with my config.

Nathan you are compiling with the 2019 tools which is why everything is working. I have been able to repeat the 2022 compiler crash and haven’t found a solution yet.

Well, yes.

I didn’t realize that VS 2022 was supported without using them yet. I look forward to it!

Happy to help with repros or anything to move things along.

Edit: a fresh download from today works in Debug and Release after accepting the upgrade prompt for latest v10 SDK and the v143 tools.

That’s the latest, isn’t it?

We haven’t updated the pre-build vcxproj for opennurbs to use something newer than the 2019 toolkit partially because of this compiler crash and because that is the toolkit we use for core Rhino compiles as well.

Just for information, Rhino 8 has the same issue. I solved by disabling the optimization for the problematic function

#pragma optimize("", off)
ON_SerialNumberMap::SN_ELEMENT* ON_SerialNumberMap::FirstElement() const
{
...
}
#pragma optimize("", on)
3 Likes

Thanks Thomas, that is good to know as a workaround. We have a bug logged for this and will consider something like this specifically for the VS2022 compile

For now this gets Opennurbs 8.5 compiled, tnx!
There is a bug report in the Developer Community:
https://developercommunity.visualstudio.com/t/fatal-error-C1001:-Internal-compiler-err/10616058