1DOLLY 72TOOLCHAIN mojo-llvm3REQUIRES HOST runtime@04REQUIRES HOST display@05REQUIRES HOST input@06REQUIRES HOST dso@07REQUIRES HOST http@08REQUIRES HOST sockets@09REQUIRES HOST threads@01011# Build-only: the LLVM, MLIR and Clang Basic libraries the Mojo compiler12# links, at the revision Mojo pins, and Zstandard, compiled inside Dolly by13# its own cc and c++.14FROM /v0.1.4/demos/cmake/Dollyfile-cmake-build e9a42d1ad1b8c35d3a6543a28306dc2d88e90e114bd3e6df892ffec05fbcfd5f15# LLVM's CMake requires a Python 3 interpreter.16INSTALL /v0.1.4/demos/python/Dollyfile-python 3e3b6f083bff4d9be1a817d8fa142378e2c0b492c42998e71977e2c309bdddb317REQUIRES TOOL cmake18REQUIRES TOOL make19REQUIRES TOOL python20REQUIRES TOOL cc21REQUIRES TOOL c++22REQUIRES TOOL ar23REQUIRES TOOL gzip24REQUIRES TOOL tar25REQUIRES TOOL patch26REQUIRES TOOL time27REQUIRES TOOL find28REQUIRES TOOL cp29REQUIRES TOOL mkdir30REQUIRES TOOL rm3132SOURCE /v0.1.4/dist/static/mojo/mojo-llvm.tar.gz bb20b5265be3bcb4387eb866060e3fa6ba5a07fb132fad481793b6db0699ac75 /tmp/mojo-llvm.tar.gz33SLOP time slop -c 'gzip -dc /tmp/mojo-llvm.tar.gz | tar -xf - -C /'34SLOP rm /tmp/mojo-llvm.tar.gz35# As demos/llvm: config.guess runs and knows no Dolly host.36SOURCE /v0.1.4/dist/static/mojo/llvm-host-triple.patch ec739fd5932c1040d07344a8511bae4da4157ff2bcafa348f06a555b71a10981 /tmp/llvm-host-triple.patch37SLOP patch -p1 -d /tmp/mojo-llvm -i /tmp/llvm-host-triple.patch38# As demos/rust: Dolly has no /proc/self/exe; a program finds itself from argv[0].39SOURCE /v0.1.4/dist/static/mojo/llvm-main-executable.patch a9fb350ef60401eeea39f75895ffc2bc89747ac4338a6daa0c3350491d0d025a /tmp/llvm-main-executable.patch40SLOP patch -p1 -d /tmp/mojo-llvm -i /tmp/llvm-main-executable.patch41# LLVM waits for a child with wait4 and a usage record, which Dolly's wait442# refuses: there it waits with waitpid and reports no statistics.43SOURCE /v0.1.4/dist/static/mojo/llvm-wait.patch bf70d879125c381e90275938d9533cba32d1c7f9ac82252a4d324c53e05195b1 /tmp/llvm-wait.patch44SLOP patch -p1 -d /tmp/mojo-llvm -i /tmp/llvm-wait.patch45# Mojo's own patch to LLVM's code generator (bazel/public-patches/llvm_source.bzl);46# its others change LLDB and the Bazel overlay, which are not built.47SOURCE /v0.1.4/dist/static/mojo/llvm-machinefunction-sti-ref-to-ptr.patch 6226c7dca544ff5ea5cf384bafecdfb49a4ef8f43d88c3996d310f25a42d6a53 /tmp/llvm-sti.patch48SLOP patch -p1 -d /tmp/mojo-llvm -i /tmp/llvm-sti.patch4950# Zstandard, with which LLVM's Support compresses: Mojo's precompiled51# packages are compressed.52SOURCE /v0.1.4/dist/static/mojo/zstd.tar 9a873f533780038d91f831cc4d24d6360bc745f2a2c1c6eaf62a2699c16cb133 /tmp/zstd.tar53SLOP tar -xf /tmp/zstd.tar -C /54FILE /tmp/zstd/Makefile55    .RECIPEPREFIX := >56    OBJECTS := $(patsubst %.c,%.o,$(wildcard lib/common/*.c lib/compress/*.c lib/decompress/*.c))57    libzstd.a: $(OBJECTS)58    >ar rcs $@ $^59    %.o: %.c60    >cc -O2 -c $< -o $@61SLOP CWD /tmp/zstd time make -j46263# As demos/llvm configures the seed's LLVM, with MLIR and Zstandard and64# without LLD. The default target is what Mojo compiles for when it is given65# none: a Dolly program, which its own target description turns into the66# wasm64-unknown-emscripten of Dolly's libc archives.67FILE /tmp/mojo-llvm/Dolly.cmake68    set(CMAKE_BUILD_TYPE Release CACHE STRING "")69    set(CMAKE_C_FLAGS "-std=gnu17" CACHE STRING "")70    set(CMAKE_CXX_FLAGS "-include endian.h -DCLANG_BUILD_STATIC" CACHE STRING "")71    set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON CACHE BOOL "")72    set(CMAKE_RULE_MESSAGES OFF CACHE BOOL "")73    set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "")74    set(LLVM_ENABLE_PROJECTS "clang;mlir" CACHE STRING "")75    set(LLVM_TARGETS_TO_BUILD WebAssembly CACHE STRING "")76    set(LLVM_HOST_TRIPLE wasm64-unknown-emscripten CACHE STRING "")77    set(LLVM_DEFAULT_TARGET_TRIPLE wasm64-unknown-dolly CACHE STRING "")78    set(LLVM_FORCE_VC_REVISION 4154b56ccc70220dca3fa1226fc8a24bafd90ac3 CACHE STRING "")79    set(LLVM_FORCE_VC_REPOSITORY https://github.com/llvm/llvm-project.git CACHE STRING "")80    foreach(option THREADS TERMINFO LIBEDIT LIBPFM ZLIB LIBXML2 CURL BINDINGS)81      set(LLVM_ENABLE_${option} OFF CACHE STRING "")82    endforeach()83    set(LLVM_ENABLE_ZSTD FORCE_ON CACHE STRING "")84    set(LLVM_USE_STATIC_ZSTD ON CACHE BOOL "")85    set(zstd_INCLUDE_DIR /tmp/zstd/lib CACHE PATH "")86    set(zstd_LIBRARY /tmp/zstd/libzstd.a CACHE FILEPATH "")87    set(zstd_STATIC_LIBRARY /tmp/zstd/libzstd.a CACHE FILEPATH "")88    foreach(option TESTS EXAMPLES BENCHMARKS DOCS)89      set(LLVM_INCLUDE_${option} OFF CACHE BOOL "")90    endforeach()91    set(LLVM_BUILD_LLVM_DYLIB OFF CACHE BOOL "")92    set(LLVM_LINK_LLVM_DYLIB OFF CACHE BOOL "")93    set(MLIR_ENABLE_BINDINGS_PYTHON OFF CACHE BOOL "")94    set(MLIR_ENABLE_EXECUTION_ENGINE OFF CACHE BOOL "")95SLOP time cmake -C /tmp/mojo-llvm/Dolly.cmake -S /tmp/mojo-llvm/llvm -B /tmp/mojo-llvm/build9697# The roots of what Mojo's BUILD.bazel files name of @llvm-project, MLIR's98# first; Make builds the TableGen tools and the libraries below them. Four jobs99# fit the 32-process cap; -k reports every failing unit, not only the first.100SLOP CWD /tmp/mojo-llvm/build time make -k -j4 MLIRCAPIIR MLIRCAPITransforms MLIRLspServerSupportLib \101  MLIRIndexToLLVM MLIRReconcileUnrealizedCasts MLIRBuiltinToLLVMIRTranslation MLIRLLVMToLLVMIRTranslation \102  MLIRNVVMToLLVMIRTranslation MLIRROCDLToLLVMIRTranslation clangBasic LLVMOrcDebugging LLVMMCJIT \103  LLVMWebAssemblyCodeGen LLVMWebAssemblyAsmParser LLVMWebAssemblyDisassembler104# The TableGen tools, the archives, and every header and TableGen source of105# the three projects with the configured and generated ones over them.106SLOP mkdir -p /opt/mojo-llvm/bin /opt/mojo-llvm/lib /opt/mojo-llvm/include107SLOP CWD /tmp/mojo-llvm/build slop -c 'cp bin/llvm-tblgen bin/mlir-tblgen /opt/mojo-llvm/bin && cp lib/*.a /tmp/zstd/libzstd.a /opt/mojo-llvm/lib'108SLOP CWD /tmp/mojo-llvm cp -R llvm/include/llvm llvm/include/llvm-c mlir/include/mlir mlir/include/mlir-c clang/include/clang clang/include/clang-c /opt/mojo-llvm/include109SLOP CWD /tmp/mojo-llvm/build slop -c 'for tree in include tools/mlir/include tools/clang/include; do for f in $(cd $tree && find . -name CMakeFiles -prune -o -type f \( -name "*.inc" -o -name "*.def" -o -name "*.h" \) -print); do mkdir -p "/opt/mojo-llvm/include/${f%/*}"; cp "$tree/$f" "/opt/mojo-llvm/include/$f"; done; done'110SLOP cp /tmp/mojo-llvm/llvm/LICENSE.TXT /opt/mojo-llvm/LICENSE.TXT111SLOP cp /tmp/zstd/LICENSE /opt/mojo-llvm/LICENSE.zstd112SLOP rm -rf /tmp/mojo-llvm /tmp/zstd /tmp/zstd.tar /tmp/llvm-host-triple.patch /tmp/llvm-main-executable.patch /tmp/llvm-wait.patch /tmp/llvm-sti.patch113114FOLDER /opt/mojo-llvm115SLOP /opt/mojo-llvm/bin/mlir-tblgen --version116117ENTRY /bin/foreground -i /bin/slop118