Skip to content
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

Remove unnecessary macOS crosstool configuration #13448

Conversation

keith
Copy link
Member

@keith keith commented May 8, 2021

This cleans up some unnecessary duplication / branching the macOS crosstool

These actions only differed on features that no-op in the same
conditions so we don't need to duplicate these.
@google-cla google-cla bot added the cla: yes label May 8, 2021
"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by having unfiltered_cxx_flags in 1 branch and not the other, this action exists for all archs, it's just a no-op for some, so we don't need to if on that in both places

flag_set(
flag_groups = [
flag_group(flags = ["-stdlib=libc++", "-std=gnu++11"]),
flag_group(flags = ["-arch", arch]),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed for different architectures by hardcoding them here, now that we have a variable for this we can remove that duplication

"version_min",
"apple_env",
"sysroot",
"cpp_linker_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by having cpp_linker_flags in 1 branch and not the other, this action exists for all archs, it's just a no-op for some, so we don't need to if on that in both places

"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by having unfiltered_cxx_flags in 1 branch and not the other, this action exists for all archs, it's just a no-op for some, so we don't need to if on that in both places

"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by having unfiltered_cxx_flags in 1 branch and not the other, this action exists for all archs, it's just a no-op for some, so we don't need to if on that in both places

@keith keith force-pushed the ks/remove-unnecessary-macos-crosstool-configuration branch from 754db4a to fa8958c Compare May 8, 2021 01:03
This had 3 cases, the normal one that just differed by arch, the 3 macOS
archs that just differed by arch, and 3 opt outs that don't pass
`-target` (although maybe they should)
@@ -3314,187 +2712,9 @@ def _impl(ctx):
requires = [feature_set(features = ["coverage"])],
)

if (ctx.attr.cpu == "ios_arm64"):
default_link_flags_feature = feature(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_link_flags has 3 cases, the macOS archs which just differed by arch, the normal case which just differed by arch, and the opt outs that don't pass -target which weren't changed here

This only differed by unfiltered_cxx_flags which exists for all
configurations, but no-ops for some, so we don't have to duplicate that
conditional
"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by unfiltered_cxx_flags which exists for all archs but just no-ops for some, so we don't have to duplicate that conditional

This only differed by unfiltered_cxx_flags which exists for all
configurations, but no-ops for some, so we don't have to duplicate that
conditional
"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed by unfiltered_cxx_flags which exists for all archs but just no-ops for some, so we don't have to duplicate that conditional

],
)

objcpp_compile_action = action_config(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed on arch, the apply_simulator_compiler_flags feature, which exists for all archs, just no-ops for some, so that's fine, and some actions used wrapped_clang instead of wrapped_clang_pp which seems to have been an unintentional difference

"-filelist",
"%{obj_list_path}",
"-arch_only",
target_system_name,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action only differed on arch

),
flag_set(
flag_groups = [
flag_group(flags = ["-arch", target_system_name]),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this action only differed on arch

"version_min",
"apple_env",
"sysroot",
"cpp_linker_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this action only differed on cpp_linker_flags which exists for all archs but no-ops for some

"version_min",
"apple_env",
"sysroot",
"cpp_linker_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this action only differed on cpp_linker_flags which exists for all archs but no-ops for some

"unfiltered_compile_flags",
"compiler_input_flags",
"compiler_output_flags",
"unfiltered_cxx_flags",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this action only differed on unfiltered_cxx_flags which exists for all archs but no-ops for some

"-no_warning_for_no_symbols",
"-static",
"-arch_only",
target_system_name,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this action only differed on arch

"-D__DATE__=\"redacted\"",
"-D__TIMESTAMP__=\"redacted\"",
"-D__TIME__=\"redacted\"",
target_system_name,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feature only differed on arch, except for armeabi-v7a which excludes the -target arg

@keith keith force-pushed the ks/remove-unnecessary-macos-crosstool-configuration branch from 4f9753e to 63bb142 Compare May 8, 2021 01:48
@keith
Copy link
Member Author

keith commented May 8, 2021

this diff is obviously quite large, happy to break it up however we want, right now reviewing by commit should be easiest, and I commented on every feature I changed. I aimed for 0 behavior changes here

@keith keith marked this pull request as ready for review May 8, 2021 02:15
Copy link
Contributor

@trybka trybka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this to the best of my ability, and it seems reasonable.

Some notes for @keith :

Most of the remaining conditionals still seem unnecessarily verbose. In particular, can we remove armeabi-v7a? Also, the other pattern I see that could possibly be removed is like:
if (one condition) ... elif (other condition) ... else (default case which should probably never happen, i.e. CPU is not anything we recognize)

Maybe those could be collapsed a bit in a follow-up?
Certainly wouldn't block this on such a cleanup, though.

ACTION_NAMES.cpp_header_parsing,
ACTION_NAMES.objc_compile,
ACTION_NAMES.objcpp_compile,
"objc-executable",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these use ACTION_NAMES....executable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm yea, there are quite a few of these that should switch to constants, mind if I do that in a follow up just to not add to the functional diff here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

@keith
Copy link
Member Author

keith commented May 8, 2021

Thanks for reviewing! If you're ok with me doing those in a followup I'd definitely prefer that at this point, and those should be much less churn than this diff. I've been trying to remember why this armeabi-v7a thing exists again but I'm happy to remove it in a follow up if it's not needed anymore

@keith
Copy link
Member Author

keith commented May 8, 2021

Working on removing armeabi-v7a from this here #13449 but I would still prefer we land this first so I don't have to resolve conflicts between them, and in case I miss something there having to revert the whole thing would be tough

@trybka
Copy link
Contributor

trybka commented May 10, 2021

Follow-ups and conflict resolution all make sense to me. I'm happy to help land this as-is and then process the follow-up(s)

@keith
Copy link
Member Author

keith commented May 10, 2021

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants