From c601618c532d1370cd64927eb5b70cb875733bf9 Mon Sep 17 00:00:00 2001 From: David Havas Date: Wed, 18 Dec 2024 00:19:26 +0100 Subject: [PATCH] Fix typos with calculating flags for lto setting Default behavior was incorrect as the `unspecified` should have no-op on the compile flags. However this was not the case due to incorrect conditions. --- rust/private/lto.bzl | 4 ++-- test/unit/lto/lto_test_suite.bzl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/private/lto.bzl b/rust/private/lto.bzl index 3f5c16264a..60eb322e67 100644 --- a/rust/private/lto.bzl +++ b/rust/private/lto.bzl @@ -101,10 +101,10 @@ def construct_lto_arguments(ctx, toolchain, crate_info): if mode in ["thin", "fat", "off"] and not is_exec_configuration(ctx): args.append("lto={}".format(mode)) - if format in ["unspecified", "object_and_bitcode"]: + if mode == "unspecified" or format == "object_and_bitcode": # Embedding LLVM bitcode in object files is `rustc's` default. args.extend([]) - elif format in ["off", "only_object"]: + elif mode == "off" or format == "only_object": args.extend(["embed-bitcode=no"]) elif format == "only_bitcode": args.extend(["linker-plugin-lto"]) diff --git a/test/unit/lto/lto_test_suite.bzl b/test/unit/lto/lto_test_suite.bzl index d70d3bce24..c7fed8e685 100644 --- a/test/unit/lto/lto_test_suite.bzl +++ b/test/unit/lto/lto_test_suite.bzl @@ -39,7 +39,7 @@ def _lto_test_impl(ctx, lto_setting, embed_bitcode, linker_plugin): return analysistest.end(env) def _lto_level_default(ctx): - return _lto_test_impl(ctx, None, "no", False) + return _lto_test_impl(ctx, None, None, False) _lto_level_default_test = analysistest.make( _lto_level_default,