Skip to content

build: perform parallel builds of BlocksRuntime #395

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

Closed
wants to merge 1 commit into from

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Oct 2, 2018

Build both the static and shared variants of the BlocksRuntime. This is needed
for proper shared linkage to the BlocksRuntime (e.g. when building SourceKit).
Build both variants and install to the appropriate location.

@compnerd
Copy link
Member Author

compnerd commented Oct 2, 2018

CC: @gottesmm @kevints

CMakeLists.txt Outdated
IMPORTED_LOCATION
${binary_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}BlocksRuntime${CMAKE_SHARED_LIBRARY_SUFFIX}
IMPORTED_IMPLIB
${binary_dir}/${CMAKE_IMPORT_LIBRARY_PREFIX}BlocksRuntime${CMAKE_IMPORT_LIBRARY_SUFFIX})
Copy link

Choose a reason for hiding this comment

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

What does this do on platforms that don't use import libraries?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does nothing meaningful on those platforms. The install rules are what matter, which need to be guarded.

<BINARY_DIR>/${CMAKE_SHARED_LIBRARY_PREFIX}BlocksRuntime${CMAKE_SHARED_LIBRARY_SUFFIX}
<BINARY_DIR>/${CMAKE_IMPORT_LIBRARY_PREFIX}BlocksRuntime${CMAKE_IMPORT_LIBRARY_SUFFIX}
BUILD_ALWAYS
1)
Copy link

@kevints kevints Oct 3, 2018

Choose a reason for hiding this comment

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

My experience using ExternalProject hasn't been great compared to creating library targets that are directly addressable in the build system and I strongly suggest we don't use it in dispatch.

  1. We need to propagate all possible interesting CMake variables from the outer build system to the inner ExternalProject build system via CMAKE_ARGS. For example here you don't propagate CMAKE_C_FLAGS, CMAKE_AR or CMAKE_LIBRARY_PATH which could cause the downstream libraries to be built differently. There are too many influential variables to enumerate here.
  2. ExternalProjects don't get good dependency tracking compared to targets that cmake understands natively. You have to declare BUILD_BYPRODUCTS manually and it's easy to under or over-depend. ExternalProjects also don't have great IDE integration as they appear opaque.
  3. Setting up a library target as IMPORTED prevents dependency tracking and prevents it being exported from the build system (via install(EXPORT) for example).
  4. Ninja is not designed to be invoked recursively - you can get into a situation where the downstream ninja is performing tasks equal to the number of CPUs, so you can have (N^2-1) tasks running in parallel (where N is the number of cores your build machine has). Console output is also broken.

Having said all that, have you considered making BlocksRuntime and BlocksRuntime_static targets using add_library instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, we already are using ExternalProject for libdispatch in swift, and it has been working quite well :-). That said, there is interest in moving to the LLVM wrapper. Doing so will automatically propagate those other variables implicitly.

The dependency tracking issue that you portray is not entirely correct. There is tracking of the dependencies in the sense that the external project's byproducts are linked into the imported library target. So if the sub-library changes, CMake/ninja realize that and rebuild the dependent targets.

Yes, I did consider that. I suppose that if we want to just duplicate the rules, thats certainly an option. I really am strongly opposed to creating the custom wrappers for both variants. I suppose that we could always extract the BlocksRuntime rules into a separate CMakeList and include it in this one to make this easier to work with.


check_include_files("objc/objc-internal.h" HAVE_OBJC)

option(INSTALL_PRIVATE_HEADERS "install private headers in the same location as the public ones" NO)
Copy link

Choose a reason for hiding this comment

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

By placing this inside an ExternalProject there's no way to trigger this option anymore.

Copy link
Member Author

@compnerd compnerd Oct 3, 2018

Choose a reason for hiding this comment

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

Oh, but there is! There is the still the option in libdispatch, which just passes it through :-) However, note that the installation for the swift side is done in the libdispatch side, so that we can install both variants into the install'ed image for libdispatch.

Build both the static and shared variants of the BlocksRuntime.  This is needed
for proper shared linkage to the BlocksRuntime (e.g. when building SourceKit).
Build both variants and install to the appropriate location.
@compnerd
Copy link
Member Author

compnerd commented Oct 3, 2018

Discussed with @kevints offline. We have a better approach that we are going to be taking and this change will be revised with a new version.

@compnerd compnerd closed this Oct 3, 2018
@compnerd compnerd deleted the shared-static branch October 3, 2018 17:11
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