Skip to content

[stdlib][Part 1] De-gyb almost everything #21149

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

Merged
merged 8 commits into from
Dec 10, 2019

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Dec 8, 2018

See here: https://forums.swift.org/t/struggling-to-find-things-in-the-new-stdlib-for-5-0-e-g-where-is-addingreportingoverflow-implemented/18612/7

This is part 1 in a 4 part series.

This removes most .gyb files from the stdlib. Commits titled de-gyb ... are the product of copying and pasting the de-gybbed version over. I have a post de-gyb formatting commit that cleans up some of the messy formatting from gyb.

cc: @airspeedswift @stephentyrone @lorentey @xwu

@stephentyrone
Copy link
Contributor

@airspeedswift and I just talked about this briefly. We'd like to do this, but want to be a bit more gradual about it. In particular, Ben wants to keep the .gyb files around (because they're better for editing--at least once you're used to them), but add a test that validates that the result of expanding the gyb matches the non-gyb source.

In cases where there isn't too much duplication, removing gyb entirely makes sense, but we should do those one file-per-commit, I think.

@Azoy
Copy link
Contributor Author

Azoy commented Dec 10, 2018

Understandable. I read "all in" from Ben and I was ready to go "all in" 😅 I imagine we might one day get around to de-gybbing IntegerTypes which might allow us to break up the integers into separate files, Int8.swift, Int16.swift, etc. How would we go about testing this split in files with IntegerTypes.swift.gyb? (Assuming we want to do something like that instead of just testing against a IntegerTypes.swift with everything in it)

@stephentyrone
Copy link
Contributor

stephentyrone commented Dec 10, 2018

@Azoy let's leave IntegerTypes and FloatingPointTypes alone for the time being, since they're a bit more involved than the others (but: we would simply run the test multiple times with different arguments to validate).

I think the other thing worth doing here is to more clearly document how to generate the .swift files from the .swift.gyb (probably via a comment line at the top the .gyb file that has exactly the required invocation(s)).

@airspeedswift
Copy link
Member

which might allow us to break up the integers into separate files, Int8.swift, Int16.swift

I'd rather leave them all in one big file than clutter the folder with lots of near-identical files. The goal of degybbing is to improve search ability of the source code (the "where on earth is xxx declared" question on the forum that led to this idea), to allow stepping through the std lib, allow an LSP server to parse the whole std lib etc, all of which works from the single file approach. These files are probably rarely going to be touched in future so making them easier to navigate/read for editing purposes isn't that important.

@Azoy
Copy link
Contributor Author

Azoy commented Dec 10, 2018

I only bring up splitting them up because the gyb file itself is almost 2k LoC, and a single ungybbed IntegerTypes.swift would be about 20k LoC. Some editors/IDEs/github even would have some trouble handling a buffer that large which might decrease ability to efficiently search for source code.

@stephentyrone
Copy link
Contributor

stephentyrone commented Dec 11, 2018

@Azoy @airspeedswift Also worth noting that as the generics story and compiler optimizations get better, we can move progressively more and more integer stuff out of gyb and into default implementations, so the gyb piece will gradually get smaller.

It should eventually be pretty much just the wrappers around Builtins, which should ~never need to be edited or debugged unless something is catastrophically wrong.

@airspeedswift
Copy link
Member

We talked about this some more and I am won over to the idea of breaking up the files (though re the 20k, I am guessing that's mostly docs and maybe some day we'll have doc-deduplication built into the swift doc capabilities). But it'd be good if we can do it by putting them all in an IntegerTypes folder.

@Azoy
Copy link
Contributor Author

Azoy commented Dec 14, 2018

While looking for gyb comments in ExistentialCollection.swift, I made some more minor formatting changes which might need a quick review.

@CodaFi
Copy link
Contributor

CodaFi commented Nov 18, 2019

@Azoy Could you rebase this one more time?

@Azoy Azoy force-pushed the de-gyb-stdlib-part-1 branch from 2d52286 to 861e0f7 Compare November 20, 2019 15:52
@Azoy
Copy link
Contributor Author

Azoy commented Nov 20, 2019

@CodaFi I've successfully rebased a years worth of commits! @airspeedswift @stephentyrone I know it's been a WHILE, but I would love another look to make sure this is good to go!

@CodaFi
Copy link
Contributor

CodaFi commented Nov 21, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 861e0f79a63884bce7b5e4f96eb81153cfdeec34

@Azoy Azoy force-pushed the de-gyb-stdlib-part-1 branch from 861e0f7 to c996619 Compare November 21, 2019 03:54
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 861e0f79a63884bce7b5e4f96eb81153cfdeec34

@Azoy
Copy link
Contributor Author

Azoy commented Nov 21, 2019

@CodaFi sigh sorry bout that one... it should be good now.

@CodaFi
Copy link
Contributor

CodaFi commented Nov 21, 2019

It happens. Let’s give it another go.

@CodaFi
Copy link
Contributor

CodaFi commented Nov 21, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c9966192a45f01871072e2576571f754fef27a2d

@CodaFi
Copy link
Contributor

CodaFi commented Nov 21, 2019

Ignore the macOS result. There’s an infrastructure problem here.

@Azoy Azoy force-pushed the de-gyb-stdlib-part-1 branch from c996619 to 0a1c30e Compare November 30, 2019 02:19
@Azoy
Copy link
Contributor Author

Azoy commented Dec 3, 2019

@CodaFi I've rebased and now this should be ready.

@CodaFi
Copy link
Contributor

CodaFi commented Dec 3, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Dec 3, 2019

Build failed
Swift Test OS X Platform
Git Sha - 0a1c30e9655d9d67738f4e65c0a0835831b8e174

@Azoy
Copy link
Contributor Author

Azoy commented Dec 3, 2019

macOS failure unrelated?

@CodaFi
Copy link
Contributor

CodaFi commented Dec 3, 2019

Ugh, infrastructure failure. Let's try again

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Dec 4, 2019

Build failed
Swift Test OS X Platform
Git Sha - 0a1c30e9655d9d67738f4e65c0a0835831b8e174

@Azoy
Copy link
Contributor Author

Azoy commented Dec 6, 2019

Another infrastructure problem again? x)

@CodaFi
Copy link
Contributor

CodaFi commented Dec 6, 2019

I think this one’s an actual failure

api-digester/dump-module.swift

Suggests you might have changed the ABI surface of stdlib.

@benrimmington
Copy link
Contributor

The conformances of Int (to MirrorPath, CVarArg, and CustomReflectable) in the cake test module have been reordered, possibly due to your CMakeLists.txt changes.

There's a comment in dump-module.swift which might be relevant:

// The input JSON files need to be modified when standard library declarations
// are reordered. This is expected behavior and we simply shouldn't run the test
// when automatically evolving the standard library.

@@ -61,6 +63,7 @@ set(SWIFTLIB_ESSENTIAL
EmptyCollection.swift
Equatable.swift
ErrorType.swift
ExistentialCollection.swift
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't fix the test failure, but you could move ExistentialCollection.swift to the SWIFTLIB_SOURCES list (at line 210) if it isn't an "essential" source; and also change the copyright year of CMakeLists.txt (from 2018 to 2019).

@Azoy Azoy force-pushed the de-gyb-stdlib-part-1 branch from 0a1c30e to e3a4401 Compare December 7, 2019 19:53
@Azoy
Copy link
Contributor Author

Azoy commented Dec 7, 2019

@benrimmington thanks so much for the help.
@CodaFi I've tested locally and this test passes now. We should be good to go.

@theblixguy
Copy link
Collaborator

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Dec 7, 2019

Build failed
Swift Test OS X Platform
Git Sha - 0a1c30e9655d9d67738f4e65c0a0835831b8e174

@swift-ci
Copy link
Contributor

swift-ci commented Dec 7, 2019

Build failed
Swift Test Linux Platform
Git Sha - 0a1c30e9655d9d67738f4e65c0a0835831b8e174

@Azoy
Copy link
Contributor Author

Azoy commented Dec 9, 2019

@CodaFi all tests have passed!

@CodaFi
Copy link
Contributor

CodaFi commented Dec 10, 2019

⛵️

@CodaFi CodaFi merged commit 113baa6 into swiftlang:master Dec 10, 2019
@Azoy Azoy deleted the de-gyb-stdlib-part-1 branch February 12, 2021 08:04
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.

8 participants