aboutsummaryrefslogtreecommitdiff
path: root/tools/build/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* tools/build: stage stdckdint.h's dependencies for non-FreeBSD hostsAbhijeet Sharma12 days1-0/+4
| | | | | | | | | | | | | | 37bd69d43c7 gave stdckdint.h two new includes, <sys/_visible.h> and <sys/ckdint.h>. Neither reaches a non-FreeBSD host: _visible.h is staged only under ${.MAKE.OS} == "FreeBSD" and ckdint.h is not staged at all, so the libc bootstrap fails on reallocarray.o when cross-building from macOS. Both headers are self-contained; stage them alongside stdckdint.h. Fixes: 37bd69d43c7 ("sys: Add sys/ckdint.h") Reviewed by: rpaulo, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58943
* build: Use -f when copying sourcesDag-Erling Smørgrav2026-08-131-2/+2
| | | | | | | | | | | If one of the source files we copy is non-writeable, cp will create a non-writeable copy. If the original is later modified, cp will fail to overwrite the copy since it is not writeable. Using cp -f ensures the copy always succeeds, as long as the object directory is writeable. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc.
* sys/cdefs.h: move __BEGIN_DECLS/__END_DECLS into a helper sys/_decls.hKonstantin Belousov2026-05-101-0/+1
| | | | | | | | | | | There are situations where nothing from sys/cdefs.h is needed except for the declaration braces. More, the other facilities from sys/cdefs.h might unnecessarly pollute the namespace. Reviewed by: markj, imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56889
* tools/build/Makefile: Always add md4.h to SYSINCSLexi Winter2026-04-091-2/+0
| | | | | | | | | | | | | Since libmd was added to the bootstrap, building main on stable/14 fails because of an incompatibility in its old md4.h. Fix this by always including md4.h in the bootstrap headers, instead of only doing so when building on a non-FreeBSD host. Fixes: 50de0bf50512 ("flua: Always build as a bootstrap tool") Reported by: olce Reviewed by: olce, kevans Sponsored by: https://www.patreon.com/bsdivy Differential Revision: https://reviews.freebsd.org/D56327
* cross-build: Provide mempcpy when building on macOSJessica Clarke2026-03-231-0/+3
| | | | | | | | | We could patch the tzcode config to not use it, but it's simple to provide an implementation of it and avoid spreading cross-build bootstrapping special cases. Fixes: ff2c98b30b57 ("tzcode: Update to 2026a") MFC after: 1 week
* build: add stddef.h to define ptraddr_t as requiredBrooks Davis2026-02-191-0/+3
| | | | | | | | | Effort: CHERI upstreaming Sponsored by: Innovate UK Reviewed by: kib Co-authored-by: Alfredo Mazzinghi <am2419@cl.cam.ac.uk> Co-authored-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Differential Revision: https://reviews.freebsd.org/D55308
* cross-build: Avoid adding <sys/cdefs.h> to SYSINCSAyrton Munoz2025-12-291-0/+2
| | | | | | | | | | | | | | | | Summary: The sys/cdefs.h in src is incompatible with glibc's sys/cdefs.h so cross-building broke when the former was added to SYSINCS in 1c9ff80f06. This commit adds a guard around that to only do that when building on FreeBSD. This should fix github CI. Test Plan: Ran buildkernel using tools/build/make.py on linux in github CI and locally on FreeBSD to double check nothing broke. Reviewed by: dim MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D54385
* tools.build: also add sys/_visible.h to SYSINCSDimitry Andric2025-12-261-0/+1
| | | | | | | | This is needed since sys/cdefs.h includes sys/_visible.h. Reported by: kib Fixes: 1c9ff80f0635 MFC after: 3 days
* tools.build: add sys/cdefs.h to SYSINCS, since lots of other headers use itDimitry Andric2025-12-261-0/+4
| | | | | | | | | This is needed to let the legacy stage compile against newer versions of sys/font.h, which transitively includes sys/cdefs.h, and requires the new __nonstring macro from it. Fixes: e2c93ed09f25 MFC after: 3 days
* Use install instead of cp to copy bootstrap toolsDag-Erling Smørgrav2025-11-151-1/+1
| | | | | | | | | | | | We need to preserve modification times on bootstrap tools, but `cp -p` also tries to preserve flags, which fails if OBJROOT is on NFS. A -N option was added to cp for this purpose, but trying to use that would break cross-building on hosts that don't have that option. The best remaining option is `install -p`, which we already assume is present. PR: 275030 Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D53751
* tools/build: Bring in stdckdint.h if neededMark Johnston2025-10-081-0/+4
| | | | | | | | | This is needed when bootstrapping libc, reallocarray.c and recallocarray.c include stdckdint.h now. Reviewed by: emaste Fixes: 7233893e9496 ("lib{c,openbsd}: use ckd_mul() for overflow checking in re(c)allocarray") Differential Revision: https://reviews.freebsd.org/D52932
* flua: support our flua modules in the bootstrap fluaKyle Evans2025-10-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This version builds every module into the flua binary itself, since all of the bootstrap tools are built -DNO_SHARED. As a result, we also cannot dlsym(), so we can't really discover the names of our newly builtin modules. Instead, just build out a linker set with all of our luaopen_*() functions to register everything up-front. Building in all of the modules isn't strictly necessary, but it means that we have an example of how to add a bootstrap module everywhere you go and one doesn't need to consider whether bootstrap flua can use a module when writing scripts. On my build machine, the consequence on our binary size is an increase from around 1.6M -> 1.9M, which isn't really that bad. .lua modules can install into their usual path below $WORLDTMP/legacy and we'll pick them up automagically by way of the ctor that sets up LUA_PATH early on. This re-lands bootstrap module support with a more sensible subset, and after having verified that it cross-builds fine on macOS and Linux -- we cannot do libfreebsd on !FreeBSD because it's more system header dependant. We also need to bootstrap libmd to bring in libhash, and libucl + libyaml. Reviewed by: bapt, emaste (both previous version) Differential Revision: https://reviews.freebsd.org/D51890
* Revert "flua: support our flua modules in the bootstrap flua"Kyle Evans2025-10-041-1/+0
| | | | | | | This reverts commit 1953a12ee2cde1afacb3e3f7612d89695c96e04f, because it cannot work at all on macOS without more work, at a minimum. We use linker sets for module discovery, but we don't have a version of this that works for mach-o at the moment.
* flua: support our flua modules in the bootstrap fluaKyle Evans2025-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | This version builds every module into the flua binary itself, since all of the bootstrap tools are built -DNO_SHARED. As a result, we also cannot dlsym(), so we can't really discover the names of our newly builtin modules. Instead, just build out a linker set with all of our luaopen_*() functions to register everything up-front. Building in all of the modules isn't strictly necessary, but it means that we have an example of how to add a bootstrap module everywhere you go and one doesn't need to consider whether bootstrap flua can use a module when writing scripts. On my build machine, the consequence on our binary size is an increase from around 1.6M -> 1.9M, which isn't really that bad. .lua modules can install into their usual path below $WORLDTMP/legacy and we'll pick them up automagically by way of the ctor that sets up LUA_PATH early on. Reviewed by: bapt, emaste Differential Revision: https://reviews.freebsd.org/D51890
* build: remove certctl requirement for host OpenSSL libs on macOSKyle Evans2025-08-191-0/+1
| | | | | | | | | | | | | | | | | | Some platforms, like macOS, do not expose headers for the system's libcrypto for public consumption. libcrypto is relatively heavy and needs to know, e.g., the host system's endianness, so we scope the build down to macOS where OpenSSL headers are known to not be present and we can be reasonably certain that most of the systems today that would be cross-building are little endian. We still don't bother if building WITHOUT_OPENSSL since the end result is expected to be used by OpenSSL, but perhaps we could revisit that independently in case one, e.g., brings their own implementation. Reported by: jrtc27 Reviewed by: jrtc27, ngie Fixes: c340ef28fd38 ("certctl: Reimplement in C") Differential Revision: https://reviews.freebsd.org/D51935
* tools/build: Provide extra headers on non-FreeBSDJessica Clarke2025-06-161-0/+6
| | | | | | These will be needed by future changes to continue to allow building makefs as a bootstrap tool on Linux and macOS. This also requires defining __sbintime_t in our cross-build sys/_types.
* Makefile: Hook MIT KRB5 into the buildCy Schubert2025-06-161-0/+64
| | | | | | | | | | | Add tests for MK_MITKRB5. If "yes" build MIT KRB5. If "no" build Heimdal. The default is MK_MITKRB5 = no, added by "krb5: Add build plumbing". At some point we will change the default to MK_MITKRB5 = yes. A ports exp-run will need to be successfully run first. Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D50815
* cross-build: Provide real fflagstostr/strtofflags on LinuxJessica Clarke2025-05-061-2/+5
| | | | | | | | | | | | | | | | | | | | | These are used by mtree and makefs, so in order to be able to set schg on /var/empty in METALOG and set schg on various files and directories in the resulting disk images we need to have a real implementation rather than always giving no flags. Ideally mtree wouldn't rely on round-tripping the textual flags field via the "native" flags encoding using these functions, and ideally makefs wouldn't rely on the "native" flags encoding matching FreeBSD's, but in practice macOS's schg is the same and we can pretend Linux has the same. This fixes Linux-produced disk images lacking schg on any files or directories, and Linux-produced distribution tarballs lacking schg on /var/empty (note though that they do set schg on files, as install already preserves file flags on Linux). Reviewed by: emaste, markj Differential Revision: https://reviews.freebsd.org/D50080
* nv: Add <sys/_nv.h> header for nvlist_t declarationJohn Baldwin2024-12-301-0/+1
| | | | | | | | | | This can be useful for headers that wish to use nvlist_t pointers in a structure or function argument without pulling in all of the headers from <sys/nv.h>. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48229
* cross-build: fix missing <sys/md4.h> the proper wayKyle Evans2024-10-181-0/+4
| | | | | | | | | | Add it to tools/build/Makefile with a short note of where it's needed, rather than hamfistedly copying it into the tools/build hierarchy. Reported by: jrtc27 Reviewed by: jrtc27 Fixes: aad507854efd13c43 ("Fix the cross-build after recent commits") Differential Revision: https://reviews.freebsd.org/D46854
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* build: only inspect the first word of toolchain toolsKyle Evans2024-01-091-3/+3
| | | | | | | | | | | CC/CXX/CPP/LD may all have arguments supplied in various circumstances, which break the logic here. We only need to determine which of these tools we're expecting to invoke from PATH, which just requires examination of the first word. Limit our scope to exactly that. Patch suggested by: jrtc27 Reviewed by: imp, jrtc27 Differential Revision: https://reviews.freebsd.org/D43372
* Make kldxref a bootstrap tool and use unconditionallyJessica Clarke2023-12-131-0/+2
| | | | | | | | | | Now that kldxref is a generic cross tool and can be built on non-FreeBSD we can bootstrap it during the build and thus remove the condition for whether it exists. We also need to make sure to add it to the METALOG for -DNO_ROOT builds. Reviewed by: brooks, imp Differential Revision: https://reviews.freebsd.org/D43051
* tools/build: Provide sys/linker_set.h when cross-buildingJessica Clarke2023-12-131-0/+4
| | | | | | | | | | This is needed for kldxref, which will shortly become a bootstrap tool. Linux can use the same one as FreeBSD (provided the cross-building sys/cdefs.h is augmented appropriately), whilst macOS needs its own Mach-O-specific implementation. Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D43049
* tools/build: Support building with glibc 2.38Andrew Turner2023-10-201-2/+8
| | | | | | | | | Ubuntu 23.10 uses glibc 2.38. This adds strlcpy and strlcmp so we need to remove them from the cross build environment. Reviewed by: jrtc27 (earlier version), arichardson Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42303
* Add support for host32 for DIRDEPS_BUILDSimon J. Gerraty2023-09-231-0/+2
| | | | | | | | | | | Allow building 32bit libs for host. Move CFLAGS additions from local.sys.dirdeps.mk (which is too early and impacts CFLAGS defaults) to local.sys.mk Reviewed by: stevek Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D41946
* kbdcontrol: Support building as a bootstrap tool on old and non-FreeBSDJessica Clarke2023-08-221-0/+2
| | | | | | | | | | | | | | | | | Systems that predate 971bac5ace7a ("kbd: consolidate kb interfaces (phase one)") cannot build kbdcontrol since kbdelays and kbrates moved to sys/kbio.h. Moreover, on non-FreeBSD, it requires all kinds of ioctls and sysctls that are highly FreeBSD-specific to build, but we use it as a bootstrap tool to generate the keymaps used by some kernels (LINT ones in particular). Thus, when bootstrapping kbdcontrol, disable everything that's not needed for that singular use, and use the in-tree kbio.h to get the definitions of the necessary structures. This allows KBDMUX_DFLT_KEYMAP, UKBD_DFLT_KEYMAP and ATKBD_DFLT_KEYMAP to be enabled when building on non-FreeBSD, and thus LINT kernels. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D41541
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* tools/build: Work around broken Clang FreeBSD resource dir logic pre-13Jessica Clarke2023-07-311-5/+16
| | | | | | | | | | | | | | Prior to Clang 13 (e.g. in the Clang 11 present in 13.0-RELEASE), the resource directory logic for FreeBSD was broken and would not resolve symlinks, meaning symlinks would only work if in a directory next to the containing lib directory. Therefore we cannot even use a symlink for worldtmp, we have to make a wrapper script that execs the real binary via an absolute path. Reported by: markj Reviewed by: markj Fixes: 65f28f63a73d ("tools/build: Create toolchain symlinks for non-absolute compiler/linker") Differential Revision: https://reviews.freebsd.org/D41238
* tools/build: Create toolchain symlinks for non-absolute compiler/linkerJessica Clarke2023-07-271-1/+26
| | | | | | | | | If any of the toolchain variables are not absolute then we need to create a symlink in WORLDTMP/legacy/bin in order to make them available during a BUILD_WITH_STRICT_TMPPATH build. Reviewed by: brooks, jhb Differential Revision: https://reviews.freebsd.org/D41188
* tools/build: Tidy up whitespace and comments, and delete duplicate codeJessica Clarke2023-07-251-8/+8
| | | | We already handle the make and bmake links unconditionally above.
* We do not need readpassphrase from opensshSimon J. Gerraty2023-04-241-11/+0
| | | | | | When building tar for linux, just disable HAVE_READPASSPHRASE in config_freebsd.h and libarchive will provide for readpassphrase Otherwise the two conflict.
* Enable building tar for non-FreeBSD hostSimon J. Gerraty2023-04-241-0/+12
| | | | | | | | | | | | | For DIRDEPS_BUILD we need Makefile.depend.options to force libegacy to be built on older FreeBSD and non-FreeBSD hosts. Add readpassphrase to libegacy to avoid the need for libbsd on Linux src.opts.mk disable TESTS for host if MK_host_egacy is yes Reviewed by: imp Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39766
* Allow tools/build to work for DIRDEPS_BUILDSimon J. Gerraty2023-04-221-0/+4
| | | | | | | | | | | | | We want to be able to build some host tools for non-FreeBSD hosts without building more than we need. The DIRDEPS_BUILD lets us do that. We use the pseudo MACHINE "host" when building for the host - deal with that when setting _host_arch. Reviewed by: jrtc27 Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39751
* cross-build: Add secure_getenv() for MacOS cross buildsMark Johnston2023-03-301-2/+8
| | | | | | Reviewed by: arichardson Fixes: 68ca8363c7a1 ("libc: Use secure_getenv(3) where appropriate") Differential Revision: https://reviews.freebsd.org/D39295
* libcasper: Move helper libraries from /lib/casper to /lib.John Baldwin2023-03-291-1/+0
| | | | | | | | | These libraries are linked to directly by applications rather than opened at runtime via dlopen(). Discussed with: oshogbo Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D39245
* build: glibc on Linux defines explicit_bzero in <string.h>.John Baldwin2023-03-271-1/+1
| | | | | | | | | | | | | | Don't install strings.h on such systems. The local prototype doesn't match the native Linux one when built as C++ breaking the build of config(8) as a bootstrap tool on some Linux systems. If the missing prototype becomes a problem in the future, tools/build/cross-build/include/linux/strings.h can be patched to add it. Reviewed by: imp, emaste Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D39289
* tools/build: Hide spurious errors if sys/stat.h does not existEd Maste2023-03-021-0/+4
| | | | | | Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38757
* tools/build: Always bootstrap (sys/)bitstring.hBrooks Davis2023-01-091-5/+5
| | | | | | | | | | | | Older, supported FreeBSD versions lack bit_ntest() so hoist the boostrap installation out of the OS!=FreeBSD case and always install it. A more precise criteria is possible, but would add little value. This fixes bootstrapping makefs as a build tool on 13.1. Reviewed by: jrtc27, emaste Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D37951
* tools/build: Provide fls* when cross-building on LinuxJessica Clarke2022-08-181-0/+2
| | | | | | | | | flsll is needed for makefs's new ZFS support, and the others are added for completeness. Reviewed by: emaste, arichardson Fixes: 240afd8c1fcc ("makefs: Add ZFS support") Differential Revision: https://reviews.freebsd.org/D36134
* tools/build: Provide FreeBSD's bitstring API when cross-buildingJessica Clarke2022-08-181-0/+9
| | | | | | | | | This is needed for building makefs as a cross-tool since the ZFS code uses these APIs. Reviewed by: emaste Fixes: 240afd8c1fcc ("makefs: Add ZFS support") Differential Revision: https://reviews.freebsd.org/D36133
* namespace nv names, version libnv and libnvpair library symbolsReid Linnemann2022-07-211-1/+1
| | | | | | | | | | | | | | | libnv and libnvpair have aliased symbols, and as a result a single process which dlopens a shared object that is dynamically linked to libnv and another to libnvpair will wind up with a single set of resolved symbols for those in conflict. A source file also cannot include both libnv and libnvpair headers because of aliased identifiers. To resolve the situation, libnv types and functions are namespaced via nv_namespace.h, and libnv symbols are versioned. The msgio functions are not namespaced or exported as they are not part of the external API. Reviewed by: kevans Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D35261
* ctf: Import ctf.h from OpenBSDMark Johnston2022-03-071-0/+1
| | | | | | | | | | | | | | | | | Use it instead of the existing ctf.h from OpenSolaris. This makes it easier to use CTF in the core kernel, and to extend the CTF format to support wider type IDs. The imported ctf.h is modified to depend only on _types.h, and also to provide macros which use the "parent" bit of a type ID to refer to types in a parent CTF container. No functional change intended. Reviewed by: Domagoj Stolfa, emaste MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34358
* tools/build: Fix the error message used when a host tool is not presentMark Johnston2022-01-261-1/+1
| | | | MFC after: 1 week
* Remove quotes around Makefile .error/.warn/.info stringsEd Maste2022-01-221-1/+1
| | | | | | | | The text after .error et al is emitted verbatim. Reviewed by: sjg Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33904
* tools: Also create ${WORLDTMP}/legacy/usr/libdata/pkgonfigJessica Clarke2021-12-061-0/+1
| | | | | | | | | | This is needed for the next commit which will make libz a bootstrap library as needed by ctfconvert. We could just not install the .pc file as it's not needed, but that requires a per-library hack every time a bootstrap library gains a .pc file, so this keeps bootstrap-tools looking as much like a normal build as possible. MFC after: 1 week
* Fix cross-building on Linux/aarch64Kyle Evans2021-10-181-0/+3
| | | | | | | | | | Add necessary bits to detect ELF format on Linux/aarch64; note that Linux calls it aarch64 where we would typically call it arm64 (uname -m) Reviewed by: arichardson, emaste, imp Sponsored by: Ampere Computing LLC Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D32542
* Support bootstrapping from Linux/ppc*Justin Hibbits2021-09-041-0/+2
|
* truncate(1): Fix cross-build CI failure due to missing fspacectlKa Ho Ng2021-08-241-0/+5
| | | | | | | | For other platforms, fspacectl(2) is absent. This commit masks out the calls to fspacectl(2) and replace them with a ENODEV errno. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31619
* Fix BUILD_WITH_STRICT_TMPPATH build after adding time to ITOOLSAlex Richardson2021-08-021-2/+2
| | | | | This is needed after bbd16236e986ef1b0e1da37c9c8a7f9dd2d63b5d (and 99feb137f5f66f903bba816c1d98ced2a92bef12).