Skip to content

Pass imported swiftmodules to ld with -add_ast_path flag#567

Merged
swiple-rules-gardener merged 17 commits intobazelbuild:masterfrom
kastiglione:swift-add-ast-path
Nov 7, 2019
Merged

Pass imported swiftmodules to ld with -add_ast_path flag#567
swiple-rules-gardener merged 17 commits intobazelbuild:masterfrom
kastiglione:swift-add-ast-path

Conversation

@kastiglione
Copy link
Copy Markdown
Contributor

When using imported swift frameworks, and when building dbg, pass the .swiftmodule files to the linker using the -add_ast_path. This enables lldb expression evaluation using such modules.

@kastiglione
Copy link
Copy Markdown
Contributor Author

This currently depends on #566. View 222c7fb for the specific changes.

@kastiglione
Copy link
Copy Markdown
Contributor Author

I assume support needs to be added for apple_dynamic_framework_import too. I will add dynamic support and tests if this looks right.

@kastiglione kastiglione changed the title Swift add ast path Pass imported swiftmodules to ld with -add_ast_path flag Aug 27, 2019
Comment thread apple/internal/apple_framework_import.bzl Outdated
Comment thread apple/internal/apple_framework_import.bzl Outdated
Comment thread apple/internal/apple_framework_import.bzl Outdated
Comment thread apple/internal/apple_framework_import.bzl Outdated
@kastiglione
Copy link
Copy Markdown
Contributor Author

I've rebased and modified on top of #566.

@kastiglione
Copy link
Copy Markdown
Contributor Author

kastiglione commented Sep 6, 2019

  • Decide how to handle dbg/fastbuild logic duplicated here and in rules_swift
  • Same, but for -add_ast_path
  • Is handling only the "legacy" naming convention ok?
  • Update tests to confirm the -add_ast_path was applied to the binary

Comment thread apple/internal/apple_framework_import.bzl Outdated
@kastiglione
Copy link
Copy Markdown
Contributor Author

kastiglione commented Sep 9, 2019

I changed approach slightly. Instead of implementing this logic all inline, I duplicated the interfaces from rules_swift that we'd like to ultimately reuse, and customized them for this case. This makes the callsite cleaner, and makes future migration – should those APIs become public, easier. It also calls out explicitly that this behavior is duplicated, as a reminder that hopefully one day we can reuse this behavior from rules_swift.

@sergiocampama
Copy link
Copy Markdown
Contributor

I'm ok with supporting only the legacy behavior for now. If adding a test is not too complex, could you add one?

@kastiglione
Copy link
Copy Markdown
Contributor Author

Yep, was intending to add tests. Will do that now.

Comment thread test/ios_framework_import_test.sh Outdated
@kastiglione
Copy link
Copy Markdown
Contributor Author

@sergiocampama I'm considering making a patch for this locally, but I wanted to check if you had any additional feedback.

Comment thread apple/internal/apple_framework_import.bzl Outdated
Comment thread apple/internal/apple_framework_import.bzl Outdated
Comment thread test/ios_framework_import_test.sh Outdated
@sergiocampama
Copy link
Copy Markdown
Contributor

also, could you rebase as well? there are some changes that fix the buildifier check

@kastiglione
Copy link
Copy Markdown
Contributor Author

Thanks for the review.

Comment thread test/ios_framework_import_test.sh
Comment thread test/ios_framework_import_test.sh Outdated
Comment thread test/ios_framework_import_test.sh Outdated
Comment thread test/ios_framework_import_test.sh Outdated
Comment thread test/ios_framework_import_test.sh
@kastiglione
Copy link
Copy Markdown
Contributor Author

Fixed

@kastiglione
Copy link
Copy Markdown
Contributor Author

Do you want me to rebase again?

@kastiglione
Copy link
Copy Markdown
Contributor Author

Rebased.

@allevato
Copy link
Copy Markdown
Member

allevato commented Nov 1, 2019

Also re-ran test/testdata/frameworks/update_frameworks.sh to generate a 5.1 swiftmodule in the test fixtures.

Having a prebuilt .swiftmodule file in there isn't going to work; it version-locks the test to a specific version of Xcode, and makes it impossible for Buildkite to update Xcode without breaking the test. It also means we can't have Buildkite and Google's internal CI running different versions of Xcode, which is a non-starter.

(And this is why I'm nervous about this whole feature to begin with.)

I don't have a great answer for this. Since you actually need it to be a valid module (because you're building code that depends on it), you can't just have it be a dummy file. @thomasvl, do you have any ideas?

@kastiglione
Copy link
Copy Markdown
Contributor Author

For what it's worth, master already is in this state.

I could look to generate these fixtures pre- test.

@allevato
Copy link
Copy Markdown
Member

allevato commented Nov 1, 2019

Ah, so it is... from the diff on the files changed page I couldn't tell if it was being added or just 100% changed.

I wonder if you could do this as two phases in the test. First, have a swift_library fixture that you build and that creates a module, then you copy that module into the test's workspace and write out a scratch framework import target in a BUILD file in the same test area, pointing to that module? If that works, that would guarantee they're always the same compiler.

@kastiglione
Copy link
Copy Markdown
Contributor Author

Sounds good

@kastiglione
Copy link
Copy Markdown
Contributor Author

kastiglione commented Nov 6, 2019

iOSSwiftStaticFramework.framework is now dynamically generated from the test. This removes the precompiled .swiftmodule. See 469a65e

Also rebased.

Comment thread test/ios_framework_import_test.sh Outdated
Copy link
Copy Markdown
Member

@allevato allevato left a comment

Choose a reason for hiding this comment

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

I think we're good to go now!

@kastiglione
Copy link
Copy Markdown
Contributor Author

Thanks for helping us get this shaped up :)

swiple-rules-gardener added a commit that referenced this pull request Nov 7, 2019
@swiple-rules-gardener swiple-rules-gardener merged commit 2082472 into bazelbuild:master Nov 7, 2019
@kastiglione kastiglione deleted the swift-add-ast-path branch November 7, 2019 18:22
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.

7 participants