Skip to content

Commit

Permalink
Remove default LTO options, dead_strip in MacOS linker options
Browse files Browse the repository at this point in the history
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 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.
  • Loading branch information
nicholasjng committed Mar 22, 2024
1 parent 9a4e02b commit 68dbfd8
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions nanobind.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ cc_library(
}),
copts = select({
"@rules_cc//cc/compiler:msvc-cl": [
"/EHsc", # exceptions
"/GL", # LTO / whole program optimization
"/EHsc", # exceptions.
],
# clang and gcc, across all platforms.
"//conditions:default": [
"-fexceptions",
"-flto",
"-fno-strict-aliasing",
],
}) + sizeopts(),
Expand All @@ -49,9 +47,7 @@ cc_library(
],
"@platforms//os:macos": [
"-Wl,@$(location :cmake/darwin-ld-cpython.sym)", # Apple.
"-Wl,-dead_strip",
],
"@rules_cc//cc/compiler:msvc-cl": ["/LTCG"], # MSVC.
"//conditions:default": [],
}),
local_defines = sizedefs(), # sizeopts apply to nanobind only.
Expand Down

0 comments on commit 68dbfd8

Please sign in to comment.