Validate extra link-time callbacks with Starlark Args #827
Do you know if this function was previously under-tested or if there's a set of tests in bazelbuild/bazel that should be migrated over into rules_cc?
This needs a comment describing what it does; I acknowledge its benefit but it's hacky.
The args.add_all documentation says map_each must be a top-level def "To avoid unintended retention of large analysis-phase data structures into the execution phase".
If we choose to abuse args.add_all to type check, I feel like we should document that we have a different intent (though we also want to save memory of course).
Requested changes.
Bazel's public C++ test only checked private API access; I couldn’t find callback tests to migrate. Bazel does have a generic Args test for nested functions and lambdas. This PR now tests nested callback rejection, rejection of built-ins and None, and that a shared top-level callback receives the merged inputs.
OK, addressed review feedback. I still think (as I'm sure you do) that this is kinda hacky, up to yall if you think its worth the benefit of removing these Java APIs
Approved these changes.
I favor getting c-specific things out of bazel; if the second reviewer thinks it's too hacky I'll push for making this a non-c bazel builtin
lilygorsheneva
dzbarsky
Validate extra link-time library callbacks with
ctx.actions.args().add_all([], map_each = callback)immediately before invocation.Args.add_allperforms the same top-level-function check as_cc_internal.check_toplevel, so the C++ Java helper is no longer needed.Validation: 88 C++ common and binary analysis tests passed, including new tests for top-level and nested callbacks.