-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Move regex literal parsing logic from SwiftCompilerSources to ASTGen #68401
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
Conversation
@swift-ci please smoke test |
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.
Seems like maybe we should move lib/ASTGen
to something like swiftlib
. Or maybe this all just becomes SwiftCompilerSources
once we've moved that across as well.
Also, woo!
//import AST | ||
//import Basic |
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.
Can remove now?
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.
Yes, I forgot that I'd only commented them out
let offset = str.utf8.distance(from: str.startIndex, to: errorLoc) | ||
diagLoc = _diagLoc.advanced(by: offset) | ||
diagLoc = BridgedSourceLoc(raw: _diagLoc.advanced(by: offset)) |
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.
SourceLoc_advanced(bridgedDiagnosticBaseLoc, SwiftInt(offset))
(there's other places that assume raw
is the address, but it would be good if we didn't add more)
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.
Ah, good point
@swift-ci please clean smoke test Linux |
@swift-ci please clean smoke test macOS |
118e8ef
to
7159e72
Compare
@swift-ci please smoke test |
I don't know if we want a |
That's fine too, |
Thanks for doing this: I just applied this pull to the Sep. 2 trunk source snapshot and was able to build a Swift compiler natively on Android that supports regex literals again and Macros for the first time. Any plans to backport this patch to 5.9? |
Fantastic! Yes, I'm going to address review comments and back port this patch to 5.9. |
@swift-ci please smoke test |
I went ahead and backported this pull to 5.9, slapped it up as a gist so you don't have to repeat that work. Haven't tried compiling it with the 5.9 branch yet, will do that next. |
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.
Nice!
initializeSwiftParseModules(); | ||
initializeSwiftModules(); |
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.
Would it be worth renaming initializeSwiftModules
to something like initializeSwiftSILModules
on the Swift side, and then defining initializeSwiftModules
on the C side to call both that and initializeSwiftParseModules
?
@swift-ci please test |
@finagolfin we've got Windows CI updated and macros support landed there (#68334), so now it's time to get this tested and merged |
@swift-ci please build toolchain Windows |
@DougGregor, sounds good, I'm currently cross-compiling my 5.9 version of this pull for Android. It appears that portions of #66044 will also need to be backported to 5.9, or the 5.9 version of this pull will have to be adapted for that bridging pull not being in 5.9. |
Linux CI failed when testing lldb:
|
@swift-ci please test Linux |
@swift-ci please test |
1 similar comment
@swift-ci please test |
This will need to be updated for #68408. |
ASTGen always builds with the host Swift compiler, without requiring bootstrapping, and is enabled in more places. Move the regex literal parsing logic there so it is enabled in more host environments, and makes use of CMake's Swift support. Enable all of the regex literal tests when ASTGen is built, to ensure everything is working. Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources, because they are no longer needed.
5f3625d
to
3a3e467
Compare
Dusting this off now and resolving the conflicts. |
@swift-ci please test |
@swift-ci please test |
lib/Parse/Lexer.cpp
Outdated
@@ -35,11 +35,9 @@ | |||
// Regex lexing delivered via libSwift. | |||
static RegexLiteralLexingFn regexLiteralLexingFn = nullptr; | |||
|
|||
#if SWIFT_SWIFT_PARSER |
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.
It's not, it's just called SWIFT_BUILD_SWIFT_SYNTAX
now. Was changed in the FetchContent PR. Do I regret that? Maybe a little.
We could totally get rid of it now, but I wouldn't for this PR personally.
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.
ARGH. Force-pushed now that I realized this, about the same time you told me :)
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.
Heh, sorry for not noticing it in here in the first place!
4c4a16c
to
773f511
Compare
@swift-ci please test |
@swift-ci please smoke test macOS |
The macOS test never actually got started properly. Trying again... |
@swift-ci please test macOS |
Please test with following PRs: @swift-ci please build toolchain Windows platform |
Please test with following PRs: @swift-ci please build toolchain Windows platform |
@swift-ci please test |
I have backported this pull to Swift 5.9 and am happy to report a working Swift 5.9 package with regex literals again on Android in the Termux app. I also backported #66033 and #66044 there, as this pull relies on those changes that aren't in the 5.9 branch. I've also backported #68408 and swiftlang/swift-syntax#2173 and applied some changes so Swift Syntax can be cross-compiled (which I'll upstream next), so that Macros work natively on Android. |
This was already done |
ASTGen always builds with the host Swift compiler, without requiring bootstrapping, and is enabled in more places. Move the regex literal parsing logic there so it is enabled in more host environments, and makes use of CMake's Swift support. Enable all of the regex literal tests when ASTGen is built, to ensure everything is working.
Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources, because they are no longer needed.