From nobody Mon Oct 02 16:00:01 2023 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rzlyn5Sbbz4wDMS for ; Mon, 2 Oct 2023 16:00:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rzlyn4whmz4J0g; Mon, 2 Oct 2023 16:00:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696262401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oR3iFaVVUw5I+phgTTenPx9HzyhYYfu586lAX/Nf2uo=; b=vlNiu+e+DMtD/VhQ7H2bOYguW/VLrWKFZ1UHozf9+6zfES6mqqbYICmz7R8NsKWSAswiIo eOf/4SE9GarCEvH2YptSALAGj0Pw8JiZvuyBw9A59UZ9BlxPvD7KXMN1eTCahGn5K9kVlp UVJbAyBuQNe9F5XiTl58gVD2H6jd2kzAY+1iASr6zUDCNfngsNpMK1XUKNZj6tM6udrvSL OaeG31aZs7VuRVRrL0Sp5BoNeWhcfJh414m7uGm/sWyze0379SPyMUCQcEtoC+jJ+IaFbo pAF7m6m+oBUOBoa0dR0Z+O23LZ3Y6lYOe6825K0B+qOx3Z3jdU+VIuTg0rI9PQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696262401; a=rsa-sha256; cv=none; b=F8vSl4yiYB3St2N/oPWg2XbVzp/AM2K58KnHlNUQDZ2xeq8hGg8lWb4EFahm1Rhgrxftg0 lK8RHZV4DKBuHTrge9scQc2XT8IOQYgQU5V5o3/myMjY0IW4j5raZixx7V3wqR0bkhhXAq JerOIOBTM2iQRE48BxPMHh7tdwfNEveOLcTOyRuo/r8bRfM5eXHs1QJIoq1xdNhgtWadfC dewOysekuIVRY+jpX/tn34baS6nmBgpHdpHSty37K0dgtuO/bF4hEkETTWoFPcTI8zUuDk im11uggWRtPuyIWKXRyJ5QAxjJD8Zc9cpYW9bMXbJCVdClBN+o2wmDcaMBBS6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696262401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oR3iFaVVUw5I+phgTTenPx9HzyhYYfu586lAX/Nf2uo=; b=wnMjZZ2EDirbKxQBcWwQ5AJ3wxmkIoZowj8jQj+ql0iiJ3tcrOlSW44/pPOIq4U+d3UOcV dt8rQZws0doFlpWbthW0gEyl+f/rJrDvS8xbXVN552BiLufjFJ4tpaDoVBXQcx71USmdT0 PQ296vUbVSP6R4fdkCasuP06CZcJwYYztCQ5fBr+Eiim5Z2D3o+Uk71EYfWXfwXv5Glnxp vfG66GqK8JI4jHYV1RVx69TyiSWsrx+ToWx5RGcmzavLzsyeyJue0KktA+FzcbkL5NX2tT RC1Cm/IwF2P/DbCJzy/xA1nUbiGxKlvl8KH/ASe3MmCYZFKbQhsN1ZAkoLsGiQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rzlyn40MLz3dN; Mon, 2 Oct 2023 16:00:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 392G01n1037255; Mon, 2 Oct 2023 16:00:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 392G016V037246; Mon, 2 Oct 2023 16:00:01 GMT (envelope-from git) Date: Mon, 2 Oct 2023 16:00:01 GMT Message-Id: <202310021600.392G016V037246@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 681ef79f8f - main - handbook/cutting-edge/: Document building FreeBSD on macOS and Linux List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 681ef79f8f0bf080592fe3ebc196b5a2e4f5feaa Auto-Submitted: auto-generated The branch main has been updated by 0mp: URL: https://cgit.FreeBSD.org/doc/commit/?id=681ef79f8f0bf080592fe3ebc196b5a2e4f5feaa commit 681ef79f8f0bf080592fe3ebc196b5a2e4f5feaa Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2023-10-02 15:54:52 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2023-10-02 15:54:52 +0000 handbook/cutting-edge/: Document building FreeBSD on macOS and Linux Based on https://wiki.freebsd.org/BuildingOnNonFreeBSD. --- .../en/books/handbook/cutting-edge/_index.adoc | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/documentation/content/en/books/handbook/cutting-edge/_index.adoc b/documentation/content/en/books/handbook/cutting-edge/_index.adoc index cf06f6df60..07e97a396f 100644 --- a/documentation/content/en/books/handbook/cutting-edge/_index.adoc +++ b/documentation/content/en/books/handbook/cutting-edge/_index.adoc @@ -1141,3 +1141,48 @@ set `DISTDIR` to a common shared directory that is writable by whichever user `r Each machine should set `WRKDIRPREFIX` to a local build directory, if ports are to be built locally. Alternately, if the build system is to build and distribute packages to the machines in the build set, set `PACKAGES` on the build system to a directory similar to `DISTDIR`. + +[[building-on-non-freebsd-hosts]] +== Building on non-FreeBSD Hosts + +Historically, building FreeBSD required a FreeBSD host. +Nowadays, the FreeBSD can be build on Linux distributions and macOS. + +To build FreeBSD on non-FreeBSD hosts, the recommendation is to use the `tools/build/make.py` script. +This script acts as a wrapper around `bmake`, which is the make implementation used by FreeBSD. +It ensures that the necessary tooling, including the actual FreeBSD's man:make[1], is bootstrapped and that the build environment is properly configured. +In particular, it sets the external toolchain variables, such as `XCC`, `XLD`, and others. +Additionally, the script can pass any additional command arguments, such as `-j 4` for parallel builds or specific make targets, to `bmake`. + +[NOTE] +==== +A recent version of `bmake` can be ued instead of the `tools/build/make.py` script as well. +In that case, however, required environment variables need to be set manually (the easiest way to obtain a list of them is by running `tools/build/make.py --debug`). +==== + +Otherwise, the list of prerequisites for building FreeBSD is rather short. +In fact, it boils down to installing a couple of dependencies. + +On macOS, the only dependency LLVM. +The necessary dependencies can be installed with package manager (e.g., link:https://brew.sh/[Homebrew]): + +[source,shell] +.... +brew install llvm +.... + +On a Linux distributions, install link:https://clang.llvm.org/[Clang] version 10.0 or newer and the headers for libarchive and libbz2 (often packaged as libarchive-dev and libbz2-dev). + +Once the dependencies are installed, the host should be able to build FreeBSD. + +For example, the following `tools/build/make.py` invocation builds the world: + +[source,shell] +.... +MAKEOBJDIRPREFIX=/tmp tools/build/make.py -j 8 TARGET=arm64 TARGET_ARCH=aarch64 buildworld +.... + +It builds the world for target `aarch64:arm64` on 8 CPUs and uses [.filename]#/tmp# for object files. +Note that the variables `MAKEOBJDIRPREFIX`, `TARGET`, and `TARGET_ARCH` are mandatory when building on non-FreeBSD hosts. + +Refer to man:arch[7] and man:build[7] for more details.