Skip to content

Commit

Permalink
Fix Windows build
Browse files Browse the repository at this point in the history
Summary:
some code to support cinderx 3.12 was added, but in a way that broke the windows build. this diff fixes that by:
1. using `Py_EXPORTED_SYMBOL` instead of `__attribute__ ((visibility ("default")))` (`Py_EXPORTED_SYMBOL` has all the platform-specific ifdefs to do the right thing)
1. add the cinder hooks and ci_api headers and cinderhooks.c to the relevant MSVC project files to let the windows build find and include them when building

Reviewed By: martindemello

Differential Revision: D65397438

fbshipit-source-id: 8a373d8c438f8b4cea5e1299f939fb17ef2dc46c
  • Loading branch information
itamaro authored and facebook-github-bot committed Nov 4, 2024
1 parent 5ffad1a commit 34d2cc3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Include/cinder/ci_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@
* prerequisites for CinderX being compatible with non-Cinder Python.
*/

#include "exports.h"

// These function the same as PyAPI_* - exporting symbols for use in .so's etc.
#define CiAPI_FUNC(RTYPE) __attribute__ ((visibility ("default"))) RTYPE
#define CiAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
#ifdef __clang__
# ifdef __cplusplus
# define CiAPI_DATA(RTYPE) __attribute__ ((visibility ("default"))) extern "C" RTYPE
# define CiAPI_DATA(RTYPE) Py_EXPORTED_SYMBOL extern "C" RTYPE
# else
# define CiAPI_DATA(RTYPE) __attribute__ ((visibility ("default"))) extern RTYPE
# define CiAPI_DATA(RTYPE) Py_EXPORTED_SYMBOL extern RTYPE
# endif
#else
# ifdef __cplusplus
# define CiAPI_DATA(RTYPE) extern "C" __attribute__ ((visibility ("default")))RTYPE
# define CiAPI_DATA(RTYPE) extern "C" Py_EXPORTED_SYMBOL RTYPE
# else
# define CiAPI_DATA(RTYPE) extern __attribute__ ((visibility ("default"))) RTYPE
# define CiAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
# endif
#endif

// Clang seems to (always?) make symbols for static inline functions.
#ifdef __clang__
# define CiAPI_STATIC_INLINE_FUNC(RTYPE) static inline __attribute__ ((visibility ("default"))) RTYPE
# define CiAPI_STATIC_INLINE_FUNC(RTYPE) static inline Py_EXPORTED_SYMBOL RTYPE
#else
# define CiAPI_STATIC_INLINE_FUNC(RTYPE) static inline RTYPE
#endif
1 change: 1 addition & 0 deletions PCbuild/_freeze_module.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
<ClCompile Include="..\Python\bltinmodule.c" />
<ClCompile Include="..\Python\bootstrap_hash.c" />
<ClCompile Include="..\Python\ceval.c" />
<ClCompile Include="..\Python\cinderhooks.c" />
<ClCompile Include="..\Python\codecs.c" />
<ClCompile Include="..\Python\compile.c" />
<ClCompile Include="..\Python\context.c" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/_freeze_module.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<ClCompile Include="..\Python\ceval.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Python\cinderhooks.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Objects\classobject.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
<ClInclude Include="..\Include\codecs.h" />
<ClInclude Include="..\Include\compile.h" />
<ClInclude Include="..\Include\complexobject.h" />
<ClInclude Include="..\Include\cinder\ci_api.h" />
<ClInclude Include="..\Include\cinder\hooks.h" />
<ClInclude Include="..\Include\cpython\abstract.h" />
<ClInclude Include="..\Include\cpython\bytearrayobject.h" />
<ClInclude Include="..\Include\cpython\bytesobject.h" />
Expand Down Expand Up @@ -515,6 +517,7 @@
<ClCompile Include="..\Python\bltinmodule.c" />
<ClCompile Include="..\Python\bootstrap_hash.c" />
<ClCompile Include="..\Python\ceval.c" />
<ClCompile Include="..\Python\cinderhooks.c" />
<ClCompile Include="..\Python\codecs.c" />
<ClCompile Include="..\Python\compile.c" />
<ClCompile Include="..\Python\context.c" />
Expand Down
9 changes: 9 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<ClInclude Include="..\Include\bytesobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cinder\ci_api.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cinder\hooks.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\ceval.h">
<Filter>Include</Filter>
</ClInclude>
Expand Down Expand Up @@ -1130,6 +1136,9 @@
<ClCompile Include="..\Python\ceval.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\cinderhooks.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\codecs.c">
<Filter>Python</Filter>
</ClCompile>
Expand Down

0 comments on commit 34d2cc3

Please sign in to comment.