bazelRio / bazelRio

Bazel workflows for the roboRIO and WPILib
MIT License
9 stars 4 forks source link

Manually patch binaries to fix macOS native builds #115

Open connorworley opened 2 years ago

connorworley commented 2 years ago

This isn't the prettiest, but it demonstrates a potential fix for macos using install_name_tool.

connorworley commented 2 years ago

I think I can refactor this to avoid the extra copy step on non-macOS platforms

connorworley commented 2 years ago

I think it probably is a bazel problem (something to do with cc_library vs cc_import) but I don't really know how to fix it. Maybe we can run with this approach and revisit the problem later.

noamzaks commented 2 years ago

In that case, I think it would be better to replace our use of cc_library to cc_imports.

I tried to do so, but:

Consequently, I think our options for achieving this are:

I'm in favor of the first option.

I think kicking this can down the road can cause more issues and make the project less readable, but at the same time, simulation on macOS is definitely a required feature, so I leave it to you guys to decide about merging this.

noamzaks commented 2 years ago

On second thought, after testing on https://github.com/noamzaks/bazel-test-cpp-library

I think cc_import might also be bugged on macOS...

dyld[96783]: Library not loaded: libfoo.so
  Referenced from: /private/var/tmp/_bazel_noamzaks/347e8076471125fc8ec55128ba990c2f/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/main
  Reason: tried: 'libfoo.so' (no such file), '/usr/local/lib/libfoo.so' (no such file), '/usr/lib/libfoo.so' (no such file), '/private/var/tmp/_bazel_noamzaks/347e8076471125fc8ec55128ba990c2f/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/main.runfiles/__main__/libfoo.so' (no such file), '/usr/local/lib/libfoo.so' (no such file), '/usr/lib/libfoo.so' (no such file)
connorworley commented 2 years ago

https://github.com/bazelbuild/bazel/issues/7415 seems relevant