From 410c0221e80e8425ed4530f1f8a92c221bd8ebad Mon Sep 17 00:00:00 2001 From: Nicholas Junge Date: Tue, 24 Oct 2023 20:20:03 +0200 Subject: [PATCH] Add LTO back to non-Windows builds The Windows case (the option name is "/GL") is more complicated, since there, the compiler options also need to be passed to the linker if LTO is enabled. Since we are gating the linker options on platform at the moment instead of compiler, we need to implement a Bazel boolean flag for the case "Platform == MacOS && Compiler == AnyOf(gcc, clang)". --- bindings/python/nanobind.BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bindings/python/nanobind.BUILD b/bindings/python/nanobind.BUILD index 9d9548b435..c7edfb2b93 100644 --- a/bindings/python/nanobind.BUILD +++ b/bindings/python/nanobind.BUILD @@ -21,8 +21,10 @@ cc_library( "/EHsc", # exceptions "/Os", # size optimizations ], + # these should work on both clang and gcc. "//conditions:default": [ "-fexceptions", + "-flto", "-Os", ], }),