### Install Certbot and Configure File Permissions for Ziglang.org Source: https://github.com/ziglang/infra/blob/master/website-server-setup.md Installs the Certbot Nginx plugin, sets ownership and group write permissions for the web root directory, and adds the CI user to the www-data group for server setup. ```bash apt install python3-certbot-nginx chown -R www-data: /var/www/html/ chmod -R g+w /var/www/html/ usermod -a -G www-data ci ``` -------------------------------- ### Install Linux Headers for Multiple Architectures Source: https://github.com/ziglang/infra/blob/master/libc-update/linux.md Installs Linux headers for various architectures using Make. Requires build-essential and rsync. The SHELL and ARCH variables are set for each target architecture. ```bash make SHELL=/bin/sh ARCH=arc INSTALL_HDR_PATH=dest/arc headers_install make SHELL=/bin/sh ARCH=arm INSTALL_HDR_PATH=dest/arm headers_install make SHELL=/bin/sh ARCH=arm64 INSTALL_HDR_PATH=dest/arm64 headers_install make SHELL=/bin/sh ARCH=csky INSTALL_HDR_PATH=dest/csky headers_install make SHELL=/bin/sh ARCH=hexagon INSTALL_HDR_PATH=dest/hexagon headers_install make SHELL=/bin/sh ARCH=loongarch INSTALL_HDR_PATH=dest/loongarch headers_install make SHELL=/bin/sh ARCH=m68k INSTALL_HDR_PATH=dest/m68k headers_install make SHELL=/bin/sh ARCH=mips INSTALL_HDR_PATH=dest/mips headers_install make SHELL=/bin/sh ARCH=powerpc INSTALL_HDR_PATH=dest/powerpc headers_install make SHELL=/bin/sh ARCH=riscv INSTALL_HDR_PATH=dest/riscv headers_install make SHELL=/bin/sh ARCH=s390 INSTALL_HDR_PATH=dest/s390 headers_install make SHELL=/bin/sh ARCH=sparc INSTALL_HDR_PATH=dest/sparc headers_install make SHELL=/bin/sh ARCH=x86 INSTALL_HDR_PATH=dest/x86 headers_install make SHELL=/bin/sh ARCH=xtensa INSTALL_HDR_PATH=dest/xtensa headers_install ``` -------------------------------- ### Setup Forgejo CI Runner for Zig CI Source: https://context7.com/ziglang/infra/llms.txt This guide outlines the setup process for a Forgejo CI Runner on various operating systems, including Linux, FreeBSD, NetBSD, OpenBSD, Windows, and macOS. It covers registering the runner with Codeberg, configuring environment variables, generating and customizing the runner's configuration file, and setting up system services for automatic startup. ```bash # Prerequisites: git, node 20+ in PATH # Download runner from https://codeberg.org/ziglang/runner/releases/latest # Register runner with Codeberg ./forgejo-runner register \ --no-interactive \ --instance https://codeberg.org \ --token $REGISTRATION_TOKEN \ --name $(hostname) \ --labels self-hosted:host,riscv64-linux:host # Create environment file cat > .env << 'EOF' PATH="/home/ci/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" EOF # Generate and customize config ./forgejo-runner generate-config > config.yaml # Edit config.yaml: # log.level: debug # log.job_level: debug # runner.capacity: 4 # concurrent jobs # runner.envs: { ZSF_MAX_RSS: "8589934592" } # 8GB # runner.timeout: 24h # runner.shutdown_timeout: 6h # Linux systemd service (/etc/systemd/system/forgejo-runner.service) cat > /etc/systemd/system/forgejo-runner.service << 'EOF' [Unit] Description=Forgejo Runner Documentation=https://forgejo.org/docs/latest/admin/actions/ Wants=network-online.target After=network-online.target [Service] ExecStart=/home/ci/forgejo-runner daemon --config /home/ci/config.yaml User=ci WorkingDirectory=/home/ci Restart=on-failure TimeoutSec=0 RestartSec=10 [Install] WantedBy=multi-user.target EOF sudo systemctl daemon-reload sudo systemctl enable forgejo-runner.service sudo systemctl start forgejo-runner.service ``` -------------------------------- ### Build and Install libc for amd64 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command sequence builds and installs the C standard library (libc) for the `amd64` architecture into a sysroot. It utilizes `make.py` with specific build flags and overrides to target libc components. This process can be time-consuming. ```bash mkdir -p sysroot/amd64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=amd64 TARGET_ARCH=amd64 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=amd64 TARGET_ARCH=amd64 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/amd64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=amd64 TARGET_ARCH=amd64 ``` -------------------------------- ### Build libc for Multiple Architectures with Zig Source: https://github.com/ziglang/infra/blob/master/libc-update/netbsd.md These commands build and install the C library (libc) for various NetBSD architectures using Zig. The '-U' flag enables cross-compilation, '-j $(nproc)' uses all available CPU cores for faster building, '-m ' specifies the target architecture, '-T obj/tools/' sets the toolchain directory, and '-D obj/sysroot/' sets the sysroot directory. 'cleandir tools zig cleandir' ensures a clean build process including the Zig build step. ```bash ./build.sh -U -j $(nproc) -m alpha -T obj/tools/alpha -D obj/sysroot/alpha cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m amd64 -T obj/tools/amd64 -D obj/sysroot/amd64 cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbarm64-el -T obj/tools/evbarm64 -D obj/sysroot/evbarm64 cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbarmv7-el -T obj/tools/evbarmv7 -D obj/sysroot/evbarmv7 cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbarmv7hf-el -T obj/tools/evbarmv7hf -D obj/sysroot/evbarmv7hf cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbppc -T obj/tools/evbppc -D obj/sysroot/evbppc cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbppc -V MKSOFTFLOAT=yes -T obj/tools/evbppcsf -D obj/sysroot/evbppcsf cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbsh3-el -T obj/tools/evbsh3 -D obj/sysroot/evbsh3 cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m evbsh3-el -V MKSOFTFLOAT=yes -T obj/tools/evbsh3sf -D obj/sysroot/evbsh3sf cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m hppa -T obj/tools/hppa -D obj/sysroot/hppa cleandir tools zig cleandir ./build.sh -U -j $(nproc) -m i386 -T obj/tools/i386 -D obj/sysroot/i386 cleandir tools zig cleandir ``` -------------------------------- ### Prepare sysroot for i386 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command prepares the sysroot directory for the `i386` architecture. It is a prerequisite for building and installing libc for this architecture, though the installation commands are not shown in this snippet. ```bash mkdir -p sysroot/i386 ``` -------------------------------- ### Configure Forgejo Runner as a Service (Windows WinSW) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md This snippet demonstrates how to set up the Forgejo Runner as a Windows service using WinSW. It includes the XML configuration file for the service and the command-line instructions to install and start it. ```xml forgejo-runner Forgejo Runner Forgejo Runner C:\Users\ci\forgejo-runner.exe daemon --config C:\Users\ci\config.yaml C:\Users\ci ci cipassword true Automatic ``` ```shell forgejo-service.exe install forgejo-service.exe start ``` -------------------------------- ### Build and Install libc for armv7 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command sequence builds and installs the C standard library (libc) for the `armv7` architecture into a sysroot. It uses `make.py` with specific build flags and overrides to target libc components. This process can be time-consuming. ```bash mkdir -p sysroot/armv7 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=arm TARGET_ARCH=armv7 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=arm TARGET_ARCH=armv7 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/armv7 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=arm TARGET_ARCH=armv7 ``` -------------------------------- ### Build and Install libc for aarch64 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command sequence builds and installs the C standard library (libc) for the `aarch64` architecture into a sysroot. It uses `make.py` with specific build flags and overrides to target libc components. This process can be time-consuming. ```bash mkdir -p sysroot/aarch64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=arm64 TARGET_ARCH=aarch64 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=arm64 TARGET_ARCH=aarch64 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/aarch64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=arm64 TARGET_ARCH=aarch64 ``` -------------------------------- ### Build, Install, and Clean FreeBSD libc for i386 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This script builds, installs, and cleans the FreeBSD libc for the i386 architecture. It utilizes a Python script from the tools/build directory and specifies build targets, source configuration, and output directories. Dependencies include the `make` utility and the `tools/build/make.py` script. ```bash MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=i386 TARGET_ARCH=i386 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=i386 TARGET_ARCH=i386 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/i386 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=i386 TARGET_ARCH=i386 ``` -------------------------------- ### Cross-Compile Musl for Multiple Architectures with Zig Source: https://github.com/ziglang/infra/blob/master/libc-update/musl.md This section demonstrates the process of cross-compiling Musl for various architectures using the previously defined Zig C compiler wrappers. It involves cleaning the build, configuring Musl with specific target and compiler settings (including `-rtlib=none`), building with parallel jobs, and installing the compiled library. ```shell make distclean && \ ./configure --prefix=$(pwd)/build-all/aarch64 --target=aarch64-linux-musl --disable-static AR="zig ar" CC="zcc-aarch64" RANLIB="zig ranlib" CFLAGS="-rtlib=none" && \ make -j$(nproc) && \ make install make distclean && \ ./configure --prefix=$(pwd)/build-all/arm --target=arm-linux-musleabi --disable-static AR="zig ar" CC="zcc-arm" RANLIB="zig ranlib" CFLAGS="-rtlib=none" && \ make -j$(nproc) && \ make install make distclean && \ ./configure --prefix=$(pwd)/build-all/hexagon --target=hexagon-linux-musl --disable-static AR="zig ar" CC="zcc-hexagon" RANLIB="zig ranlib" CFLAGS="-rtlib=none" && \ make -j$(nproc) && \ make install make distclean && \ ./configure --prefix=$(pwd)/build-all/i386 --target=i386-linux-musl --disable-static AR="zig ar" CC="zcc-i386" RANLIB="zig ranlib" CFLAGS="-rtlib=none" && \ make -j$(nproc) && \ make install make distclean && \ ``` -------------------------------- ### Set Up FreeBSD Build Environment Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command sequence prepares the build environment by cleaning and creating necessary directories and files for the FreeBSD build process. It ensures a fresh build environment. ```bash rm -rf build && mkdir build rm -rf sysroot && mkdir sysroot rm -f src.conf && touch src.conf ``` -------------------------------- ### Build, Install, and Clean FreeBSD libc for powerpc64 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This script builds, installs, and cleans the FreeBSD libc for the powerpc64 architecture. It's similar to the i386 build process but targets different architectures and creates a dedicated sysroot directory. Dependencies include the `make` utility and the `tools/build/make.py` script. ```bash mkdir -p sysroot/powerpc64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=powerpc TARGET_ARCH=powerpc64 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=powerpc TARGET_ARCH=powerpc64 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/powerpc64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=powerpc TARGET_ARCH=powerpc64 ``` -------------------------------- ### Enable and Start Forgejo Runner Daemon (FreeBSD/NetBSD) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md This snippet shows the commands to enable and start the Forgejo Runner as a daemon on FreeBSD or NetBSD systems using the rc.conf and service commands. ```shell echo forgejo_runner=YES | sudo tee /etc/rc.conf.d/forgejo_runner service forgejo_runner start ``` -------------------------------- ### Clone and Build musl Headers for Multiple Architectures (Shell) Source: https://github.com/ziglang/infra/blob/master/libc-update/musl.md This script clones the musl repository, checks out a specific version, and then proceeds to build and install headers for a wide range of architectures. It cleans the object files before each build and specifies the destination directory and architecture. ```sh git clone https://codeberg.org/alexrp/musl.git cd musl git checkout zig-1.2.5 # the branch of the version to update to rm -rf obj/ && make DESTDIR=build-all/aarch64 install-headers ARCH=aarch64 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/arm install-headers ARCH=arm prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/hexagon install-headers ARCH=hexagon prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/i386 install-headers ARCH=i386 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/loongarch64 install-headers ARCH=loongarch64 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/m68k install-headers ARCH=m68k prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/mips install-headers ARCH=mips prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/mips64 install-headers ARCH=mips64 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/mipsn32 install-headers ARCH=mipsn32 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/powerpc install-headers ARCH=powerpc prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/powerpc64 install-headers ARCH=powerpc64 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/riscv32 install-headers ARCH=riscv32 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/riscv64 install-headers ARCH=riscv64 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/s390x install-headers ARCH=s390x prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/x32 install-headers ARCH=x32 prefix=/usr/local/musl rm -rf obj/ && make DESTDIR=build-all/x86_64 install-headers ARCH=x86_64 prefix=/usr/local/musl ``` -------------------------------- ### Manage Forgejo Runner with service (Bash) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md Commands to enable and start the Forgejo runner service on FreeBSD using the service command and rc.conf.d configuration. ```bash echo forgejo_runner_enable=YES | sudo tee /etc/rc.conf.d/forgejo_runner service forgejo_runner start ``` -------------------------------- ### Bootstrap bmake and List Targets Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command bootstraps the `bmake` build tool and lists all supported targets for the current FreeBSD release. It's a crucial step for understanding the build system's capabilities. ```bash MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py --bootstrap-toolchain targets ``` -------------------------------- ### List Supported Architectures Source: https://github.com/ziglang/infra/blob/master/libc-update/netbsd.md This command lists all the architectures supported by the current NetBSD release. It's a preliminary step to identify which architectures to build the libc for. ```bash ./build.sh list-arch ``` -------------------------------- ### Build and Install Libraries (Makefile) Source: https://github.com/ziglang/infra/blob/master/libc-update/openbsd.md This snippet details the process of building and installing various libraries, including libcompiler_rt, csu, libc, libm, librthread, and libutil. It utilizes make commands with specific environment variables and object directory configurations for cross-compilation. ```makefile + export MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} BSDOBJDIR=${CROSSDIR}/usr/obj BUILD_CLANG=${BUILD_CLANG}; \ + (cd ${.CURDIR}/gnu/lib/libcompiler_rt; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} all; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} ${MAKE} install; \ + ); \ + (cd ${.CURDIR}/lib; \ + for lib in csu libc libm librthread libutil; do \ + (cd $$lib; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} all; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} ${MAKE} install; \ + ); \ + done; \ + ); \ + (cd ${.CURDIR}/gnu/lib/libexecinfo; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} all; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} ${MAKE} install; \ + ); \ + (cd ${.CURDIR}/libexec/ld.so; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} SKIPDIR="ldconfig ldd" ${MAKE} all; \ + eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} SKIPDIR="ldconfig ldd" ${MAKE} install; \ + ); ``` -------------------------------- ### Build, Install, and Clean FreeBSD libc for riscv64 Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This script builds, installs, and cleans the FreeBSD libc for the riscv64 architecture. It follows the same pattern as other architecture builds, ensuring the correct sysroot and build configurations are used. Dependencies include the `make` utility and the `tools/build/make.py` script. ```bash mkdir -p sysroot/riscv64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py buildworld --bootstrap-toolchain -j$(nproc) TARGET=riscv TARGET_ARCH=riscv64 SRCCONF=$PWD/src.conf NO_SHARE=1 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py installworld --bootstrap-toolchain -j$(nproc) TARGET=riscv TARGET_ARCH=riscv64 SRCCONF=$PWD/src.conf NO_SHARE=1 NO_LIBS=1 SUBDIR_OVERRIDE="include lib/libsys lib/libc lib/libdl lib/libelf lib/libexecinfo lib/librt lib/libstdthreads lib/libthr lib/libutil lib/msun libexec/rtld-elf" NO_ROOT=1 DESTDIR=$PWD/sysroot/riscv64 && \ MAKEOBJDIRPREFIX=$PWD/build tools/build/make.py cleanworld --bootstrap-toolchain -j$(nproc) TARGET=riscv TARGET_ARCH=riscv64 ``` -------------------------------- ### Manage Forgejo Runner with systemctl (Bash) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md Commands to manage the Forgejo runner service using systemctl. This includes reloading the systemd daemon, enabling the service to start on boot, and starting the service immediately. ```bash sudo systemctl daemon-reload sudo systemctl enable forgejo-runner.service sudo systemctl start forgejo-runner.service ``` -------------------------------- ### Copy libSystem TBD File Source: https://github.com/ziglang/infra/blob/master/libc-update/darwin.md Copies the 'libSystem.tbd' file from the specified SDK path to the Zig libc darwin directory. ```shell cp $SDK_PATH/usr/lib/libSystem.tbd lib/libc/darwin/libSystem.tbd ``` -------------------------------- ### Updating Clang Include Directory Source: https://github.com/ziglang/infra/blob/master/llvm-upgrade.md Removes the existing include directory for Clang within the Zig project and copies the updated version from a new LLVM installation. This ensures Zig uses the latest Clang headers. The `$LLVM_INSTALL_PREFIX` and `$VER` variables should point to the correct LLVM installation and version. ```shell rm -rf lib/include cp -r $LLVM_INSTALL_PREFIX/lib/clang/$VER/include/ lib/ ``` -------------------------------- ### Set libc runtimes directory Source: https://github.com/ziglang/infra/blob/master/building-libcs.md Sets the environment variable LIBC_RUNTIMES to specify the installation directory for compiled libc runtimes. This is a prerequisite for the subsequent build steps. ```bash export LIBC_RUNTIMES=$HOME/.local/libc ``` -------------------------------- ### Fetch macOS Headers with Zig Source: https://github.com/ziglang/infra/blob/master/libc-update/darwin.md Fetches macOS headers from the latest system-wide SDK using a Zig script. Optionally specify a sysroot path for non-standard SDKs. ```zig zig run tools/fetch_them_macos_headers.zig --sysroot $SDK_PATH ``` -------------------------------- ### Clone Linux Stable Tree Source: https://github.com/ziglang/infra/blob/master/libc-update/linux.md Clones the Linux stable kernel source tree from the official repository. Requires Git to be installed. ```bash git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git ``` -------------------------------- ### Link Node.js Binaries (Bash) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md Creates symbolic links for Node.js, npm, and npx executables in a local bin directory. This makes them available in the runner's PATH, which is often required for actions like 'actions/checkout'. ```bash mkdir -p ~/local/bin ln -s ~/deps/node-v21.7.2-linux-riscv64/bin/node ~/local/bin/node ln -s ~/deps/node-v21.7.2-linux-riscv64/bin/npm ~/local/bin/npm ln -s ~/deps/node-v21.7.2-linux-riscv64/bin/npx ~/local/bin/npx ``` -------------------------------- ### Update FreeBSD libc Startup Code using Zig Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This command runs a Zig program (`tools/update_freebsd_libc.zig`) to update the libc startup code. It takes the path to the FreeBSD source directory and the current directory as arguments. Inspecting the diff is necessary to preserve Zig patches. ```bash zig run tools/update_freebsd_libc.zig -- ../freebsd-src . ``` -------------------------------- ### Update NetBSD libc Startup Code Source: https://github.com/ziglang/infra/blob/master/libc-update/netbsd.md This Zig tool, `tools/update_netbsd_libc.zig`, is used to update the libc startup code. It requires the path to the NetBSD source directory and the current Zig project directory as arguments. It's important to inspect the diff and preserve any Zig-specific patches. ```shell zig run tools/update_netbsd_libc.zig -- ../netbsd-src . ``` -------------------------------- ### Clone FreeBSD Source and Checkout Release Source: https://github.com/ziglang/infra/blob/master/libc-update/freebsd.md This snippet demonstrates how to clone the FreeBSD source code repository and checkout a specific release version. It requires `git` to be installed. ```bash git clone https://github.com/freebsd/freebsd-src.git cd freebsd-src git checkout release/14.2.0 ``` -------------------------------- ### Update Linux Headers using Zig Source: https://github.com/ziglang/infra/blob/master/libc-update/linux.md Updates Linux headers by running a Zig script. It requires the previously installed headers and specifies an output directory. The script searches for headers in a specified path. ```bash rm -rf lib/libc/include/*-linux-any zig run tools/update-linux-headers.zig -- --search-path ~/Downloads/linux/dest --out lib/libc/include ``` -------------------------------- ### Nginx Server Block Configuration for Ziglang.org Source: https://github.com/ziglang/infra/blob/master/website-server-setup.md Defines the Nginx server block for ziglang.org, listening on port 80, setting the document root, enabling gzip compression for various file types, and configuring MIME types for efficient content delivery. ```nginx server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html; server_name ziglang.org; if ($http_user_agent ~* (facebook)) { return 403; } gzip on; gzip_types application/javascript application/json application/x-tar application/xml application/xml+rss text/css text/html text/javascript text/plain text/xml ; gunzip on; gzip_static always; location / { } types { text/html html htm shtml; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/javascript js; application/atom+xml atom; application/rss+xml rss; text/mathml mml; text/plain txt; text/vnd.sun.j2me.app-descriptor jad; text/vnd.wap.wml wml; text/x-component htc; image/png png; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; image/svg+xml svg svgz; image/webp webp; application/font-woff woff; application/java-archive jar war ear; application/json json; application/mac-binhex40 hqx; application/msword doc; application/pdf pdf; application/postscript ps eps ai; application/rtf rtf; application/vnd.apple.mpegurl m3u8; application/vnd.ms-excel xls; application/vnd.ms-fontobject eot; application/vnd.ms-powerpoint ppt; application/vnd.wap.wmlc wmlc; application/vnd.google-earth.kml+xml kml; application/vnd.google-earth.kmz kmz; application/wasm wasm; application/x-7z-compressed 7z; application/x-cocoa cco; application/x-java-archive-diff jardiff; application/x-java-jnlp-file jnlp; application/x-makeself run; application/x-perl pl pm; application/x-pilot prc pdb; application/x-rar-compressed rar; application/x-redhat-package-manager rpm; application/x-sea sea; application/x-shockwave-flash swf; application/x-stuffit sit; application/x-tcl tcl tk; application/x-x509-ca-cert der pem crt; application/x-xpinstall xpi; application/xhtml+xml xhtml; application/xspf+xml xspf; application/zip zip; application/octet-stream bin exe dll; application/octet-stream deb; application/octet-stream dmg; application/octet-stream iso img; application/octet-stream msi msp msm; application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; audio/midi mid midi kar; audio/mpeg mp3; audio/ogg ogg; audio/x-m4a m4a; audio/x-realaudio ra; ``` -------------------------------- ### Configure Nginx for ziglang.org Source: https://context7.com/ziglang/infra/llms.txt This snippet demonstrates how to create and enable an Nginx server block configuration for the ziglang.org domain. It sets up basic HTTP serving, enables gzip compression for static assets, and configures the site to be enabled and restart Nginx. Finally, it initiates SSL certificate setup using Certbot. ```bash cat > /etc/nginx/sites-available/ziglang.org << 'EOF' server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html; server_name ziglang.org; gzip on; gzip_types application/javascript application/json application/x-tar application/xml text/css text/html text/javascript text/plain; gunzip on; gzip_static always; location / {} } EOF cd /etc/nginx/sites-enabled ln -s /etc/nginx/sites-available/ziglang.org default systemctl restart nginx certbot --nginx -d ziglang.org ``` -------------------------------- ### Test glibc Integration with Zig Build Source: https://github.com/ziglang/infra/blob/master/libc-update/glibc.md This command demonstrates how to test the updated glibc integration within a Zig build using QEMU. It requires the glibc build artifacts to be available at the specified path. ```shell zig build test -fqemu --libc-runtimes /foo/glibc/multi/install/glibcs ``` -------------------------------- ### Configure Nginx for Zig Website (ziglang.org) Source: https://context7.com/ziglang/infra/llms.txt This configuration sets up an Nginx web server to host the ziglang.org website. It includes instructions for installing necessary packages, setting file ownership and permissions for the web root directory, and adding a user to the 'www-data' group for access. ```bash # Install dependencies and configure permissions apt install python3-certbot-nginx chown -R www-data: /var/www/html/ chmod -R g+w /var/www/html/ usermod -a -G www-data ci ``` -------------------------------- ### Build Linux glibc Source: https://github.com/ziglang/infra/blob/master/building-libcs.md Builds multiple versions of the GNU C Library (glibc) for various architectures. This process involves cloning the glibc repository, checking out a specific tag, and using helper scripts to compile host libraries, compilers, and the glibc itself. It can take a significant amount of time. ```bash git clone https://sourceware.org/git/glibc.git cd glibc git checkout $(git describe $(git rev-list -n 1 --tags='glibc-?.??')) mkdir build cd build ../scripts/build-many-glibcs.py . checkout pushd src/glibc git checkout $(git describe $(git rev-list -n 1 --tags='glibc-?.??')) popd ../scripts/build-many-glibcs.py . host-libraries -j $(nproc) ../scripts/build-many-glibcs.py . compilers -j $(nproc) ../scripts/build-many-glibcs.py . glibcs -j $(nproc) mkdir -p $LIBC_RUNTIMES mv install/glibcs/* $LIBC_RUNTIMES ``` -------------------------------- ### Merge Architecture Headers Source: https://github.com/ziglang/infra/blob/master/libc-update/darwin.md Merges 'aarch64' and 'x86_64' architecture-specific headers into a universal directory for macOS. ```shell mkdir headers/any-macos-any rsync -vaHP headers/aarch64-macos.$LATEST_MACOS_VERSION-none/. headers/any-macos-any/. rsync -vaHP headers/x86_64-macos.$LATEST_MACOS_VERSION-none/. headers/any-macos-any/. ``` -------------------------------- ### Clean Up Header Fetching Directory Source: https://github.com/ziglang/infra/blob/master/libc-update/darwin.md Removes the temporary 'headers' directory created during the header fetching process. ```shell rm -rf headers ``` -------------------------------- ### Replace Vendored Darwin Headers Source: https://github.com/ziglang/infra/blob/master/libc-update/darwin.md Removes the existing Zig vendored Darwin headers and replaces them with the newly fetched and merged universal headers. ```shell rm -rf lib/libc/include/any-macos-any mv headers/any-macos-any lib/libc/include/any-macos-any ``` -------------------------------- ### Configure Forgejo Runner as a Service (OpenBSD rc.d) Source: https://github.com/ziglang/infra/blob/master/forgejo-runner.md This snippet shows how to configure the Forgejo Runner as a service using OpenBSD's rc.d system. It involves creating a service script in /etc/rc.d/ and configuring login class limits in /etc/login.conf.d/. ```shell #!/bin/ksh daemon="/home/ci/forgejo-runner daemon --config /home/ci/config.yaml" daemon_user="ci" daemon_execdir="/home/ci" rc_bg="YES" . /etc/rc.d/rc.subr rc_cmd $1 ``` ```text forgejo_runner:\ :datasize=infinity:\ :maxproc=infinity:\ :openfiles=infinity:\ :stacksize=infinity:\ :tc=default: ``` ```shell rcctl enable forgejo_runner rcctl start forgejo_runner ``` -------------------------------- ### Build Linux musl Source: https://github.com/ziglang/infra/blob/master/building-libcs.md Compiles the musl C library for a wide range of Linux architectures using Zig's cross-compilation tools. This involves cloning the musl repository, checking out a specific branch, creating wrapper scripts for 'zig cc', and then configuring and building musl for each target. The process is considerably faster than building glibc. ```bash git clone https://codeberg.org/alexrp/musl.git cd musl # Tracks the latest musl release with Zig's musl patches. git checkout zig-1.2.5 mkdir build cd build for triple in arm-linux-musleabi \ arm-linux-musleabihf \ armeb-linux-musleabi \ armeb-linux-musleabihf \ thumb-linux-musleabi \ thumb-linux-musleabihf \ thumbeb-linux-musleabi \ thumbeb-linux-musleabihf \ aarch64-linux-musl \ aarch64_be-linux-musl \ hexagon-linux-musl \ loongarch64-linux-musl \ loongarch64-linux-muslsf \ mips-linux-musleabi \ mips-linux-musleabihf \ mipsel-linux-musleabi \ mipsel-linux-musleabihf \ mips64-linux-muslabi64 \ mips64-linux-muslabin32 \ mips64el-linux-muslabi64 \ mips64el-linux-muslabin32 \ powerpc-linux-musleabi \ powerpc-linux-musleabihf \ powerpc64-linux-musl \ powerpc64le-linux-musl \ riscv32-linux-musl \ riscv64-linux-musl \ s390x-linux-musl \ x86-linux-musl \ x86_64-linux-musl; do echo -e '#!/bin/sh\nzig cc -target '$triple' $@' > zcc-$triple done chmod +x zcc-* for zcc in $(echo zcc-* | sort); do prefix=$LIBC_RUNTIMES/${zcc#zcc-} target=${zcc#zcc-} target=${target/x86-/i386-} target=${target/thumb-/arm-} target=${target/thumbeb-/armeb-} ../configure --prefix=$prefix --bindir=$prefix/usr/bin --includedir=$prefix/usr/include --libdir=$prefix/usr/lib --syslibdir=$prefix/lib --target=$target --enable-debug AR="zig ar" CC=$PWD/$zcc RANLIB="zig ranlib" && \ rm -f conf*-*-*.o && \ make clean && \ make -j $(nproc) && \ make install || break done ```