[swift-dev] Beginner's questions about building Swift from source etc.

Jordan Rose jordan_rose at apple.com
Wed Dec 9 19:54:45 CST 2015

Looks like Mish Awadah has an answer on a later thread:

> Here’s what I’ve done in the past to build a toolchain using the build script. 
> function build_osx_package() {
>    YEAR=$(date +"%Y")
>    MONTH=$(date +"%m")
>    DAY=$(date +"%d")
>    ARCHIVE="${TOOLCHAIN_VERSION}-osx.tar.gz"
>    SYM_ARCHIVE="${TOOLCHAIN_VERSION}-osx-symbols.tar.gz"
>    BUNDLE_IDENTIFIER="org.swift.${YEAR}${MONTH}${DAY}"
>    DISPLAY_NAME="Swift Development Snapshot"
>    SWIFT_BUILD_ROOT="${SRC_DIR}/build"
>    SWIFT_INSTALL_DIR="${SRC_DIR}/swift-nightly-install"
>    SWIFT_INSTALL_SYMROOT="${SRC_DIR}/swift-nightly-symroot"
>    SWIFT_TOOLCHAIN_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/${TOOLCHAIN_NAME}.xctoolchain"
>    ./swift/utils/build-script --preset="buildbot_osx_package" install_destdir="${SWIFT_INSTALL_DIR}" installable_package="${SWIFT_INSTALLABLE_PACKAGE}" install_toolchain_dir="${SWIFT_TOOLCHAIN_DIR}" install_symroot="${SWIFT_INSTALL_SYMROOT}" symbols_package="${SYMBOLS_PACKAGE}" darwin_toolchain_bundle_identifier="${BUNDLE_IDENTIFIER}" darwin_toolchain_display_name="${DISPLAY_NAME}" darwin_toolchain_xctoolchain_name="${TOOLCHAIN_NAME}" darwin_toolchain_version="${TOOLCHAIN_VERSION}"
> }

I'm not sure if this is the easiest way, but it will give you a toolchain. Hope that helps.


P.S. I (still) don't know anything about this myself, but I've CCed Mish for further toolchain questions.

> On Dec 9, 2015, at 14:22, Jens Persson via swift-dev <swift-dev at swift.org> wrote:
> Hi all,
> First of all, sorry for not being able to formulate these presumably basic questions in a  better/shorter way.
> Background: We're working on an app that will benefit greatly from Swift's ability to generate optimized code from relatively high level abstractions.
> I've successfully compiled Swift from sources and observed some significant improvements in the optimizer (for details see the following forum thread, especially edit1 and edit2 of this post:
> https://forums.developer.apple.com/thread/27204#93327 <https://forums.developer.apple.com/thread/27204#93327>
> ).
> Now I'd like to be able to use Swift built from sources from within Xcode (or at least have some way of using it with code completion and probably swiftpm), but I haven't been able to find information on how to do that.
> Here's my journey so far:
> 1. Read the main swift repos readme.
> 2. Cloned the 9 repositories listed there (for read-only access).
> 3. Built using:
>     swift/utils/build-script -R --no-assertions --no-swift-stdlib-assertions
>     (Found out about the no-assert-flags through Twitter. Without them, the resulting compiler compiled binaries that were very slow.)
> 3. Compiled my "performance critical" test code like this:
>     xcrun /blabla/build/Ninja-Release/swift-macosx-x86_64/bin/swift -Ounchecked -gnone -whole-module-optimization main.swift
>     (My first try was without xcrun, but then it would complain about "no such module". So I asked Twitter and got the info about using xcrun.) 
> 4. Noted significant improvements in what the optimizer was able to do with my test code (compared to when compiling it with Xcode 7.2. The compiled-from-sources-compiler produced 340 times faster code. See details in the above forum thread.)
> 5. Feeling happy. Can't wait until this gets into an Xcode GM.
> 6. Wish I knew more about how to build Swift from sources, so I could make my workflow more convenient, ie switching between compiling with Swift-built-from-sources, Xcode and Xcode-beta. Eg:
> - Is there a way to use the built-from-sources-version of Swift from within Xcode (can I build a toolchain or something)?
> - How do I build and use the package manager (swiftpm)? It doesn't seem to get built when I build everything(?) using the build-script as described above.
> - Can I use any of the build-presets for this, and if so will it use the --no-assertions and --no-swift-stdlib-assertions options?
> My goal is to be able to have a convenient way of being able to write and compile my (performance critical) code using, switching between and comparing, the three different Swift versions in current
> Xcode (GM),
> Xcode-beta and
> built-from-source.
> Are the answers to these (and similar) questions plain to see in some documentation somewhere or do I have to dig around in various scripts etc and try to figure things out? 
> Thanks,
> /Jens
>  _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151209/94f7d306/attachment.html>

More information about the swift-dev mailing list