Merge branch 'main' of github.com:apple/swift into tensorflow-stage

* 'main' of github.com:apple/swift:
  IRGen: Nonoverridden method descriptors should be true-const
tree: 4e1ece144d4fd4121f25ca8f36758de80d19840b
  1. .clang-format
  2. .dir-locals.el
  3. .flake8
  4. .gitattributes
  5. .github/
  6. .gitignore
  7. .mailmap
  8. Brewfile
  9. CHANGELOG.md
  10. CMakeLists.txt
  11. CODE_OF_CONDUCT.md
  12. CODE_OWNERS.TXT
  13. CONTRIBUTING.md
  14. LICENSE.txt
  15. README.md
  16. apinotes/
  17. benchmark/
  18. bindings/
  19. cmake/
  20. docs/
  21. include/
  22. lib/
  23. localization/
  24. stdlib/
  25. test/
  26. tools/
  27. unittests/
  28. userdocs/
  29. utils/
  30. validation-test/
README.md

Swift Programming Language

ArchitecturemainPackage
macOSx86_64Build StatusBuild Status
Ubuntu 16.04x86_64Build StatusBuild Status
Ubuntu 18.04x86_64Build StatusBuild Status
Ubuntu 20.04x86_64Build StatusBuild Status
CentOS 8x86_64Build StatusBuild Status
Amazon Linux 2x86_64Build StatusBuild Status

Swift Community-Hosted CI Platforms

OSArchitectureBuild
Ubuntu 16.04 PPC64LEBuild Status
Ubuntu 18.04AArch64Build Status
Ubuntu 20.04AArch64Build Status
CentOS 8 AArch64Build Status
Amazon Linux 2AArch64Build Status
AndroidARMv7Build Status
AndroidAArch64Build Status
Windows 2019 (VS 2017)x86_64Build Status
Windows 2019 (VS 2019)x86_64Build Status

Swift TensorFlow Community-Hosted CI Platforms

OSArchitectureBuild
Ubuntu 18.04x86_64Build Status
macOS 10.13x86_64Build Status

Swift for TensorFlow is a new programming language for TensorFlow. It is a copy of the compiler for the Swift Programming Language that adds first-class compiler and language support for machine learning.

This repository covers the compiler and standard libraries. Please visit the documentation repository for more information about the project, including a project overview, technical details, and guidelines for contributing. To use Swift for TensorFlow out of the box, follow the installation instructions. To build from source, follow the instructions below.

Welcome to Swift

Swift is a high-performance system programming language. It has a clean and modern syntax, offers seamless access to existing C and Objective-C code and frameworks, and is memory safe by default.

Although inspired by Objective-C and many other languages, Swift is not itself a C-derived language. As a complete and independent language, Swift packages core features like flow control, data structures, and functions, with high-level constructs like objects, protocols, closures, and generics. Swift embraces modules, eliminating the need for headers and the code duplication they entail.

To learn more about the programming language, visit swift.org.

Contributing to Swift

Contributions to Swift are welcomed and encouraged! Please see the Contributing to Swift guide.

To be a truly great community, Swift.org needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.

To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.

Getting Started

If you are interested in:

We also have an FAQ that answers common questions.

Swift For TensorFlow Toolchains

Building

Swift for TensorFlow toolchains are created using the script build-toolchain-tensorflow. This script is used by swift.org's CI to produce snapshots and can allow for one to locally reproduce such builds for development or distribution purposes. A typical invocation looks like the following:

  $ ./swift/utils/build-toolchain-tensorflow $BUNDLE_PREFIX

where $BUNDLE_PREFIX is a string that will be prepended to the build date to give the bundle identifier of the toolchain's Info.plist. For instance, if $BUNDLE_PREFIX was com.example, the toolchain produced will have the bundle identifier com.example.YYYYMMDD. It will be created in the directory you run the script with a filename of the form: swift-tensorflow-LOCAL-YYYY-MM-DD-a-osx.tar.gz.

Beyond building the toolchain, build-toolchain-tensorflow also supports the following (non-exhaustive) set of useful options:

  • --dry-run: Perform a dry run build. This is off by default.
  • --test: Test the toolchain after it has been compiled. This is off by default.
  • --pkg (macOS only): Build a toolchain installer package (.pkg). This is off by default.

More options may be added over time. Please pass --help to build-toolchain-tensorflow to see the full set of options.

Installing into Xcode

On macOS if one wants to install such a toolchain into Xcode:

  1. Untar and copy the toolchain to one of /Library/Developer/Toolchains/ or ~/Library/Developer/Toolchains/. E.x.:
  $ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C /
  $ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C ~/

The script also generates an archive containing debug symbols which can be installed over the main archive allowing symbolication of any compiler crashes.

  $ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C /
  $ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C ~/
  1. Specify the local toolchain for Xcode's use via Xcode->Toolchains.

Swift Toolchains

Building

Swift toolchains are created using the script build-toolchain. This script is used by swift.org's CI to produce snapshots and can allow for one to locally reproduce such builds for development or distribution purposes. A typical invocation looks like the following:

  $ ./swift/utils/build-toolchain $BUNDLE_PREFIX

where $BUNDLE_PREFIX is a string that will be prepended to the build date to give the bundle identifier of the toolchain's Info.plist. For instance, if $BUNDLE_PREFIX was com.example, the toolchain produced will have the bundle identifier com.example.YYYYMMDD. It will be created in the directory you run the script with a filename of the form: swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz.

Beyond building the toolchain, build-toolchain also supports the following (non-exhaustive) set of useful options::

  • --dry-run: Perform a dry run build. This is off by default.
  • --test: Test the toolchain after it has been compiled. This is off by default.
  • --distcc: Use distcc to speed up the build by distributing the c++ part of the swift build. This is off by default.

More options may be added over time. Please pass --help to build-toolchain to see the full set of options.

Installing into Xcode

On macOS if one wants to install such a toolchain into Xcode:

  1. Untar and copy the toolchain to one of /Library/Developer/Toolchains/ or ~/Library/Developer/Toolchains/. E.x.:
  $ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C /
  $ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C ~/

The script also generates an archive containing debug symbols which can be installed over the main archive allowing symbolication of any compiler crashes.

  $ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C /
  $ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C ~/
  1. Specify the local toolchain for Xcode's use via Xcode->Toolchains.

Build Failures

Try the suggestions in Troubleshooting build issues.

Make sure you are using the correct release of Xcode.

If you have changed Xcode versions but still encounter errors that appear to be related to the Xcode version, try passing --clean to build-script.

When a new version of Xcode is released, you can update your build without recompiling the entire project by passing --reconfigure to build-script.

Learning More

Be sure to look at the documentation index for a bird's eye view of the available documentation. In particular, the documents titled Debugging the Swift Compiler and Continuous Integration for Swift are very helpful to understand before submitting your first PR.