HadrienG2 / hwlocality

Rust bindings to Open MPI Portable Hardware Locality "hwloc" library, covering version 2.0 and above.
MIT License
20 stars 5 forks source link

Try to make bundled feature work on macOS, without dynamic linking #31

Closed HadrienG2 closed 8 months ago

HadrienG2 commented 1 year ago

The bundled feature is currently hardcoded to error out on macOS (and this combination is disabled in CI) because if I let such a build run through, it will bomb at binary linking time due to the fact that for some unknown reason, the resulting internal hwloc build does not correctly set the -framework flags that it needs in its pkgconfig file.

I do not have a Mac around, so I cannot investigate this on my side. Patches from Mac users are welcome!

nazar-pc commented 8 months ago

Silent shared library for macOS will be an issue for me. What error did you get exactly on macOS?

HadrienG2 commented 8 months ago

This problem has been resolved by PR #45, which is why the issue is closed ;)

nazar-pc commented 8 months ago

It was resolved by building a shared library, not static. Which means it is no longer possible to build an app an ship it to the user, shared library will need to be shipped alongside it as well, which is not very Rusty and not expected behavior, so making it compile statically is still something worth pursuing (though not a high priority for me, I will not be using this library on macOS by default for now).

HadrienG2 commented 8 months ago

I see. In this case, feel free to switch back to static linking and try to resolve the error on your side.

The symptom was a linker error claiming that some core macOS API functions were undefined symbols, missing from the set of libraries that the final binary links to.

I figured out that this was due to the fact that if you link to hwloc statically, you must pass in the right -framework flags to dynamically link to hwloc's runtime dependencies, but hwloc's pkgconfig file will not do it for you. I did not want to hardcode hwloc's -framework flags, and couldn't find another way to do it, especially as without having a Mac at hand, CI trial and error is a major pain.