mergerfs/mkdocs/docs/setup/build.md

106 lines
2.9 KiB
Markdown
Raw Normal View History

# Build
**NOTE:** Prebuilt packages can be found at and recommended for most
users: https://github.com/trapexit/mergerfs/releases
**NOTE:** Only tagged releases are supported. `master` and other
branches should be considered works in progress.
First, get the code from [github](https://github.com/trapexit/mergerfs).
```
$ git clone https://github.com/trapexit/mergerfs.git
$ # or
$ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.tar.gz
```
## Debian / Ubuntu
```
$ cd mergerfs
$ sudo buildtools/install-build-pkgs
$ make deb
$ sudo dpkg -i ../mergerfs_<version>_<arch>.deb
```
Debian package compilation uses the available CPUs by default. To limit
parallelism, set `DEB_BUILD_OPTIONS`:
```
$ DEB_BUILD_OPTIONS=parallel=4 make deb
```
## RHEL / CentOS / Rocky / Fedora
```
$ su -
# cd mergerfs
# buildtools/install-build-pkgs
# make rpm
# rpm -i rpmbuild/RPMS/<arch>/mergerfs-<version>.<arch>.rpm
```
Fedora 45 rejects unsigned RPMs by default. When installing a locally
built RPM that you trust, pass `--nosignature` to `rpm` to allow that
unsigned package.
Rocky Linux container builds activate newer GCC Toolsets when available.
Both the Rocky 10 `/usr/lib/gcc-toolset/<version>-env.source` activation
script and the older `/opt/rh/gcc-toolset-<version>/enable` layout are
supported.
## Container packages
Package build targets are defined in `buildtools/containerfiles/`, with
the standard distro targets listed in `buildtools/target-containers.txt`.
Debian release builds target Debian 12 and 13. Other targets include
Fedora 45 on `amd64` and `arm64`, and Ubuntu 26.10 on `amd64`, `arm64`,
`armhf`, and `riscv64`. Foreign-architecture builds require QEMU/binfmt
support.
## Generic Linux
Have git, g++ or clang, make, python installed.
```
$ cd mergerfs
$ make
$ sudo make install
```
## FreeBSD
Have git, g++ or clang, gmake, python installed.
```
$ cd mergerfs
$ gmake
$ gmake install # as root
```
## Build options
```
$ make help
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
usage: make ARG
USE_XATTR=0 - build program without xattrs functionality
STATIC=1 - build static binary
LTO=1 - build with link time optimization
SANITIZE=1 - build with sanitizers (address,undefined,leak)
SANITIZE=list - build with custom sanitizers (comma separated)
CLEANUP=1 - cleanup images between release build process
PKGDIR=/dir/ - location for release build pkgs
GITREF=gitref - gitref to use for release builds
```
build: make NDEBUG=1 and make release build the release profile - The RELEASE=1 profile replaced 2.42.0's NDEBUG=1 one, but the static archives and the container image still build with NDEBUG=1, which therefore selected the debug profile: -O0 -g3 with assertions on. Both Makefiles accept NDEBUG=1 again, as -O3 -DNDEBUG, and the debug profile defines DEBUG. The vendored libfuse follows the same profile as mergerfs. - make release first removes the objects, binaries and stamp under build/ and cleans vendored/libfuse, because make only compares timestamps: objects from an earlier debug build were otherwise linked into the release binary unchanged. Packages and build reports in build/pkgs are kept; TEST_release_pkg_preservation checks both. - make release also builds preload.so. It takes the release defines through its own PRELOAD_CPPFLAGS: the global CPPFLAGS add _FILE_OFFSET_BITS=64, which would hide its unsuffixed open/openat/fopen/creat interposers. - mergerfs.spec builds the release target, as debian/rules does. The distribution's CFLAGS, CXXFLAGS and LDFLAGS still apply. - The release driver mounts the repository with ":ro,z", not ":ro:z", which Podman read as an extra field instead of a mount option. TEST_release_metadata runs the driver against a fake podman and checks the volume argument and the build report. - Remove release-installer: build-release has no installer target. - make help printed a literal "\n" where /bin/sh is bash. Match the build.md transcript to its output and document the profiles. Performance: static archives and the container image go from -O0 with assertions back to optimized builds, now -O3 -DNDEBUG (2.42.0: -O2 -DNDEBUG). RPM packages keep the distribution's -O2 and no longer evaluate assertions. A plain make is unoptimized, as before.
2026-11-29 23:10:53 -05:00
A plain `make` builds the debug profile (`-O0 -g3`, assertions
enabled). `make release` builds the binaries and `preload.so` with
`-O3` and assertions disabled. It rebuilds the objects, binaries and
vendored libfuse so debug objects cannot end up in the release build.
It leaves packages and reports in `build/pkgs/` (or your `PKGDIR`)
alone. `make clean` still removes the entire `build/` directory.
`make NDEBUG=1` selects the same release flags without cleaning; the
static package builds use it together with `LTO=1 STATIC=1`.