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

macOS compilation fails #306

Open
oceanusxiv opened this issue Apr 24, 2024 · 1 comment
Open

macOS compilation fails #306

oceanusxiv opened this issue Apr 24, 2024 · 1 comment

Comments

@oceanusxiv
Copy link

I understand that this has only been tested on Ubuntu 22.04, and macOS isn't even a particularly well supported target for ROS2, this is more for presenting my findings trying to make this work on a Mac than anything else.

First, the pic_static_library property on Mac isn't set for many static libraries, but this is easily resolved with

if library.pic_static_library == None:

if library.pic_static_library == None and library.static_library == None:

to restore the previous behavior.

After this, we get python linking errors

ERROR: /private/var/tmp/_bazel_xxx/0c6fe4d261a727bb6fbfa1fdc418e921/external/ros2_rcl_interfaces/BUILD.bazel:25:23: Linking external/ros2_rcl_interfaces/builtin_interfaces/libbuiltin_interfaces_s__rosidl_typesupport_c.dylib failed: (Exit 1): sandbox-exec failed: error executing CppLink command 
  (cd /private/var/tmp/_bazel_xxx/0c6fe4d261a727bb6fbfa1fdc418e921/sandbox/darwin-sandbox/97/execroot/com_github_mvukov_rules_ros2 && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/r6/xyz_wzyd5tv_0snr3fmtc3lr0000gn/T/ \
    ZERO_AR_DATE=1 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_xxx/0c6fe4d261a727bb6fbfa1fdc418e921/sandbox/darwin-sandbox/97/sandbox.sb /var/tmp/_bazel_xxx/install/c235141d88c168b049a191acefbb1f54/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_xxx/0c6fe4d261a727bb6fbfa1fdc418e921/sandbox/darwin-sandbox/97/stats.out' external/local_config_cc/cc_wrapper.sh @bazel-out/darwin_arm64-fastbuild/bin/external/ros2_rcl_interfaces/builtin_interfaces/libbuiltin_interfaces_s__rosidl_typesupport_c.dylib-2.params)
Undefined symbols for architecture arm64:
  "_PyCapsule_New", referenced from:
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      ...
  "_PyImport_ImportModule", referenced from:
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
  "_PyLong_AsLong", referenced from:
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
  "_PyLong_AsUnsignedLong", referenced from:
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
  "_PyLong_FromLong", referenced from:
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
  "_PyLong_FromUnsignedLong", referenced from:
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
  "_PyModule_AddObject", referenced from:
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__duration in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      __register_msg_type__msg__time in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
      ...
  "_PyModule_Create2", referenced from:
      _PyInit_builtin_interfaces_s__rosidl_typesupport_c in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
  "_PyObject_CallObject", referenced from:
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
  "_PyObject_GetAttrString", referenced from:
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_from_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
      _builtin_interfaces__msg__time__convert_from_py in _time_s.o
      ...
  "_PyObject_SetAttrString", referenced from:
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__duration__convert_to_py in _duration_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
      _builtin_interfaces__msg__time__convert_to_py in _time_s.o
  "__Py_Dealloc", referenced from:
      __Py_DECREF in _duration_s.o
      __Py_DECREF in _time_s.o
      __Py_DECREF in _builtin_interfaces_s.ep.rosidl_typesupport_c.o
ld: symbol(s) not found for architecture arm64

So clearly somewhere CPython is not being linked properly, unfortunately I'm not good enough at bazel to really figure out where it went wrong.

@mvukov
Copy link
Owner

mvukov commented Apr 24, 2024

Thanks for looking into this. You can try to fix linking as in https://github.com/pybind/pybind11_bazel/blob/master/build_defs.bzl#L56-L58. If that works, please open a PR with fixes from this discussion.

It's on my TODO list to create a python extension macro as in the repo above...

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

No branches or pull requests

2 participants