-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starlarkify objc/CompilationAttributes.java #24009
Starlarkify objc/CompilationAttributes.java #24009
Conversation
src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl
Outdated
Show resolved
Hide resolved
sdk_frameworks = depset(sdk_frameworks), | ||
weak_sdk_frameworks = depset(weak_sdk_frameworks), | ||
sdk_dylibs = depset(getattr(ctx.attr, "sdk_dylibs", [])), | ||
linkopts = objc_internal.expand_and_tokenize(ctx = ctx, attr = "linkopts", flags = getattr(ctx.attr, "linkopts", [])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and data weren't covered by tests for expansions, hoping internal google CI helps validate some of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a close look what the internal Google tests can check here.
There's one more thing I noticed: in ObjcStarlarkInternal.createCompilationAttributes() the call to CompilationAttributes.Builder.addCompileOptionsFromRuleContext() (which sets linkopts, copts, additional_linker_inputs and defines) is only called if the rule has copts.
After digging a bit into the history of this, I currently think that this was not an intended coupling of conditions; the straightforward linear copying that you implemented makes more sense to me.
We can discuss tweaks if any problems surface from this.
"ERROR /workspace/examples/apple_starlark/BUILD:1:13: " | ||
+ "in objc_library rule //examples/apple_starlark:lib:"); | ||
|
||
assertContainsEvent("sdk_frameworks attribute is disallowed. Use explicit dependencies instead."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor error text change with fail vs Java. Same behavior and I tried to nearly match it
objc_compilation_context_kwargs["public_hdrs"].extend(compilation_attributes.hdrs.to_list()) | ||
objc_compilation_context_kwargs["public_hdrs"].extend( | ||
[artifact for artifact, _ in compilation_attributes.hdrs.to_list()], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what you are doing here is the corresponding operation to what's happening in CompilationAttributes.Builder.addHeadersFromRuleContext(), right? The picking of the key from the artifact/label pairs returned by CcCommon.getHeaders()?
Unless I'm mistaken, that effectively moves this further down in the chain, changing the content of compilation_attributes.hdrs from artifacts to artifact/label pairs. And since compilation_attributes in compilation_support.bzl is not just passed to objc_common.create_context_and_provider(), but also returned, both by build_common_variables() and register_compile_and_archive_actions_for_j2objc(), so the change doesn't look contained within compilation_support.bzl.
Wouldn't it be better to make the conversion from artifact/label pairs to artifact right when hdrs is initialized in _create_compilation_attributes()? Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrm yea good point, pushed that. I assume long term once we can drop this objc specific stuff we'll want the pairs version, but I think you're right it's nicer to not mess with now
c476d9d
to
4154b02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll handle the PR import myself.
sdk_frameworks = depset(sdk_frameworks), | ||
weak_sdk_frameworks = depset(weak_sdk_frameworks), | ||
sdk_dylibs = depset(getattr(ctx.attr, "sdk_dylibs", [])), | ||
linkopts = objc_internal.expand_and_tokenize(ctx = ctx, attr = "linkopts", flags = getattr(ctx.attr, "linkopts", [])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a close look what the internal Google tests can check here.
There's one more thing I noticed: in ObjcStarlarkInternal.createCompilationAttributes() the call to CompilationAttributes.Builder.addCompileOptionsFromRuleContext() (which sets linkopts, copts, additional_linker_inputs and defines) is only called if the rule has copts.
After digging a bit into the history of this, I currently think that this was not an intended coupling of conditions; the straightforward linear copying that you implemented makes more sense to me.
We can discuss tweaks if any problems surface from this.
*** Reason for rollback *** Internal breakages *** Original change description *** Starlarkify objc/CompilationAttributes.java Closes #24009. PiperOrigin-RevId: 692916945 Change-Id: Idce0820a9e97e049a0568eb031594979de2b8b57
We had to roll this back as it did break one internal test after all. Will investigate. |
The breaking test was
The immediate cause of the failure was the change in behaviour I mentioned in #24009 (comment), that in the native code linkopts, copts, additional_linker_inputs and defines are only set if the rule has copts whereas in the initial Starlark code they were all set independently of each other. I still believe that to be the right behaviour, but reproducing the native behaviour in Starlark does fix the test so that's what I'll do for now. I'll investigate this further. |
In the end, the fix to the broken test was not to reproduce the old native code behaviour where setting of |
No description provided.