nicholasjng / nanobind-bazel

Bazel defs and rules for building Python projects with nanobind extensions.
Apache License 2.0
9 stars 1 forks source link

Remove default LTO options, dead_strip in MacOS linker options #16

Closed nicholasjng closed 8 months ago

nicholasjng commented 8 months ago

Follows the official documentation's guidance that LTO is not strictly necessary due to the library component. As an alternative, users can give the thin_lto feature to a nanobind_extension instead.

The second -Wl,-dead_strip removal is due to it appearing twice in the generated linker command. I also saw a missing symbol error during a stubgen attempt earlier, which has since disappeared.

nicholasjng commented 8 months ago

Hm, I wonder what happened here.

The only thing I can think of is that I have removed the building Python's library directories from the linkopts for Windows in the meantime in the nanobind_example. So this still works for all Pythons except 3.12?

nicholasjng commented 8 months ago

Summary:

1) @rules_python Windows toolchains do not yet add the unversioned libs/python3.lib to the library target, preventing SABI builds on Windows. This is hopefully fixed in the next release with the PR mentioned above. 2) Apparently, Python itself (in a header called pyconfig.h) designates the correct library to link on Windows without me having to do anything, so the select()s with the current libs can all go. (cool!)

nicholasjng commented 8 months ago

I'm going to merge this, and require a newer rules_python for future versions.