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.5/demos/cmake/Dollyfile-cmake-build a187c93a214051fbafe68c92538f26f28d6cc36c2a0461369f067be8f3f1873b15# LLVM's CMake requires a Python 3 interpreter.16INSTALL /v0.1.5/demos/python/Dollyfile-python 5909c3743aee62ae30b4bc1bfc3b0b221ac5458e2ed4dfb4b6767d8b072fc9ea17REQUIRES 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.5/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.5/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.5/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# Mojo's own patch to LLVM's code generator (bazel/public-patches/llvm_source.bzl);42# its others change LLDB and the Bazel overlay, which are not built.43SOURCE /v0.1.5/dist/static/mojo/llvm-machinefunction-sti-ref-to-ptr.patch 6226c7dca544ff5ea5cf384bafecdfb49a4ef8f43d88c3996d310f25a42d6a53 /tmp/llvm-sti.patch44SLOP patch -p1 -d /tmp/mojo-llvm -i /tmp/llvm-sti.patch4546# Zstandard, with which LLVM's Support compresses: Mojo's precompiled47# packages are compressed.48SOURCE /v0.1.5/dist/static/mojo/zstd.tar 9a873f533780038d91f831cc4d24d6360bc745f2a2c1c6eaf62a2699c16cb133 /tmp/zstd.tar49SLOP tar -xf /tmp/zstd.tar -C /50FILE /tmp/zstd/Makefile51    .RECIPEPREFIX := >52    OBJECTS := $(patsubst %.c,%.o,$(wildcard lib/common/*.c lib/compress/*.c lib/decompress/*.c))53    libzstd.a: $(OBJECTS)54    >ar rcs $@ $^55    %.o: %.c56    >cc -O2 -c $< -o $@57SLOP CWD /tmp/zstd time make -j45859# As demos/llvm configures the seed's LLVM, with MLIR and Zstandard and60# without LLD. The default target is what Mojo compiles for when it is given61# none: a Dolly program, which its own target description turns into the62# wasm64-unknown-emscripten of Dolly's libc archives.63FILE /tmp/mojo-llvm/Dolly.cmake64    set(CMAKE_BUILD_TYPE Release CACHE STRING "")65    set(CMAKE_C_FLAGS "-std=gnu17" CACHE STRING "")66    set(CMAKE_CXX_FLAGS "-include endian.h -DCLANG_BUILD_STATIC" CACHE STRING "")67    set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON CACHE BOOL "")68    set(CMAKE_RULE_MESSAGES OFF CACHE BOOL "")69    set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "")70    set(LLVM_ENABLE_PROJECTS "clang;mlir" CACHE STRING "")71    set(LLVM_TARGETS_TO_BUILD WebAssembly CACHE STRING "")72    set(LLVM_HOST_TRIPLE wasm64-unknown-emscripten CACHE STRING "")73    set(LLVM_DEFAULT_TARGET_TRIPLE wasm64-unknown-dolly CACHE STRING "")74    set(LLVM_FORCE_VC_REVISION 4154b56ccc70220dca3fa1226fc8a24bafd90ac3 CACHE STRING "")75    set(LLVM_FORCE_VC_REPOSITORY https://github.com/llvm/llvm-project.git CACHE STRING "")76    foreach(option THREADS TERMINFO LIBEDIT LIBPFM ZLIB LIBXML2 CURL BINDINGS)77      set(LLVM_ENABLE_${option} OFF CACHE STRING "")78    endforeach()79    set(LLVM_ENABLE_ZSTD FORCE_ON CACHE STRING "")80    set(LLVM_USE_STATIC_ZSTD ON CACHE BOOL "")81    set(zstd_INCLUDE_DIR /tmp/zstd/lib CACHE PATH "")82    set(zstd_LIBRARY /tmp/zstd/libzstd.a CACHE FILEPATH "")83    set(zstd_STATIC_LIBRARY /tmp/zstd/libzstd.a CACHE FILEPATH "")84    foreach(option TESTS EXAMPLES BENCHMARKS DOCS)85      set(LLVM_INCLUDE_${option} OFF CACHE BOOL "")86    endforeach()87    set(LLVM_BUILD_LLVM_DYLIB OFF CACHE BOOL "")88    set(LLVM_LINK_LLVM_DYLIB OFF CACHE BOOL "")89    set(MLIR_ENABLE_BINDINGS_PYTHON OFF CACHE BOOL "")90    set(MLIR_ENABLE_EXECUTION_ENGINE OFF CACHE BOOL "")91SLOP time cmake -C /tmp/mojo-llvm/Dolly.cmake -S /tmp/mojo-llvm/llvm -B /tmp/mojo-llvm/build9293# The roots of what Mojo's BUILD.bazel files name of @llvm-project, MLIR's94# first; Make builds the TableGen tools and the libraries below them. Four jobs95# fit the 32-process cap; -k reports every failing unit, not only the first.96SLOP CWD /tmp/mojo-llvm/build time make -k -j4 MLIRCAPIIR MLIRCAPITransforms MLIRLspServerSupportLib \97  MLIRIndexToLLVM MLIRReconcileUnrealizedCasts MLIRBuiltinToLLVMIRTranslation MLIRLLVMToLLVMIRTranslation \98  MLIRNVVMToLLVMIRTranslation MLIRROCDLToLLVMIRTranslation clangBasic LLVMOrcDebugging LLVMMCJIT \99  LLVMWebAssemblyCodeGen LLVMWebAssemblyAsmParser LLVMWebAssemblyDisassembler100# The TableGen tools, the archives, and every header and TableGen source of101# the three projects with the configured and generated ones over them.102SLOP mkdir -p /opt/mojo-llvm/bin /opt/mojo-llvm/lib /opt/mojo-llvm/include103SLOP 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'104SLOP 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/include105SLOP 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'106SLOP cp /tmp/mojo-llvm/llvm/LICENSE.TXT /opt/mojo-llvm/LICENSE.TXT107SLOP cp /tmp/zstd/LICENSE /opt/mojo-llvm/LICENSE.zstd108SLOP rm -rf /tmp/mojo-llvm /tmp/zstd /tmp/zstd.tar /tmp/llvm-host-triple.patch /tmp/llvm-main-executable.patch /tmp/llvm-sti.patch109110FOLDER /opt/mojo-llvm111SLOP /opt/mojo-llvm/bin/mlir-tblgen --version112113ENTRY /bin/foreground -i /bin/slop114