Skip to content

build: add control of the build of Cxx module in -stdlib #65122

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
Apr 13, 2023

Conversation

compnerd
Copy link
Member

This adds the ability to control the C++ interop module in the -stdlib build separately from "extra toolchain content". This is helpful for Windows where we bootstrap the entire toolchain and do not have a stdlib built when building tools.

This adds the ability to control the C++ interop module in the -stdlib
build separately from "extra toolchain content".  This is helpful for
Windows where we bootstrap the entire toolchain and do not have a stdlib
built when building tools.
@compnerd compnerd marked this pull request as ready for review April 12, 2023 22:29
@compnerd compnerd requested review from egorzhdan and zoecarver April 12, 2023 22:29
@compnerd
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, Saleem!

@zoecarver
Copy link
Contributor

Would be good to have Egor look at this as well though :)

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

Hmm, on a closer look, should the build logic that passes SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=FALSE also pass SWIFT_BUILD_STDLIB_CXX_MODULE=FALSE now?

  • utils/swift_build_support/swift_build_support/products/backdeployconcurrency.py:72
  • utils/build-tooling-libs:235

@compnerd
Copy link
Member Author

@egorzhdan - I couldn't tell you that tbh. The current behaviour is maintaining the status quo. In one sense, yes, they should as this was previously disabled and was enabled by the original change, so that is now building more content. In another sense, it seemed that you wanted to build the Cxx module unconditionally? However, if you want my opinion, I would say, yes, those configurations should specify -D SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=NO -D SWIFT_BUILD_STDLIB_CXX_MODULE=NO now.

@compnerd compnerd merged commit fee7e36 into swiftlang:main Apr 13, 2023
drodriguez added a commit to drodriguez/swift that referenced this pull request Apr 14, 2023
With the changes introduced in swiftlang#65055, the Cxx module will build even
when not building the stdlib as long as
`SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT` was set. With the further changes
in swiftlang#65122 the previous flag is not necessary, and only
`SWIFT_BUILD_STDLIB_CXX_MODULE` (which defaults to `TRUE`) is necessary.

However, `stdlib/public/Cxx` did rely on `StdlibOptions.cmake` to be
include before it, or the functions that build the target libraries will
find a half configured state. `StdlibOptions.cmake` are included in
`stdlib/toolchain`, in `stdlib/` and `StandaloneOverlay.cmake`. Before swiftlang#65122
it was working just because `stdlib/toolchain` was added just before.

The second changes adds dependencies on the legacy layouts and the clang
headers. The legacy layouts are a dependency only added to the libraries of
the stdlib core (IS_STDLIB_CORE flag). Since enabling that flag also enables
a bunch other stuff, and I am not sure that Cxx should be classified as "core"
anyway, I preferred to add the dependency. The clang headers are another
dependency of the swiftCore, which otherwise causes problems to not find
the compiler headers when building Cxx. This is necessary for builds
that use a previously built compiler to compile the stdlib.
drodriguez added a commit to drodriguez/swift that referenced this pull request Apr 14, 2023
With the changes introduced in swiftlang#65055, the Cxx module will build even
when not building the stdlib as long as
`SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT` was set. With the further changes
in swiftlang#65122 the previous flag is not necessary, and only
`SWIFT_BUILD_STDLIB_CXX_MODULE` (which defaults to `TRUE`) is necessary.

However, `stdlib/public/Cxx` did rely on `StdlibOptions.cmake` to be
include before it, or the functions that build the target libraries will
find a half configured state. `StdlibOptions.cmake` are included in
`stdlib/toolchain`, in `stdlib/` and `StandaloneOverlay.cmake`. Before swiftlang#65122
it was working just because `stdlib/toolchain` was added just before.

The second changes adds dependencies on the legacy layouts and the clang
headers. The legacy layouts are a dependency only added to the libraries of
the stdlib core (IS_STDLIB_CORE flag). Since enabling that flag also enables
a bunch other stuff, and I am not sure that Cxx should be classified as "core"
anyway, I preferred to add the dependency. The clang headers are another
dependency of the swiftCore, which otherwise causes problems to not find
the compiler headers when building Cxx. This is necessary for builds
that use a previously built compiler to compile the stdlib.
drodriguez added a commit that referenced this pull request Apr 14, 2023
With the changes introduced in #65055, the Cxx module will build even
when not building the stdlib as long as
`SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT` was set. With the further changes
in #65122 the previous flag is not necessary, and only
`SWIFT_BUILD_STDLIB_CXX_MODULE` (which defaults to `TRUE`) is necessary.

However, `stdlib/public/Cxx` did rely on `StdlibOptions.cmake` to be
include before it, or the functions that build the target libraries will
find a half configured state. `StdlibOptions.cmake` are included in
`stdlib/toolchain`, in `stdlib/` and `StandaloneOverlay.cmake`. Before #65122
it was working just because `stdlib/toolchain` was added just before.

The second changes adds dependencies on the legacy layouts and the clang
headers. The legacy layouts are a dependency only added to the libraries of
the stdlib core (IS_STDLIB_CORE flag). Since enabling that flag also enables
a bunch other stuff, and I am not sure that Cxx should be classified as "core"
anyway, I preferred to add the dependency. The clang headers are another
dependency of the swiftCore, which otherwise causes problems to not find
the compiler headers when building Cxx. This is necessary for builds
that use a previously built compiler to compile the stdlib.
drodriguez added a commit that referenced this pull request Apr 17, 2023
In #65172 I tried to fix a problem when the Cxx module is enabled, but
we are not building the stdlib. The fix work for `swiftCxx`, but failed
to to realize that `swiftCxxStdlib` overlay is also built, which needs
parts of the stdlib.

The original #65055 only built the Cxx module when
`EXTRA_TOOLCHAIN_CONTENT` was set, but #65122 changed so it was two
independent checks. A more faithful fix will had been to nest the `if`
as I am trying to do with this PR. Parts of #65172 are still necessary
to build in every case, though: the `swiftCxx` target is dependent on
the Clang headers and the legacy layouts. Those two pieces are normally
in place because of other targets in upstream builds, but fail to
materialize when the stdlib is trying to be built with the host
compiler.

This one and #65172 will need to be cherry-picked to 5.9 because #65055
and #65122 where cherry-picked, so 5.9 is having the same problems as
`main`.
drodriguez added a commit to drodriguez/swift that referenced this pull request Apr 17, 2023
…65172)

With the changes introduced in swiftlang#65055, the Cxx module will build even
when not building the stdlib as long as
`SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT` was set. With the further changes
in swiftlang#65122 the previous flag is not necessary, and only
`SWIFT_BUILD_STDLIB_CXX_MODULE` (which defaults to `TRUE`) is necessary.

However, `stdlib/public/Cxx` did rely on `StdlibOptions.cmake` to be
include before it, or the functions that build the target libraries will
find a half configured state. `StdlibOptions.cmake` are included in
`stdlib/toolchain`, in `stdlib/` and `StandaloneOverlay.cmake`. Before swiftlang#65122
it was working just because `stdlib/toolchain` was added just before.

The second changes adds dependencies on the legacy layouts and the clang
headers. The legacy layouts are a dependency only added to the libraries of
the stdlib core (IS_STDLIB_CORE flag). Since enabling that flag also enables
a bunch other stuff, and I am not sure that Cxx should be classified as "core"
anyway, I preferred to add the dependency. The clang headers are another
dependency of the swiftCore, which otherwise causes problems to not find
the compiler headers when building Cxx. This is necessary for builds
that use a previously built compiler to compile the stdlib.

(cherry picked from commit 539fc69)
drodriguez added a commit to drodriguez/swift that referenced this pull request Apr 17, 2023
In swiftlang#65172 I tried to fix a problem when the Cxx module is enabled, but
we are not building the stdlib. The fix work for `swiftCxx`, but failed
to to realize that `swiftCxxStdlib` overlay is also built, which needs
parts of the stdlib.

The original swiftlang#65055 only built the Cxx module when
`EXTRA_TOOLCHAIN_CONTENT` was set, but swiftlang#65122 changed so it was two
independent checks. A more faithful fix will had been to nest the `if`
as I am trying to do with this PR. Parts of swiftlang#65172 are still necessary
to build in every case, though: the `swiftCxx` target is dependent on
the Clang headers and the legacy layouts. Those two pieces are normally
in place because of other targets in upstream builds, but fail to
materialize when the stdlib is trying to be built with the host
compiler.

This one and swiftlang#65172 will need to be cherry-picked to 5.9 because swiftlang#65055
and swiftlang#65122 where cherry-picked, so 5.9 is having the same problems as
`main`.

(cherry picked from commit ccf57da)
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request Apr 18, 2023
In swiftlang#65172 I tried to fix a problem when the Cxx module is enabled, but
we are not building the stdlib. The fix work for `swiftCxx`, but failed
to to realize that `swiftCxxStdlib` overlay is also built, which needs
parts of the stdlib.

The original swiftlang#65055 only built the Cxx module when
`EXTRA_TOOLCHAIN_CONTENT` was set, but swiftlang#65122 changed so it was two
independent checks. A more faithful fix will had been to nest the `if`
as I am trying to do with this PR. Parts of swiftlang#65172 are still necessary
to build in every case, though: the `swiftCxx` target is dependent on
the Clang headers and the legacy layouts. Those two pieces are normally
in place because of other targets in upstream builds, but fail to
materialize when the stdlib is trying to be built with the host
compiler.

This one and swiftlang#65172 will need to be cherry-picked to 5.9 because swiftlang#65055
and swiftlang#65122 where cherry-picked, so 5.9 is having the same problems as
`main`.
@compnerd compnerd deleted the cxx-option branch July 21, 2023 11:32
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.

3 participants