Skip to content

[build-script] Turn on --no-legacy-impl by default #21772

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 3 commits into from
Jan 24, 2019

Conversation

benlangmuir
Copy link
Contributor

Turns on the --no-legacy-impl option to build-script by default; the
old behaviour is temporarily still available as --legacy-impl.

This causes build-script to invoke build-script-impl for every
individual build/test/install/etc. action rather than a single global
invocation. For example, a single invocation might be for
macosx-swift-install. This will enable the python code in build-script
to drive the overall process and add additional steps in between actions
without the involvement of build-script-impl. It also provides a path to
refactoring the existing actions out of build-script-impl individually.

Discussed as part of https://forums.swift.org/t/rfc-building-swift-packages-in-build-script/18920

The --no-legacy-impl flag was originally disabled by default because of
concerns about the performance of null builds due to the increased
number of script invocations. There is a small optimization in this
commit to use tr when processing command-line options instead of
bash's builtin substitution, which eliminates most of the overhead.
After this change, a null build of llvm+swift changes from 1.6 s to
2.1 s on Linux, and from 5 s to 6 s on macOS. Non-null builds and
builds that involve more build products than just llvm+swift (e.g.
corelibs) are basically unaffected since they are not correctly
incremental to begin with.

The changes to build-script-impl in this commit are to fix the behaviour
of --no-legacy-impl, which had bitrotted since it was introduced. These
changes are to make various parts of the script not rely on variables
defined in "earlier" parts of the script, which is good hygiene in
general.

@benlangmuir
Copy link
Contributor Author

impl_args += [
"--%s-cmake-options=%s" % (product_name, ' '.join(cmake_opts))
]
if len(cmake_opts) > 0:
Copy link
Member

Choose a reason for hiding this comment

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

The more idiomatic way to write this would be:

  if cmake_opts:

-DSWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_I18N_INCLUDE:STRING="${ICU_TMPINSTALL}/include"
-DSWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB:BOOL=TRUE
-DICU_UC_LIBDIR:PATH="${LIBICU_BUILD_DIR}/lib"
-DICU_I18N_LIBDIR:PATH="${LIBICU_BUILD_DIR}/lib"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, does this work? I thought that it requires that the path to the library is given instead. I think it would be nicer if we just used -DSWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_{UC,I18N}=

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just kept these the same as they were before. Maybe they were always dead?

@@ -2623,12 +2637,14 @@ for host in "${ALL_HOSTS[@]}"; do
echo "Cleaning the XCTest build directory"
call rm -rf "${XCTEST_BUILD_DIR}"

LLVM_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
Copy link
Member

Choose a reason for hiding this comment

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

Where is this new variable used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the options immediately below, e.g. Line 2645. Previously it depended on this being set somewhere else

# Set the PKG_CONFIG_PATH so that core-foundation can find the libraries and
# header files
LIBICU_BUILD_DIR="$(build_directory ${host} libicu)"
export PKG_CONFIG_PATH="${LIBICU_BUILD_DIR}/config:${PKG_CONFIG_PATH}"
Copy link
Member

Choose a reason for hiding this comment

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

Why were the CMake options removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which ones? Maybe this comment was on the wrong line? There was a set of options being appended to swift_cmake_options during the setup of ICU that I moved directly into the configuration for swift.

@benlangmuir
Copy link
Contributor Author

@swift-ci please test

@benlangmuir
Copy link
Contributor Author

@swift-ci please build toolchain

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ce4c85a

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ce4c85a

@benlangmuir
Copy link
Contributor Author

Any additional feedback, @compnerd?

]
if cmake_opts:
impl_args += [
"--%s-cmake-options=%s" %
Copy link
Contributor

@Rostepher Rostepher Jan 14, 2019

Choose a reason for hiding this comment

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

(Nit-pick) We should be using the more modern Python string formatting via the str.format method. This could be re-written as: '--{}-cmake-options={}'.format(product_name, ' '.join(cmake_opts)).

@benlangmuir
Copy link
Contributor Author

@swift-ci please smoke test

@benlangmuir
Copy link
Contributor Author

@swift-ci please smoke test

@benlangmuir
Copy link
Contributor Author

@compnerd or @Rostepher any additional feedback, or is this good to go?

@Rostepher
Copy link
Contributor

I'm fine with merging this.

Turns on the `--no-legacy-impl` option to build-script by default; the
old behaviour is temporarily still available as `--legacy-impl`.

This causes build-script to invoke build-script-impl for every
individual build/test/install/etc. action rather than a single global
invocation. For example, a single invocation might be for
`macosx-swift-install`. This will enable the python code in build-script
to drive the overall process and add additional steps in between actions
without the involvement of build-script-impl. It also provides a path to
refactoring the existing actions out of build-script-impl individually.

Discussed as part of https://forums.swift.org/t/rfc-building-swift-packages-in-build-script/18920

The --no-legacy-impl flag was originally disabled by default because of
concerns about the performance of null builds due to the increased
number of script invocations. There is a small optimization in this
commit to use `tr` when processing command-line options instead of
bash's builtin substitution, which eliminates most of the overhead.
After this change, a null build of llvm+swift changes from 1.6 s to
2.1 s on Linux, and from 5 s to 6 s on macOS.  Non-null builds and
builds that involve more build products than just llvm+swift (e.g.
corelibs) are basically unaffected since they are not correctly
incremental to begin with.

The changes to build-script-impl in this commit are to fix the behaviour
of --no-legacy-impl, which had bitrotted since it was introduced. These
changes are to make various parts of the script not rely on variables
defined in "earlier" parts of the script, which is good hygiene in
general.
@benlangmuir
Copy link
Contributor Author

@swift-ci please smoke test

@benlangmuir
Copy link
Contributor Author

@swift-ci please smoke test macOS

@benlangmuir
Copy link
Contributor Author

@compnerd is this ready to go, or did you have more feedback?

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

If the builds are happy, I'm happy.

@benlangmuir
Copy link
Contributor Author

@swift-ci please build toolchain

@benlangmuir benlangmuir merged commit dc2ea3e into swiftlang:master Jan 24, 2019
@benlangmuir benlangmuir deleted the no-legacy-rebase branch January 24, 2019 17:14
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.

4 participants