The following code incorrectly report the "removed_configs" are unused (see bug 602209 for the reason why I have to use "removed_configs"):
template("wrapped_shared_library") {
shared_library(target_name) {
forward_variables_from(invoker, "*", ["configs"])
if (defined(invoker.configs)) {
configs += invoker.configs
}
if (defined(invoker.removed_configs)) {
configs -= invoker.removed_configs
}
}
}
wrapped_shared_library("foo") {
sources = ["bar.cc", "bar.h"]
removed_configs = [
"//build/config/gcc:symbol_visibility_hidden"
]
}
Causes the following error while I expect the variable to be marked as used by the template "configs -= remove_unused":
$ gn gen out/gn
ERROR at //foo/BUILD.gn:16:21: Assignment had no effect.
removed_configs = [
^
You set the variable "removed_configs" here and it was unused before it went
out of scope.
See //foo/BUILD.gn:14:1: whence it was called.
wrapped_shared_library("foo") {
^------------------------------
Note that the removed value is present (this command is run with "removed_configs = ..." line commented out):
$ gn desc out/gn //foo configs
//build/config:feature_flags
//build/config/compiler:compiler
//build/config/compiler:clang_stackrealign
//build/config/compiler:compiler_arm_fpu
//build/config/compiler:chromium_code
//build/config/compiler:default_include_dirs
//build/config/compiler:default_optimization
//build/config/compiler:default_symbols
//build/config/compiler:no_rtti
//build/config/compiler:runtime_library
//build/config/sanitizers:default_sanitizer_flags
//build/config/sanitizers:default_sanitizer_coverage_flags
//build/config/gcc:no_exceptions
//build/config/gcc:symbol_visibility_hidden
//build/config/clang:find_bad_constructs
//build/config/clang:extra_warnings
//build/config:debug
//build/config:default_libs
//build/config:shared_library_config
Comment 1 by brettw@chromium.org
, Apr 11 2016