mitsuba-renderer / nanogui

Minimalistic C++/Python GUI library for OpenGL, GLES2/3, Metal, and WebAssembly/WebGL
Other
1.52k stars 189 forks source link

build: Accept libstdc++ when using clang #130

Closed tbaederr closed 1 year ago

tbaederr commented 1 year ago

There really shouldn't be any problem with using libstdc++ with clang. I couldn't find any information about why this check exists in the first place.

tbaederr commented 1 year ago

For a discussion on allowing libstdc++ to be used with clang, see https://github.com/mitsuba-renderer/mitsuba3/pull/246

jwakely commented 1 year ago

I'm going to guess that the "you must use libc++ with clang" restriction began because on macOS the default libstdc++ is ancient (GCC 4.2) and doesn't even support C++11. So on macOS it's reasonable to require libc++.

But on Linux the default libstdc++ is often more capable than any version of libc++, because even the latest libc++ release has incomplete C++17 support, and libstdc++ is more complete. So clang on Linux will generally have a good version of libstdc++.

Even on macOS, it's possible to use Clang's --with-gcc-toolchain option to point it at specific newer libstdc++ headers. So it might make more sense to do a feature check for required C++17 features, instead of requiring -stdlib=libc++ specifically.

I have checked that the project builds OK using GCC 12 and GCC 8, which both use libstdc++, and Timm checked it using Clang with libstdc++.

wjakob commented 1 year ago

This looks fine to me. The original error message was from a time where Clang and libstdc++ did not play very well together.