Build script documentation

(Carl Peto) #1

Hiya, bit of a generic question, leading on from my work on other topics. (I hope I'm not repeating myself.)

Is there any detailed documentation of the build script, other than just the help options and basic examples?

I'd like to start patching/hacking it but I'm more of a C/C++/Swift person than a python guru.

Specifically i'd like to build the swift compiler without building the standard library. Right now my best approach is to set a build off and hope!


(Brent Royal-Gordon) #2

The way to do this is to use build-script for the initial build and thereafter use ninja -C ../build/Ninja-WhateverConfigYoureUsing/swift-macosx-x86_64, which lets you specify a particular target. For instance, the target swift will rebuild just the main compiler executable, leaving other executables (like the SIL optimizer) and Swift modules untouched.

(Carl Peto) #3

I'm in the process of trying this (I've built cmark and llvm first as I assume various targets will need these).

Is there any documentation about the targets, etc.?

I'm not used to ninja (I'm more used to classic gmake) and looking through the generated, it's over 123,000 lines long!!

(Dan Zheng) #4

I don't think there's great documentation, unfortunately.

You can list all ninja targets with ninja -t targets. The ones you're likely interested in are:

  • ninja swift: as mentioned above, builds the swift compiler without the stdlib (swift and swiftc binaries).
  • ninja swift-stdlib: builds the swift stdlib.
    • This takes a long time. If you want to test only the compiler, you'll need to build the stdlib just once. Then, you can just run ninja swift to build the compiler incrementally.
  • ninja sil-opt: builds the SIL optimizer utility, useful for testing SIL transformations.

@codafi has a great post on tips for building and testing, with a focus on testing.

(Ben Rimmington) #5

Be a Ninja