FPGA開発日記

FPGAというより、コンピュータアーキテクチャかもね! カテゴリ別記事インデックス https://sites.google.com/site/fpgadevelopindex/

Swiftがオープンソース化されたのでフルスクラッチビルドに挑戦してみる

Appleプログラミング言語Swiftオープンソース化されたそうだ。

developer.apple.com

github.com

せっかくだし、Vagrant仮想マシンを作って、環境を構築してみようと思ったのだが、、、

その1. Vagrantで箱を作ってSwiftを構築

Appleでも、OfficialにUbuntuを推奨しているため、Ubuntuをダウンロードして新しい仮想マシンを構築し、そこにSwiftをソースからビルドしようとした。

やり方は、Swiftgithubに載っている通りだ。

$ sudo apt-get install git cmake ninja-build clang uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config

$ sudo apt-get install clang-3.6
$ sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
$ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

$ git clone https://github.com/apple/swift.git swift
$ git clone https://github.com/apple/swift-llvm.git llvm
$ git clone https://github.com/apple/swift-clang.git clang
$ git clone https://github.com/apple/swift-lldb.git lldb
$ git clone https://github.com/apple/swift-cmark.git cmark
$ git clone https://github.com/apple/swift-llbuild.git llbuild
$ git clone https://github.com/apple/swift-package-manager.git swiftpm
$ git clone https://github.com/apple/swift-corelibs-xctest.git
$ git clone https://github.com/apple/swift-corelibs-foundation.git

まず、常用しているUbuntu-14.04LTS で挑戦したが、途中でビルドが失敗してしまった(ログを取り忘れた。。。)clang-3.6の問題か?

その2. Ubuntu15.10を利用して挑戦してみる

良く分からないが、環境の問題だということにして、Ubuntuを最新バージョンに上げてみる。

Vagrant box ubuntu/wily64 | Atlas by HashiCorp

ところが、今度はVagrantの初期のディスク容量が足らずに失敗する。上記のVagrantのボックスはデフォルトでは、8GBのHDD容量が取られているのだが、これでは全然足りないようなのだ。 どれだけディスク食うんだよSwift。。。

その3. 独自にUbuntu 15.10の箱を構築して挑戦してみる

そこで、独自にVirtualBoxUbuntu 15.10の仮想マシンを構築し、そこでビルドを挑戦した。今度は、ディスク容量は40GBだ。

-- Build files have been written to: /home/masayuki/swift/build/Ninja-DebugAssert/swift-linux-x86_64
++ cmake_config_opt swift
++ product=swift
++ [[ Ninja == \X\c\o\d\e ]]
+ /usr/bin/cmake --build /home/masayuki/swift/build/Ninja-DebugAssert/swift-linux-x86_64 -- all swift-stdlib-linux-x86_64
[111/490] Building CXX object lib/IDE/CMakeFiles/swiftIDE.dir/SyntaxModel.cpp.o
/home/masayuki/swift/swift/lib/IDE/SyntaxModel.cpp:1298:38: warning: code will never be executed [-Wunreachable-code]
  static const auto MailToPosition = std::find(URLProtocols.begin(),
                                     ^~~~~~~~~
/home/masayuki/swift/swift/lib/IDE/SyntaxModel.cpp:1361:43: warning: code will never be executed [-Wunreachable-code]
  std::match_results<StringRef::iterator> Matches;
                                          ^~~~~~~
2 warnings generated.
[119/490] Building CXX object lib/Immediate/CMakeFiles/swiftImmediate.dir/REPL.cpp.o
/home/masayuki/swift/swift/lib/Immediate/REPL.cpp:133:13: warning: unused function 'convertFromUTF8' [-Wunused-function]
static void convertFromUTF8(llvm::StringRef utf8,
            ^
/home/masayuki/swift/swift/lib/Immediate/REPL.cpp:147:13: warning: unused function 'convertToUTF8' [-Wunused-function]
static void convertToUTF8(llvm::ArrayRef<wchar_t> wide,
            ^
/home/masayuki/swift/swift/lib/Immediate/REPL.cpp:163:13: warning: unused function 'appendToREPLFile' [-Wunused-function]
static bool appendToREPLFile(SourceFile &SF,
            ^
3 warnings generated.
[259/490] Building CXX object lib/SILAnalysis/CMakeFiles/swiftSILAnalysis.dir/AliasAnalysis.cpp.o
/home/masayuki/swift/swift/lib/SILAnalysis/AliasAnalysis.cpp:364:70: warning: unknown command tag name 'in'; did you mean 'fn'? [-Wdocumentation]
/// alias. Call arguments also cannot alias because they must follow @in, @out,
                                                                     ^~~~
                                                                      fn
/home/masayuki/swift/swift/lib/SILAnalysis/AliasAnalysis.cpp:365:16: warning: unknown command tag name 'in'; did you mean 'fn'? [-Wdocumentation]
/// @inout, or @in_guaranteed conventions.
               ^~~~~~~~~~~~~~
                fn
2 warnings generated.
[403/490] Linking CXX executable bin/sil-opt
FAILED: : && /usr/bin/clang++   -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -g  -L/home/masayuki/swift/build/Ninja-DebugAssert/swift-linux-x86_64/./lib/swift/linux tools/sil-opt/CMakeFiles/sil-opt.dir/SILOpt.cpp.o  -o bin/sil-opt -L/home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib  -L/home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/./lib -rdynamic lib/libswiftFrontend.a lib/libswiftIRGen.a lib/libswiftSILGen.a lib/libswiftSILPasses.a lib/libswiftOption.a lib/libswiftLLVMPasses.a lib/libswiftSILPassesUtils.a lib/libswiftSILAnalysis.a lib/libswiftSILPassesUtils.a lib/libswiftSILAnalysis.a lib/libswiftSIL.a lib/libswiftParse.a lib/libswiftSema.a lib/libswiftSIL.a lib/libswiftParse.a lib/libswiftSema.a lib/libswiftSerialization.a lib/libswiftClangImporter.a lib/libswiftAST.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangCodeGen.a lib/libswiftBasic.a -luuid lib/libswiftMarkup.a /home/masayuki/swift/build/Ninja-DebugAssert/cmark-linux-x86_64/src/libcmark.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangIndex.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangFormat.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangToolingCore.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangFrontendTool.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangFrontend.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangDriver.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangSerialization.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangParse.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangSema.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangAnalysis.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangEdit.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangRewriteFrontend.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangRewrite.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangAST.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangLex.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangAPINotes.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libclangBasic.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMIRReader.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAsmParser.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMDebugInfoDWARF.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMObjCARCOpts.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMipo.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMProfileData.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMVectorize.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMOption.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86AsmParser.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86CodeGen.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86Desc.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMObject.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86AsmPrinter.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86Utils.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86Disassembler.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMX86Info.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMCodeGen.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMAsmParser.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMDisassembler.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMDesc.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMAsmPrinter.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMARMInfo.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64CodeGen.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAsmPrinter.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMSelectionDAG.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMCodeGen.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMBitReader.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMBitWriter.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMInstrumentation.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMScalarOpts.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMInstCombine.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMTransformUtils.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMTarget.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAnalysis.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMCore.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64AsmParser.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMMCParser.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64Disassembler.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64Desc.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64AsmPrinter.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64Info.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMMCDisassembler.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMMC.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMAArch64Utils.a /home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lm -Wl,-rpath,/home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/lib:/home/masayuki/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/./lib && :
clang: error: unable to execute command: Killed
clang: error: linker command failed due to signal (use -v to see invocation)
[403/490] Linking CXX executable bin/swift
ninja: build stopped: subcommand failed.
./swift/utils/build-script: command terminated with a non-zero exit status 1, aborting

やはり、途中でビルドが失敗する。しかもログを見ても何だか分からないんだよなあ。。。 もうちょっと、成熟するのを待った方が良いかもしれない。。?