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

Add macOS support #151

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Add macOS support #151

merged 4 commits into from
Dec 11, 2023

Conversation

lzaoral
Copy link
Member

@lzaoral lzaoral commented Dec 9, 2023

No description provided.

@lzaoral lzaoral self-assigned this Dec 9, 2023
@lzaoral lzaoral force-pushed the add-macos-support branch 2 times, most recently from d905fbc to 552e07f Compare December 9, 2023 14:15
@lzaoral
Copy link
Member Author

lzaoral commented Dec 9, 2023

TODO:

Python3::Module

New in version 3.15.

Python 3 library for Python module. Target defined if component Development.Module is found.

edit: done

@lzaoral
Copy link
Member Author

lzaoral commented Dec 9, 2023

Ok, I forgot that sanitizers and GitHub's macOS machines do not like each other:

/usr/local/include/boost/any.hpp:326:13: runtime error: downcast of address 0x603000002dd0 which does not point to an object of type 'any::holder<string>'
0x603000002dd0: note: object is of type 'boost::any::holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >'
 00 00 00 00  c0 ff ef 05 01 00 00 00  51 00 00 00 00 00 00 00  47 00 00 00 00 00 00 00  e0 16 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'boost::any::holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/include/boost/any.hpp:326:13 

No idea why though, it works perfectly fine on my machine...

... to fix the following build error on macOS:
```
[ 86%] Linking CXX shared library pycsdiff_py3/pycsdiff.dylib
ld: Undefined symbols:
  _PyUnicode_FromStringAndSize, referenced from:
      boost::python::detail::caller_arity<2u>::impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), boost::python::default_call_policies, boost::mpl::vector3<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>>::operator()(_object*, _object*) in pycsdiff.cc.o
      boost::python::objects::caller_py_function_impl<boost::python::detail::caller<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(), boost::python::default_call_policies, boost::mpl::vector1<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>>::operator()(_object*, _object*) in pycsdiff.cc.o
  _PyUnicode_Type, referenced from:
      boost::python::detail::converter_target_type<boost::python::to_python_value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>>::get_pytype() in pycsdiff.cc.o
  __Py_Dealloc, referenced from:
      boost::python::api::slice_nil::~slice_nil() in pycsdiff.cc.o
      void boost::python::def<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)) in pycsdiff.cc.o
      void boost::python::def<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)()>(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> (*)()) in pycsdiff.cc.o
      boost::python::api::object::~object() in pycsdiff.cc.o
  __Py_NoneStruct, referenced from:
      __GLOBAL__sub_I_pycsdiff.cc in pycsdiff.cc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
@lzaoral lzaoral marked this pull request as ready for review December 10, 2023 08:38
@lzaoral lzaoral requested a review from kdudka December 10, 2023 08:38
... to mark the intent that it is meant to be used by `dlopen` only.

Consequently, this forces the library to always use the `.so` suffix
which fixes the following test failure on macOS because Python ignores
shared libraries with the native `.dylib` suffix.
```
pycsdiff_py3......................................***Failed    0.02 sec
Traceback (most recent call last):
      File "<string>", line 1, in <module>
      ModuleNotFoundError: No module named 'pycsdiff'
```
Copy link
Member

@kdudka kdudka left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@lzaoral lzaoral merged commit 56ceca8 into csutils:main Dec 11, 2023
29 checks passed
@lzaoral lzaoral deleted the add-macos-support branch December 11, 2023 08:30
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.

2 participants