[swift-users] Bootstrapping ninja and building from source

Lane Schwartz dowobeha at gmail.com
Fri Dec 4 14:36:24 CST 2015


On Fri, Dec 4, 2015 at 1:39 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Fri, Dec 4, 2015 at 11:22 AM, Lane Schwartz <dowobeha at gmail.com> wrote:
>
>> Hi,
>>
>> First of all, congratulations on the open source release! I'm very
>> excited!
>>
>> Second, I'm running into trouble building from source, particularly in
>> regards to getting ninja bootstrapped. I'm on Scientific Linux.
>>
>
> Which version are you running?  It is only feasible to try SL7+ because of
> LLVM and Clang requirements.
>
>
>> I first used yum to install packages for llvm, llvm-devel, clang, and
>> cmake.
>>
>> I then did the following, following the README.md in the swift git repo:
>>
>>  git clone git at github.com:apple/swift.git swift
>>  git clone git at github.com:apple/swift-llvm.git llvm
>>  git clone git at github.com:apple/swift-clang.git clang
>>  git clone git at github.com:apple/swift-lldb.git lldb
>>  git clone git at github.com:apple/swift-cmark.git cmark
>>  git clone git at github.com:apple/swift-llbuild.git llbuild
>>  git clone git at github.com:apple/swift-package-manager.git swiftpm
>>  git clone git at github.com:apple/swift-corelibs-xctest.git
>>  git clone git at github.com:apple/swift-corelibs-foundation.git
>>
>>
>> The README.md also states:
>>
>> Ninja is the current recommended build system for building Swift and is
>>> the default configuration generated by CMake. If you're on OS X or don't
>>> install it as part of your Linux distribution, clone it next to the other
>>> projects and it will be bootstrapped automatically
>>
>>
>>  My Linux distro doesn't package ninja, so I also did this:
>>
>> git clone git at github.com:martine/ninja.git
>>
>> I then attempted to build swift:
>>
>> $ ./swift/utils/build-script
>>
>
> Yes, this should work.
>
>
>>
>> Which resulted in errors, and as far as I can tell did not attempt to
>> build the ninja distro that I downloaded into the ninja directory in my
>> current working directory:
>>
>> which: no ninja in
>>> (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/lanes/.local/bin:/home/lanes/bin)
>>> Building the standard library for: swift-stdlib-linux-x86_64
>>> Running Swift tests for: check-swift-linux-x86_64
>>> + rm -rf /home/lanes/swift/build/Ninja-DebugAssert/ninja-build
>>> + cp -r /home/lanes/swift/ninja
>>> /home/lanes/swift/build/Ninja-DebugAssert/ninja-build
>>> ++ uname -s
>>> + [[ Linux == \D\a\r\w\i\n ]]
>>> + cd /home/lanes/swift/build/Ninja-DebugAssert/ninja-build
>>> + python ./configure.py --bootstrap
>>> bootstrapping ninja...
>>> warning: A compatible version of re2c (>= 0.11.3) was not found; changes
>>> to src/*.in.cc will not affect your build.
>>> wrote build.ninja.
>>> bootstrap complete.  rebuilding...
>>> [24/24] LINK ninja
>>>
>>
> So ninja built successfully.
>
>
>> cmark: using standard linker
>>> + cd /home/lanes/swift/build/Ninja-DebugAssert/cmark-linux-x86_64
>>> + /usr/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang
>>> -DCMAKE_CXX_COMPILER:PATH=clang++ -DCMAKE_BUILD_TYPE:STRING=Debug
>>> /home/lanes/swift/cmark
>>>
>>
> I just verified, the script bootstraps ninja for me, and cmake finds it.
>
> Could you apply this patch and see if the PATH was set correctly?
>
> diff --git a/utils/build-script-impl b/utils/build-script-impl
> index b2d2954..60ab51d 100755
> --- a/utils/build-script-impl
> +++ b/utils/build-script-impl
> @@ -1312,6 +1312,7 @@ if [[ "${BUILD_NINJA}" ]] ; then
>          fi
>      fi
>      export PATH="${build_dir}:${PATH}"
> +    which ninja
>  fi
>
>  #
> @@ -1805,6 +1806,7 @@ for deployment_target in
> "${NATIVE_TOOLS_DEPLOYMENT_TARGETS[@]}" "${CROSS_TOOLS_
>                      ( ! -z "${generator_output_path}" && ! -f
> "${generator_output_path}" ) ]] ; then
>              mkdir -p "${build_dir}"
>              set -x
> +            which ninja
>              (cd "${build_dir}" && "$CMAKE" "${cmake_options[@]}"
> ${USER_CONFIG_ARGS})
>              { set +x; } 2>/dev/null
>          fi
>
>  Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>


I'm on Scientific Linux 7.1. I added the two instances of "which ninja" as
you suggested, then re-ran build-script:

$ ./swift/utils/build-script
> which: no ninja in
> (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/lanes/.local/bin:/home/lanes/bin)
> Building the standard library for: swift-stdlib-linux-x86_64
> Running Swift tests for: check-swift-linux-x86_64
>
> /home/lanes/swift/build/Ninja-DebugAssert/ninja-build/ninja
> cmark: using standard linker
> + which ninja
> /home/lanes/swift/build/Ninja-DebugAssert/ninja-build/ninja
> + cd /home/lanes/swift/build/Ninja-DebugAssert/cmark-linux-x86_64
> + /usr/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang
> -DCMAKE_CXX_COMPILER:PATH=clang++ -DCMAKE_BUILD_TYPE:STRING=Debug
> /home/lanes/swift/cmark
> CMake Error: CMake was unable to find a build program corresponding to
> "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a
> different build tool.
> CMake Error: Error required internal CMake variable not set, cmake may be
> not be built correctly.
> Missing variable is:
> CMAKE_C_COMPILER_ENV_VAR
> CMake Error: Could not find cmake module
> file:/home/lanes/swift/build/Ninja-DebugAssert/cmark-linux-x86_64/CMakeFiles/2.8.11/CMakeCCompiler.cmake
> CMake Error: Error required internal CMake variable not set, cmake may be
> not be built correctly.
> Missing variable is:
> CMAKE_CXX_COMPILER_ENV_VAR
> CMake Error: Could not find cmake module
> file:/home/lanes/swift/build/Ninja-DebugAssert/cmark-linux-x86_64/CMakeFiles/2.8.11/CMakeCXXCompiler.cmake
> -- Configuring incomplete, errors occurred!
> ./swift/utils/build-script: command terminated with a non-zero exit status
> 1, aborting


Thanks,
Lane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151204/28c7f6f3/attachment.html>


More information about the swift-users mailing list