PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.99k stars 1.18k forks source link

Build option to use _GLIBCXX_USE_CXX11_ABI=0 #1609

Open colaub opened 3 years ago

colaub commented 3 years ago

Description of Issue

Most third parties or vfx libs use by default _GLIBCXX_USE_CXX11_ABI=0 it's also recommended by https://vfxplatform.com/ Building USD plugins with these libs causes conflicts. Is there a reason why USD and its dependencies don't use _GLIBCXX_USE_CXX11_ABI=0? If it is a deliberate choice, could we add an option to _buildusd.py to switch values?

System Information (OS, Hardware)

Linux

Thanks for enlightening me on that :pray: !

jilliene commented 3 years ago

Filed as internal issue #USD-6873

sunyab commented 2 years ago

Hi @colaub, our primary test platform forces _GLIBCXX_USE_CXX11_ABI=0 so we hadn't observed a problem internally, and no one's raised this issue before (which is maybe a little surprising).

We think it would be a good idea to add a parameter to build_usd.py to let users specify the value for _GLIBCXX_USE_CXX11_ABI to use when building USD and its dependencies. However, we won't be setting this by default. We think it would be less confusing and less error-prone for users to rely on the compiler's default ABI setting instead of having to know about and define this in their builds. The parameter will at least give advanced users an easy way to set this up when it's needed.

colaub commented 2 years ago

Hi @sunyab thanks for your reply. I agree with your proposition. Today, we have to do :

build_usd.py ... --build-args USD,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" BOOST,"define=_GLIBCXX_USE_CXX11_ABI=0" OPENSUBDIV,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" OPENEXR,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" MATERIALX,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" ALEMBIC,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" OPENIMAGEIO,"-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0"

I think no one's raise this issue because ABI setting is pretty advanced and plugin editors build USD without build_usd.py and with their own third-party packages.

Thanks for this proposition.

Cheers.

colaub commented 2 years ago

Hello, even if we use the new flag --use-cxx11-abi 0 we still need to pass the build flag --build-args BOOST,"define=_GLIBCXX_USE_CXX11_ABI=0" for boost. Because I guess boost doesn't use cmake.

idk if I have to do a new issue ticket or let my comment here.

Thanks

Colin.

sunyab commented 2 years ago

@colaub have you confirmed this doesn't work? I believe this line should have added the necessary define to cxxflags when building boost:

https://github.com/PixarAnimationStudios/USD/blob/release/build_scripts/build_usd.py#L831

colaub commented 2 years ago

Hello, it's verified. If I understand well your AppendCXX11ABIArg def you assume that all USD's third-parties use -D as variable declaration but boost seems to doesn't consider it and need to use define= flag instead of -D. So I guess we have to make an exception for boost in the build_script. https://stackoverflow.com/questions/36309021/how-to-compile-boost-with-gcc-5-using-old-abi

Thanks

Colin.

sunyab commented 2 years ago

Ah, I totally missed that with the original change. Thanks for calling that out, will have another look.