Skip to content

Extend freestanding to support targeting Darwin platforms #40202

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 6 commits into from
Dec 8, 2021

Conversation

edymtt
Copy link
Contributor

@edymtt edymtt commented Nov 16, 2021

  • add an option to add freestanding to the Darwin platform, so that
    to get expected compile behaviours (e.g. setting the install name)
  • rework testing configuration to relax assumptions about freestanding
  • add a preset to test such configuration (at least for PR testing)

Addresses rdar://85465396

@edymtt edymtt force-pushed the extend-freestanding-to-darwin branch from da1374d to 6fff7df Compare November 16, 2021 18:51
@edymtt
Copy link
Contributor Author

edymtt commented Nov 16, 2021

@swift-ci please python lint

@edymtt
Copy link
Contributor Author

edymtt commented Nov 16, 2021

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@edymtt
Copy link
Contributor Author

edymtt commented Nov 16, 2021

preset=stdlib_S_standalone_darwin_x86_64,build,test
@swift-ci please test with toolchain and preset

@@ -1685,6 +1685,7 @@ function(add_swift_target_library name)
set(SWIFTLIB_TARGET_SDKS ${SWIFT_SDKS})
endif()
list_replace(SWIFTLIB_TARGET_SDKS ALL_APPLE_PLATFORMS "${SWIFT_DARWIN_PLATFORMS}")
list(REMOVE_DUPLICATES SWIFTLIB_TARGET_SDKS)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this part of this change? Is this because adding the FREESTANDING now results in duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes -- in particular FREESTANDING could be present in SWIFT_DARWIN_PLATFORMS and as an explicit target when building the Darwin overlay (as a result of https://github.com/apple/swift/blob/78809726080ce61a4f73c013d542c91d5da35f2e/stdlib/public/Platform/CMakeLists.txt#L21)

I could have added the deduplication in the file above, but this seemed something that could happen in other instances as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a nice big comment here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@edymtt is it possible to instead of adding in this deduplication, add in an assert that we never have duplicates and change the other code?

Copy link
Contributor Author

@edymtt edymtt Nov 17, 2021

Choose a reason for hiding this comment

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

For now I addressed the issue in Platform/CMakeLists.txt (a8d57e2)

Adding the assert seems to require some changes to precondition_binary_op which may require further discussion a bit outside of this PR -- if time allows I will tackle that in another PR.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6fff7df049079ffe25226753472916bcb9f10fb7

test/lit.cfg Outdated
@@ -1155,7 +1165,10 @@ if run_vendor == 'apple':
'Running tests on %s version %s (%s)' %
(sw_vers_name, sw_vers_vers, sw_vers_build))

config.target_sdk_name = xcrun_sdk_name
if "-freestanding" in config.variant_suffix and config.swift_freestanding_is_darwin:
config.target_sdk_name = "freestanding"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here explaining why you are doing this.

Copy link
Contributor Author

@edymtt edymtt Nov 17, 2021

Choose a reason for hiding this comment

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

Added a comment in bbde1af, also pulled the value from CMake in an attempt to show where that value comes from.

@edymtt
Copy link
Contributor Author

edymtt commented Nov 17, 2021

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c843efb09df08b5e7dd4e3471a21c224fd4de893

@edymtt
Copy link
Contributor Author

edymtt commented Nov 17, 2021

******************** TEST 'Swift(freestanding-x86_64) :: stdlib/symbols-depended-on-in-freestanding.darwin.test-sh' FAILED ********************
<snip>
Error: Unexpected dependency '_fflush'

This happens on main as well -- https://ci.swift.org/job/oss-swift-test-stdlib-with-toolchain-minimal/843/console

@edymtt
Copy link
Contributor Author

edymtt commented Nov 17, 2021

preset=stdlib_S_standalone_darwin_x86_64,build,test
@swift-ci please test with toolchain and preset

* add an option to add freestanding to the Darwin platform, so that
  to get expected compile behaviours (e.g. setting the install name)
* rework testing configuration to relax assumptions about freestanding
* add a preset to test such configuration (at least for PR testing)

Addresses rdar://85465396
Drop deduplication of such lists so to surface configuration errors
earlier.
Add some more comments as well
@edymtt edymtt force-pushed the extend-freestanding-to-darwin branch from c843efb to bbde1af Compare December 6, 2021 16:17
Also take the chance to rename a function for clarity
@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

@swift-ci please python lint

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

Testing the minimal preset before testing the one introduced with this PR

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

preset=stdlib_S_standalone_darwin_x86_64,build,test
@swift-ci please test with toolchain and preset

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

@swift-ci please smoke test

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor Author

edymtt commented Dec 6, 2021

@swift-ci please build toolchain

@swift-ci
Copy link
Contributor

swift-ci commented Dec 6, 2021

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 194fb21

Install command
tar zxf swift-PR-40202-739-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

swift-ci commented Dec 7, 2021

macOS Toolchain
Download Toolchain
Git Sha - 194fb21

Install command
tar -zxf swift-PR-40202-1234-osx.tar.gz --directory ~/

@@ -972,6 +980,8 @@ if run_vendor == 'apple':
symlink_if_not_exists("clang", "clang")
symlink_if_not_exists("shims", "shims")
symlink_if_not_exists("freestanding", "macosx")
if config.swift_freestanding_is_darwin:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here explaining why we are doing this?


swift_execution_tests_extra_flags += ' -experimental-hermetic-seal-at-link -lto=llvm-full'
if not config.swift_freestanding_is_darwin:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine for now, but the hermetic seal at link thing feels like it should have its own feature option sort of thing.

But that being said, I think this is good incremental work. Maybe put in a TODO.

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM. Can you maybe add some comments in a follow on commit.

@edymtt edymtt merged commit 403ccd4 into swiftlang:main Dec 8, 2021
edymtt added a commit to edymtt/swift that referenced this pull request Dec 8, 2021
@edymtt edymtt deleted the extend-freestanding-to-darwin branch December 8, 2021 15:21
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