cc @trybka @armandomontanez
When a rules-based toolchain enables static_link_cpp_runtimes (required to use static_runtime_lib / dynamic_runtime_lib), rules_cc currently also enables static_libgcc such that -static-libgcc is added to all link actions.
This is problematic for toolchains that:
- use clang with
compiler-rt + libunwind (i.e., not GCC’s libgcc for runtime/unwinding), or
- expect a single, process-wide unwinder when DSOs throw/catch across boundaries.
Current escape hatch
--features=-static_libgcc works, but is not ideal for a public/toolchain-default experience.
The alternative option is to redefine/duplicate the entire experimental_replace_legacy_action_config_features feature set just to drop //cc/toolchains/args/static_libgcc:feature.
That duplication is especially painful because some targets aren’t publicly visible, e.g.:
:backfill_legacy_args
//cc/toolchains/args/soname_flags:feature
Mitigation
I see a few ways to fix this:
- Gate
static_libgcc behind an explicit use_libgcc flag.
- Make all targets under
experimental_replace_legacy_action_config_features public so that opting out for a given toolchain is feasible.
- Make
static_libgcc opt-in for rules-based toolchains.
cc @trybka @armandomontanez
When a rules-based toolchain enables
static_link_cpp_runtimes(required to usestatic_runtime_lib/dynamic_runtime_lib), rules_cc currently also enablesstatic_libgccsuch that-static-libgccis added to all link actions.This is problematic for toolchains that:
compiler-rt+libunwind(i.e., not GCC’s libgcc for runtime/unwinding), orCurrent escape hatch
--features=-static_libgccworks, but is not ideal for a public/toolchain-default experience.The alternative option is to redefine/duplicate the entire
experimental_replace_legacy_action_config_featuresfeature set just to drop//cc/toolchains/args/static_libgcc:feature.That duplication is especially painful because some targets aren’t publicly visible, e.g.:
:backfill_legacy_args//cc/toolchains/args/soname_flags:featureMitigation
I see a few ways to fix this:
static_libgccbehind an explicituse_libgccflag.experimental_replace_legacy_action_config_featurespublic so that opting out for a given toolchain is feasible.static_libgccopt-in for rules-based toolchains.