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-1738] Allow *only* static libraries to be built #3027

Merged
merged 1 commit into from Jun 24, 2016

Conversation

modocache
Copy link
Collaborator

@modocache modocache commented Jun 15, 2016

What's in this pull request?

This splits the --build-swift-stdlib and --build-swift-sdk-overlay arguments into dynamic and static variants, which makes the following build command possible:

utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0

This command produces only static libraries for the stdlib, and no SDK overlay libraries at all. Many other finely-grained build options are now possible.

@gribozavr This pull request is built on top of #3020 and #3043; it'll be easier to review and merge those first. Thanks for all your feedback on this! 🙇

Resolved bug number: (SR-1738)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@modocache modocache changed the title Sr 1738 build only static [SR-1738] Allow *only* static library to be built Jun 15, 2016
@modocache
Copy link
Collaborator Author

@swift-ci please test

@modocache modocache force-pushed the sr-1738-build-only-static branch 2 times, most recently from b7e07fb to b3997cb Compare June 16, 2016 19:09
@modocache
Copy link
Collaborator Author

@swift-ci please test

@modocache modocache changed the title [SR-1738] Allow *only* static library to be built [SR-1738] Allow *only* static libraries to be built Jun 16, 2016
@modocache
Copy link
Collaborator Author

@gribozavr This was a sort of work-in-progress, but I've updated it to something I think is good to go. It's based on the work from #3020 and #3043, so it'd be easier to review/merge those before looking at this. Let me know what you think -- thanks!

@gribozavr
Copy link
Collaborator

gribozavr commented Jun 18, 2016

Thank you! Would you mind rebasing and fixing the conflicts?

@modocache
Copy link
Collaborator Author

Thanks @gribozavr. It's weird, though, this rebased cleanly onto master. I wonder if GitHub determines conflicts differently somehow... oh well!

@swift-ci please test

build-swift-stdlib "1" "set to 1 to build the Swift standard library"
build-swift-stdlib-unittest-extra "0" "set to 1 to build optional StdlibUnittest components"
build-swift-sdk-overlay "1" "set to 1 to build the Swift SDK overlay"
build-swift-dynamic-stdlib "1" "set to 1 to build dynamic variants of the Swift standard library"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we keep build-swift-stdlib and build-swift-sdk-overlay as aliases for --build-swift-static-xyz=1 --build-swift-dynamic-xyz=1? We are using these in build presets, would be best to not break them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gribozavr Done! I also updated the documentation in build-script-impl and the source code comments in CMakeLists.txt.

@modocache modocache force-pushed the sr-1738-build-only-static branch 2 times, most recently from 31cf9a8 to 144c270 Compare June 20, 2016 14:07
@modocache
Copy link
Collaborator Author

@swift-ci please test

@modocache
Copy link
Collaborator Author

Looks like the OS X build has stalled for the past 7 hours. Kicking it.

@swift-ci please test

@modocache
Copy link
Collaborator Author

@gribozavr OK! I think this is good to go.

@@ -810,6 +813,14 @@ if [[ "${CROSS_COMPILE_HOSTS}" ]]; then
SKIP_COMPILER_RT=1
fi

if [[ "${BUILD_SWIFT_STDLIB}" ]]; then
BUILD_SWIFT_DYNAMIC_STDLIB=1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it turn off the static one as well?

Also, would you mind moving the alias processing into Python? (Possibly in a future change.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add support for build-swift-sdk-overlay=0? Some of our internal presets use it.

@gribozavr
Copy link
Collaborator

Thank you! I'm running a few tests and I'll merge soon!

@gribozavr
Copy link
Collaborator

@modocache Sorry, compatibility with build-swift-sdk-overlay=0 is a blocker for us. Would you mind taking a look?

@modocache
Copy link
Collaborator Author

@gribozavr OK, I've addressed your comments on both moving the logic into Python and on build-swift-sdk-overlay 👍

@modocache
Copy link
Collaborator Author

@swift-ci please test

@modocache
Copy link
Collaborator Author

@gribozavr Is there a way to test the compatibility concerns you mentioned? @swift-ci consistently passes for me. Could you confirm whether this passes, and whether it can be merged? Sorry for all the pings 😅

@gribozavr
Copy link
Collaborator

Sorry, I was reviewing other patches. I'm running a test locally now.

@gribozavr
Copy link
Collaborator

@modocache Sorry, this change does not yet fix the issue. The command that we care about is:

./utils/build-script -R --build-swift-sdk-overlay=0

It should not build the overlay at all.

# options.
if args.build_swift_stdlib:
args.build_swift_dynamic_stdlib = True
args.build_swift_static_stdlib = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add an else clause that sets both to False?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wouldn't that overwrite whatever was passed to --build-swift-dynamic-stdlib and --build-swift-static-stdlib? For example, consider the following invocation:

utils/build-script --build-swift-static-stdlib=1

Since --build-swift-stdlib is not passed in, the else statement would be executed, which would set --build-swift-static-stdlib=0, thus negating the desired invocation. Or am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You're right. We probably want it to be a tristate then. If --build-swift-stdlib is not passed on the command line, do nothing, if it is passed, then it should override other args.

Once this PR is merged, I'll try to remove the uses of legacy parameters internally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a good way to determine whether --build-swift-stdlib is specified on the command line? Right now it seems like the following are indistinguishable:

$ utils/build-script
$ utils/build-script --build-swift-stdlib=0

Is there a good way to distinguish these two using the existing swift_build_support code? Or should I make some modifications there, or just inspect argv?

Thanks for all your help!

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a way, but we'd need to stop using the optional_bool action. Since this is a short-lived compatibility aid, I think inspecting argv is acceptable.

Copy link
Member

@rintaro rintaro Jun 24, 2016

Choose a reason for hiding this comment

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

I think action=optional_bool, default=None will have 3 possible state.
(is None, True, False).
Not confirmed though.
Confirmed, works as expected:

    parser.add_argument(
        "--my-opt", action=arguments.action.optional_bool, default=None)

    args = parse_args( ... )

    if args.my_opt is None:
        print("DEFAULT")
    elif args.my_opt:
        print("YES")
    else:
        print("NO")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perfect, this is just what I need. Thanks, @rintaro!! I'll make the changes first thing tomorrow.

This splits the `--build-swift-stdlib` and `--build-swift-sdk-overlay`
arguments into `dynamic` and `static` variants, which makes the
following build command possible:

```
utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0
```

This command produces *only* static libraries for the stdlib, and no
SDK overlay libraries at all. Many other finely-grained build options
are now possible.
@modocache
Copy link
Collaborator Author

@gribozavr OK, I addressed your comments, thanks to @rintaro's suggestion. Please have another look! I'd love to merge this before the weekend. 😎 ☀️

@swift-ci please test

@gribozavr
Copy link
Collaborator

@modocache Thank you, my tests pass now! Please merge when the CI succeeds!

@modocache modocache merged commit 48e04b4 into apple:master Jun 24, 2016
@modocache modocache deleted the sr-1738-build-only-static branch June 24, 2016 18:55
@modocache
Copy link
Collaborator Author

Thanks a ton, @gribozavr! 🙇

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.

None yet

3 participants