Skip to content

[build-script] Add support for using isolated -impl actions. #2988

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 1 commit into from
Jun 23, 2016

Conversation

ddunbar
Copy link
Contributor

@ddunbar ddunbar commented Jun 10, 2016

What's in this pull request?

This adopts the feature in #2880 in build-script, and is part of SR-237.


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.

  • This change moves the top-level invocation driver loop into build-script
    and uses the -impl script to perform each individual action. Once landed
    and enabled, this will enable us to migrate the individual pieces of the
    -impl script into Python code in an incremental fashion.
  • This also introduces stub product definitions for each of the different projects
    we manage.
  • This works, but is disabled by default (--no-legacy-impl) because it
    severely impacts the performance of null builds (4x slower, currently) due to
    the build-script-impl parsing overhead. If only we had a JITing bash
    implementation...

@ddunbar ddunbar force-pushed the build-script-isolated-actions branch from 1fda5b2 to ea99469 Compare June 10, 2016 22:47
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 10, 2016

@swift-ci please python lint

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 10, 2016

@swift-ci please smoke test

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 11, 2016

/cc @gribozavr @rintaro @karwa

call_without_sleeping(
[build_script_impl] + impl_args + [
"--only-execute", action_name],
env=impl_env, echo=self.args.verbose_build)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this mode drops echoing subcommands by default, it is too verbose until we finish killing the -impl script.

 - This change moves the top-level invocation driver loop into `build-script`
   and uses the `-impl` script to perform each individual action. Once landed
   and enabled, this will enable us to migrate the individual pieces of the
   `-impl` script into Python code in an incremental fashion.

 - This also introduces stub product definitions for each of the different projects
   we manage.

 - This works, but is disabled by default (`--no-legacy-impl`) because it
   severely impacts the performance of null builds (4x slower, currently) due to
   the `build-script-impl` parsing overhead. If only we had a JITing bash
   implementation...
@ddunbar ddunbar force-pushed the build-script-isolated-actions branch from ea99469 to b1d56ea Compare June 14, 2016 00:16
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 14, 2016

@swift-ci please smoke test

@rintaro
Copy link
Member

rintaro commented Jun 14, 2016

Continued from: #2988 (comment)

@ddunbar

I want all the products to have the same initializer signature so that the build-script can work with the classes generically.

According to my own experience, difficult part for that is "dependency": Swift depends on CMark and LLVM, Foundation depends on Swift, and so on.

FYI, Here's my outdated attempt from #2190:
https://github.com/rintaro/swift/blob/SR-237-build-script-rewrite/utils-experimental/build-script-impl/build_script/main_driver.py#L321-L483

From an object-oriented perspective, I think, only LLVM object should knows the path of its deliverables.
That means, Swift object must somehow reference LLVM object for the host, or receive deliverable paths from the main control flow.
Maybe, we can pass structured object that holds all product object, but that leads the same problem of args: it easy to lose track of which products depends on which.
Or should we invent some dependency manager?

@karwa As for args problem

it makes it easy to lose track of which options are required and for what.

I agree with your concern. But, for example, Swift requires over 30 properties of args.
Nobody wants to do like this:

swift_obj = products.Swift(
    target=target,

    # args
    native_llvm_tools_path=args.native_llvm_tools_path,
    native_clang_tools_path=args.native_clang_tools_path,
    native_swift_tools_path=args.native_tools_swift_path,
    build_type=args.swift_build_type,
    enable_assertions=args.swift_enable_assertions,
    ...
    ... )

Do you have ideas?

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 15, 2016

One possible way to manage that, and I'm not familiar enough with argparse to know how easy this is, but if we could get the highly product dependent arguments to simply be parsed into a more structured product-specific object (SwiftProductArgs, e.g.) that would at least be an improvement.

Is it possible to get an argparse argument dest to map to a subobject?

@rintaro
Copy link
Member

rintaro commented Jun 16, 2016

Is it possible to get an argparse argument dest to map to a subobject?

Like this?

parser = argparse.ArgumentParser()
parser.add_argument('--swift-opt', dest="swift.opt")

args = parser.parse_args(['--swift-opt', 'foobar'])
assert args.swift.opt == 'foobar'

It's possible if we use custom Namespace object.
Roughly implemented demo:
https://gist.github.com/rintaro/9f99f4b1627aa9daf91e643f7e5e6a7c

@karwa
Copy link
Contributor

karwa commented Jun 16, 2016

I don't think it's such a big problem. It's only the Swift project that really takes a lot of parameters. Many of them can be given reasonable defaults for the purpose of keeping the initialiser manageable. The build script would then parse the args and set the appropriate properties.

Many of those arguments could also be folded - e.g. the native_{project}_tools_path arguments could be derived from a native HostSpecificConfiguration argument. Actually, in this case the native toolchain is only required for cross-compile builds, so we can leave it out of the initialiser and default the properties to None. In general, any build settings Swift gets from, e.g, LLVM, should come from an already-parsed LLVM object. Thats also easier to reason about and makes semantic sense.

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 21, 2016

@swift-ci please test

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 21, 2016

@swift-ci please smoke test

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 23, 2016

I am going to go ahead and land this change, in the interest of continuing the SR-237 conversion. I'll continue to iterate on the feedback to simplify and cleanup the build-script, but I want to split that into separate PRs.

@ddunbar ddunbar merged commit b169cb5 into swiftlang:master Jun 23, 2016
@ddunbar ddunbar deleted the build-script-isolated-actions branch June 23, 2016 16:00
@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 23, 2016

@rintaro

From an object-oriented perspective, I think, only LLVM object should knows the path of its deliverables.
That means, Swift object must somehow reference LLVM object for the host, or receive deliverable paths from the main control flow.
Maybe, we can pass structured object that holds all product object, but that leads the same problem of args: it easy to lose track of which products depends on which

I think the relationships between the products are simple enough that this is a good pragmatic approach, we have one structured object to hold all the product objects, and pass that to each product so that it can get connection information from that.

@karwa
Copy link
Contributor

karwa commented Jun 23, 2016

I would say the opposite: our dependencies are so simple they can be passed manually.

Especially if we split the build step in to tools/target libraries steps as was proposed for the 'toolchain-based build' thingy.

@karwa
Copy link
Contributor

karwa commented Jun 23, 2016

By manually, I mean initialising the Swift product object with a configured LLVM object.

(Sorry, GitHub doesn't have an edit button on mobile)

@ddunbar
Copy link
Contributor Author

ddunbar commented Jun 23, 2016

I agree, I think the tradeoff just depends on how generic we can make the build-script in terms of products. I'm hoping that we can get rid of a lot of the per-product duplication, and if have a single config object helps that I think it would be a win.

MaxDesiatov added a commit that referenced this pull request Apr 19, 2021
[pull] swiftwasm from main
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.

5 participants