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

[SR-2660][Driver] Handle .swiftmodule inputs #12507

Merged

Conversation

modocache
Copy link
Contributor

@modocache modocache commented Oct 19, 2017

Allow users to pass .swiftmodule files into the Swift driver when compiling without -g. The .swiftmodule files are then passed to the linker via -add_ast_path so that LLDB can access their AST information.

This addresses one of two driver changes suggested in the comments of https://bugs.swift.org/browse/SR-2660. The second is to detangle the -g option with the driver logic that determines whether to run a merge module job or not.

In addition to the unit tests, to make sure the debug info was being read properly by lldb, I also ran bash build-driver.sh on an updated version of the sample project attached to the original bug report, which I've uploaded here: https://github.com/modocache/SR-2660. I tested that on macOS.

@modocache modocache force-pushed the sr-2660-driver-swiftmodule-linker-inputs branch from 6337088 to 1833159 Compare October 19, 2017 09:48
@modocache
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Thanks, Brian! Some small comments, but overall this makes sense.

} else {
// Otherwise, pass .swiftmodule files as inputs to the linker,
// so that their debug info is available.
AllLinkerInputs.push_back(Current);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably check that we're planning to do a link action at all (OI.shouldLink()) and continue diagnosing otherwise.

addInputsOfType(Arguments, context.InputActions, types::TY_SwiftModuleFile);

// For each .swiftmodule file added to the linker input arguments, prepend
// an -add_ast_path option.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit too clever. What do you think about adding an extra const char * argument to addInputsOfType that is inserted before each input if present?

@@ -265,6 +268,11 @@
// DEBUG: linker
// DEBUG: -o linker.dSYM

// LINK-SWIFTMODULES: bin/swift
// LINK-SWIFTMODULES-NEXT: bin/ld{{"? }}
// LINK-SWIFTMODULES: -add_ast_path {{.*}}/a.swiftmodule
Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of this test doesn't do this yet, but FileCheck now has a -SAME suffix that guarantees that the check lines are on the same line as the previous match. Please use that here!

@modocache modocache force-pushed the sr-2660-driver-swiftmodule-linker-inputs branch 2 times, most recently from 0a6e6df to ca6cfbd Compare October 19, 2017 17:28
@modocache
Copy link
Contributor Author

modocache commented Oct 19, 2017

Thanks for the review, @jrose-apple! I addressed your comments and (hopefully) fixed the issues that popped up on Linux CI.

@modocache modocache force-pushed the sr-2660-driver-swiftmodule-linker-inputs branch from ca6cfbd to 6c6a0a0 Compare October 19, 2017 17:34
@modocache
Copy link
Contributor Author

@swift-ci please smoke test

// LINK-SWIFTMODULES-macho: 1: link, {0}, image

// LINK-SWIFTMODULES-elf: 0: input, "{{.*}}.swiftmodule", swiftmodule
// LINK-SWIFTMODULES-elf: 1: swift-autolink-extract, {0}, autolink
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this is a great test because the behavior is wrong. :-) swift-autolink-extract should not be run on swiftmodules; the trouble is that I'm not sure whether it should only run on object files or also on, say, .a files. Let's say just object files for now.

Allow users to pass `.swiftmodule` files into the Swift driver when
compiling without `-g`. The `.swiftmodule` files are then passed to the
linker via `-add_ast_path` so that LLDB can access their AST
information.

This addresses one of two driver changes suggested in the comments of
https://bugs.swift.org/browse/SR-2660.
@modocache modocache force-pushed the sr-2660-driver-swiftmodule-linker-inputs branch from 6c6a0a0 to b81ad22 Compare October 19, 2017 22:03
@modocache
Copy link
Contributor Author

modocache commented Oct 19, 2017

OK, I think I took care of it, please have another look, @jrose-apple!

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Yep, looks good! Thanks, Brian.

@modocache modocache merged commit d3ebc28 into swiftlang:master Oct 19, 2017
@modocache modocache deleted the sr-2660-driver-swiftmodule-linker-inputs branch October 19, 2017 23:16
@modocache
Copy link
Contributor Author

Hooray! I'll try to disentangle -g in another pull request soon.

modocache added a commit to modocache/swift that referenced this pull request Oct 20, 2017
This fixes an intermittent failure introduced by
swiftlang#12507.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants