Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiling with OSL 1.11.8 #2900

Closed
wants to merge 1 commit into from
Closed

Fix compiling with OSL 1.11.8 #2900

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 1, 2020

Fixes #2892

@@ -403,6 +403,7 @@ foreach (osl_source ${osl_sources})
OUTPUT ${oso_dir}/${oso_filename}
COMMAND ${CMAKE_COMMAND} -E make_directory ${oso_dir}
COMMAND ${PROJECT_SOURCE_DIR}/sandbox/bin/oslc ${OSLC_OPTIONS}
-I"${PROJECT_SOURCE_DIR}/sandbox/shaders/"
Copy link
Author

@ghost ghost Nov 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSL 1.11.7 and 1.11.8 changed how stdosl.h is looked up: INSTALL_PREFIX/share/OSL/shaders takes precedence over ../shaders (where INSTALL_PREFIX is the compile time path of the installation).

However, if stdosl.h found in the includes it takes the highest precedence.
These changes were introduced in AcademySoftwareFoundation/OpenShadingLanguage#956 and the relevant change can be seen here:
https://github.com/imageworks/OpenShadingLanguage/blob/8ff28a0e062c714b74244cc89fd55461421c5a97/src/liboslcomp/oslcomp.cpp#L334-L341

Comment on lines 41 to 46
// wrap_python.hpp undefines _DEBUG and then redefines it, losing its value of 1
// In OSL 1.11.8 osl/platform.h header assumes that _DEBUG=1, otherwise the
// header can't be compiled
#ifdef _DEBUG
#define _OLD_DEBUG _DEBUG
#endif
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +45 to +51
// wrap_python.hpp undefines _DEBUG and then redefines it without assigning it value of 1
// In OSL 1.11.8 osl/platform.h header uses the syntax "#if _DEBUG" which assumes
// that _DEBUG is not an empty macro, otherwise the header can't be compiled
#ifdef _DEBUG
#undef _DEBUG
#define _DEBUG 1
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is a conflit between boost and OSL ?

Why putting this here exactly ? There isn't any OSL include bellow those lines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. wrap_python.hpp undefines "_DEBUG" then redefines it as an empty macro.
https://github.com/boostorg/python/blob/f1320bf30b4887aff28b9fc67b98f6f8be8c3684/include/boost/python/detail/wrap_python.hpp#L45
https://github.com/boostorg/python/blob/f1320bf30b4887aff28b9fc67b98f6f8be8c3684/include/boost/python/detail/wrap_python.hpp#L209

I added this here directly after "wrap_python.hpp" to fix the macro definition.
Personally I think that the syntax #if OSL_DEBUG instead of #ifdef OSL_DEBUG used in OSL is suboptimal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We have some headers in appleseed wich goal is to include another header and then fix some things, like you are doing here. This ensure that the fix will be avilable everywhere we need wrap_python without having to write the fix multiple times.

@dictoon Can you confirm this ? Do you have an example in mind ?

Copy link
Member

@oktomus oktomus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @theartful !

@bartoszek
Copy link

bartoszek commented Dec 10, 2020

Confirmed 👍 Work on ArchLinux against openshadinglanguage:1.11.10.0 for appleseed:2.1.0 and appleseed:master
build_env={gcc:10.2.0, python2:2.7.18, python:3.9.0, embree:3.12.1, qt5:5.15.2, seexpr:2.11, boost:1.74.0, openexr:2.5.3, opencolorio:1.1.1, openimageio:2.2.9.0, openshadinglanguage:1.11.10.0}
AUR/appleseed
AUR/appleseed-git

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openshadinglanguage:1.11.7 support
3 participants