aboutsummaryrefslogtreecommitdiff
path: root/tools/build/cross-build
Commit message (Collapse)AuthorAgeFilesLines
* cdefs.h: Introduce __nonstring attributeAlex Richardson2025-12-161-0/+8
| | | | | | | | | | This attribute can be used to annotate char arrays that are not supposed to be terminated with a NUL char and is needed to silence clang's new -Wunterminated-string-initialization warning. The name matches linuxkpi. Reviewed by: emaste, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D52565
* cross-build: Define __GNUC_PREREQ__ in cdefs.hMark Johnston2025-10-081-0/+10
| | | | | | | | | This is required when including stdckdint.h and doesn't seem to be provided by older clang. Reviewed by: emaste Fixes: 7233893e9496 ("lib{c,openbsd}: use ckd_mul() for overflow checking in re(c)allocarray") Differential Revision: https://reviews.freebsd.org/D52933
* fix cross build after expand_number type changeBrooks Davis2025-08-032-2/+2
| | | | Fixes: 2e0caa7c7e14 ("libutil: Really fix expand_number(3)")
* cross-build: Add a <endian.h> wrapper for macOSJohn Baldwin2025-07-291-0/+7
| | | | | | This is required to build libkrb5support. Fixes: 7e35117eb07f ("Makefile: Hook MIT KRB5 into the build")
* cross-build: provide exterr.h and sys/exterrvar.h for non-FreeBSD hostsKonstantin Belousov2025-07-102-0/+20
| | | | | | | | | with enough glue to make libc/gen/err.c compilable. Reported by: jhb Reviewed by: jhb, jrtc27 Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D51217
* tools/build: Provide extra headers on non-FreeBSDJessica Clarke2025-06-161-0/+3
| | | | | | 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.
* cross-build: Provide real fflagstostr/strtofflags on LinuxJessica Clarke2025-05-062-62/+20
| | | | | | | | | | | | | | | | | | | | | 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
* cross-build: Workaround system-provided strchrnul on macOS 15.4+John Baldwin2025-04-281-2/+5
| | | | | | | | | | | | | macOS added a native strchrnul in 15.4. There is not an easy way to detect it at compile time, so use a macro to rename our local inline version to avoid conflicts while also forcing its use during bootstrap. The local version can be removed once macOS versions older than 15.4 are no longer supported as build hosts. Co-authored by: jrtc27 Reported by: kib Reviewed by: jrtc27 Differential Revision: https://reviews.freebsd.org/D49893
* cross-build: fix missing <sys/md4.h> the proper wayKyle Evans2024-10-181-91/+0
| | | | | | | | | | 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
* tools/build/cross-build: Don't include sys/uio.h from linux limits.hJessica Clarke2024-10-181-4/+1
| | | | | | | | | | | This creates a circular dependency for OpenZFS's libspl in sys/uio.h, and it shouldn't be needed since the system limits.h already defines IOV_MAX, so delete it, and unconditionally assert that to be the case. Otherwise the re-include of libspl's sys/uio.h tries to use PAGESIZE before it has been defined by OpenZFS's own sys/param.h. Fixes: 7a7741af18d6 ("zfs: merge openzfs/zfs@b10992582") MFC after: 1 week
* Fix the cross-build after recent commitsKyle Evans2024-09-301-0/+91
| | | | | | | | | | | - Provide a sys/md4.h in the cross-build environment to fix bootstrap of libmd. - flua now exposes WTRAPPED which isn't incredibly common- make it conditional, we probably won't be using it in any bootstrap context any time soon. Fixes: 442e0975ee4b3 ("Consolidate md4 implementations written in C") Fixes: c2caf3b3313fe ("flua: posix: add more useful functions [...]")
* cross-build: fix fake_sysctl/tzsetupVal Packett2024-09-061-0/+1
| | | | | | | | | | The error was always returned, even after handling the sysctl, breaking installworld under Linux. Sponsored by: https://www.patreon.com/valpackett Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1376
* cross-build: Define DEFFILEMODE and ALLPERMS if not definedWarner Losh2024-07-251-0/+8
| | | | | | | | | | GLIBC defines these, but MUSL does not. FreeBSD's bootstrap code uses these defines, so define them if they aren't yet defined. Co-authored-by: Val Packett <val@packett.cool> Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1066 Differential Revision: https://reviews.freebsd.org/D45375
* cross-build: progname.c is used only on linux, so no ifdefs neededWarner Losh2024-07-251-2/+0
| | | | | | | | | | | The logic in the makefile ensures this is only present on Linux, so no ifdef is needed. I overlooked comments to the effect in the original pull request somehow. Fixes: 0e03402139da Suggested by: arichards, jrtc27 Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D45374
* cross-build: Move fcntl.h workaround to Linux specific fileWarner Losh2024-07-251-0/+7
| | | | | | | | | | | Move the cdefs.h inclusion to the Linux specific file. Either place will work, but it makes more sense to do it in the Linux specific file since it's a Linux specific workaround. Fixes: 4300e053618f Suggested by: arichards, jrtc27 Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D45373
* tools/build: Unbreak cross build by providing stub ssp/ssp.hJessica Clarke2024-07-171-0/+34
| | | | | | | We build arc4random.c on non-FreeBSD, which now wants the header for __ssp_real. Fixes: d0b7445904f5 ("include: ssp: fortify <stdlib.h>")
* Remove residual blank line at start of MakefileWarner Losh2024-07-153-3/+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
* cross-build: This is not glibc specific, but Linux specificWarner Losh2024-05-261-2/+2
| | | | | | | | | Neither glibc nor musl define these interfaces, so provide them for all Linux builds. Sponsored by: Netflix Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45355
* cross-build: Define __*int*_t and include sys/cdefs.hWarner Losh2024-05-261-0/+21
| | | | | | | | | | | | | | | FreeBSD assumes that sys/types.h includes sys/cdefs.h, so add it here. FreeBSD also needs __*int*_t defined for software we bootstrap (a lot of it). GLIBC defines these, but musl does not, so we have to define them here, even though it looks backwards. There's no good #define to key off of, so use !defined GLIBC since on Linux defacto there's only two libc implementations. Co-authored-by: Val Packett <val@packett.cool> Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1066 Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45354
* cross-build: string.h uses mode_t, so we need sys/types.hWarner Losh2024-05-261-1/+1
| | | | | | | | | | | | | string.h defines strmode with a mode_t argument. POSIX states that one must include sys/types.h to get mode_t, so do that here. This makes musl happier. We know that sys/types.h will include sys/cdefs.h, so just replace the latter with the former. Co-authored-by: Val Packett <val@packett.cool> Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1066 Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45353
* cross-build: Include sys/types.h from sys/param.hWarner Losh2024-05-261-0/+2
| | | | | | | | | | | | | FreeBSD has a style(9) enforced assumption that sys/param.h includes sys/types.h. However, Linux under musl doesn't do this so go ahead and explicitly include it here. It won't hurt on the glibc systems, and helps musl. Co-authored-by: Val Packett <val@packett.cool> Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1066 Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45352
* cross-tools: Document a rather bizarre looking constructWarner Losh2024-05-261-0/+7
| | | | | | | | | | | | | | On Linux, stddef.h will define __size_t to something when size_t is defined. On FreeBSD, __size_t is an actual typedef which we need for other parts of the system. If __size_t isn't defined, that tells us we need to define the fallback __size_t typedef (if it is defined, then we can't easily redefine it without issues because glob.h will define it to something different than stddef.h defines it). Add a comment to this effect. Sponsored by: Netflix Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45350
* cross: Move Solaris API64 defines to commonVal Packett2024-05-242-2/+3
| | | | | | | | | off64_t is needed for both Linux (musl) and MacOS, so move them to the common area. Somehow glibc provides the definition, but defining it doesn't hurt and hels in the musl case. Reviewed by: allanjude, jrtc27 Pull Request: https://github.com/freebsd/freebsd-src/pull/1066
* tools/build: Provide sys/linker_set.h when cross-buildingJessica Clarke2023-12-132-0/+153
| | | | | | | | | | 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: Automated cleanup of cdefs and other formattingWarner Losh2023-11-273-3/+2
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* tools/build: Support building with glibc 2.38Andrew Turner2023-10-201-0/+3
| | | | | | | | | 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
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-167-7/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1668-136/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* We do not need readpassphrase from opensshSimon J. Gerraty2023-04-241-4/+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/+4
| | | | | | | | | | | | | 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
* cross-build: Add secure_getenv() for MacOS cross buildsMark Johnston2023-03-302-0/+17
| | | | | | Reviewed by: arichardson Fixes: 68ca8363c7a1 ("libc: Use secure_getenv(3) where appropriate") Differential Revision: https://reviews.freebsd.org/D39295
* Revert "Fix cross-build support for Ubuntu 16.04"Jose Luis Duran2023-03-071-9/+1
| | | | | | | | | | | | | | | | | | | | This reverts commit d6327ae8c11b73765f100981baca49166b558b70. Before version 2.25, glibc's unistd.h would define the POSIX subset of getopt.h by defining __need_getopt, including getopt.h (which would disable the header guard) and then undefining it so later including getopt.h explicitly would define the extensions. However, we wrap getopt, and so the wrapper's #pragma once breaks that. Thus getopt.h was included before the real unistd.h to ensure we get all the extensions. However, with clang 12 that causes problems where we get a function mismatch (since getopt can throw exceptions). If we include it after unistd.h, it will get the full definitions since glibc no longer does the subsetting thing. This will result in matching definitions and fix clang 12. Reviewed by: imp, jrtc27 (OK'd on irc) Pull Request: https://github.com/freebsd/freebsd-src/pull/668
* Revert "tools/build: Unbreak bmake bootstrap on Linux"Jessica Clarke2023-01-291-8/+0
| | | | | | | Now that make.py no longer has the described hack on Linux we can drop this ugly workaround. This reverts commit fba998a3d897e6297baca74068e4ec1db7adaeec.
* tools/build: Unbreak bmake bootstrap on LinuxJessica Clarke2022-08-221-0/+8
| | | | | | | | | | | | Currently make.py has a hack to add the cross-build headers to the include search path when bootstrapping bmake on Linux (but not macOS). This is a bit of an abuse of these headers, and e9ba1fd5eda2 was not prepared for this, since sys/bitcount.h won't exist in that instance (it gets copied into WORLDTMP during the legacy build). Work around this until we can wean the bmake bootstrap off using these headers by not including sys/bitcount.h when it doesn't exist. Fixes: e9ba1fd5eda2 ("tools/build: Provide FreeBSD's bitstring API when cross-building")
* tools/build: Provide fls* when cross-building on LinuxJessica Clarke2022-08-181-0/+40
| | | | | | | | | 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/+4
| | | | | | | | | 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
* cross-build: Add comment missing from 9e5b0d9eac5bJessica Clarke2021-12-151-0/+16
| | | | | | | | | Whilst the commit message documented some of the details, I had intended to include this comment in the actual header, but failed to amend the commit properly. Fixes: 9e5b0d9eac5b ("cross-build: Fix bmake bootstrap with glibc 2.34") MFC after: 1 week
* cross-build: Fix bmake bootstrap with glibc 2.34Jessica Clarke2021-12-151-0/+31
| | | | | | | | | | | | | As of glibc 2.34, our unistd.h wrapper's inclusion of stdlib.h exposes fragility in glibc's sys/wait.h and corresponding part of stdlib.h, leading to "error: use of undeclared identifier 'WNOHANG'" and similar errors when bootstrapping bmake. Work around this by wrapping sys/wait.h to force stdlib.h's inclusion first before it's implicitly included during the problematic window in sys/wait.h. MFC after: 1 week
* cross-build: Add __weak_symbol definition for libdwarf bootstrapJessica Clarke2021-12-151-0/+3
| | | | | Fixes: 3aa0bc89c6a1 ("libdwarf: Add a weak uncompress() symbol") MFC after: 1 week
* cross-build: Provide _PASSWORD_EFMT1 for libcrypt on LinuxJessica Clarke2021-12-071-0/+4
| | | | | | | | Linux's pwd.h does not define _PASSWORD_EFMT1 (macOS's does), so we need to define it in order to be able to bootstrap libcrypt (crypt-des.c uses it) on non-FreeBSD, which will be done in a subsequent commit. MFC after: 1 week
* cross-build: Define crypt_data in unistd.h for libcryptJessica Clarke2021-12-071-0/+5
| | | | | | | | This is where it's defined in the base system, so is where libcrypt expects it to exist when being built, and will be needed when being bootstrapped in a subsequent commit. MFC after: 1 week
* cross-build: fix some redeclaration warnings during bootstrapAlex Richardson2021-10-115-13/+6
| | | | MFC after: 3 days
* cross-build: Remove redundant lines.Warner Losh2021-10-102-4/+0
| | | | | | | | | There's two identical gid_from_group lines in a row. We only need one. Ditto for uid_from_user(). Sponsored by: Netflix Reviewed by: bapt, jrtc27 Differential Revision: https://reviews.freebsd.org/D32442
* Fix cross-builds after 4e5d32a445f90d37966cd6de571978551654e3f3Jose Luis Duran2021-09-071-0/+19
| | | | | | | Add alignment macros to cross-build's sys/cdefs.h Pull Request: https://github.com/freebsd/freebsd-src/pull/531 MFC after: immediately (build fix)
* tools/build/cross-build: Fix building libllvmminimal on LinuxJessica Clarke2021-08-123-0/+133
| | | | | | | | | | There is a __used member in glibc's posix_spawn_file_actions_t in spawn.h, so we must temporarily undefine __used when including it, otherwise Support/Unix/Program.inc fails to build. This is based on similar handling for __unused in other headers. Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux") MFC after: 1 week
* Allow bootstrapping llvm-tblgen on macOS and LinuxAlex Richardson2021-08-021-0/+6
| | | | | | | | | | This is needed in order to build various LLVM binutils (e.g. addr2line) as well as clang/lld/lldb. Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org> Test Plan: Compiles on ubuntu 18.04 and macOS 11.4 Reviewed By: dim Differential Revision: https://reviews.freebsd.org/D31057
* tools/build: Don't redefine open() for the linux bootstrapAlex Richardson2021-08-021-21/+4
| | | | | | | | | | | This is needed to bootstrap llvm-tblgen on Linux since LLVM calls `::open(...)` which does not work if open is a statement macro. Also stop defining O_SHLOCK/O_EXLOCK and update the only bootstrap tools user of those flags to deal with missing definitions. Reviewed By: jrtc27 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31226
* Change strmode argument type to mode_t for crossbuildAlfonso Gregory2021-06-291-1/+1
| | | | | | | To match the libc changes. Reviewed by: imp@ Pull Request: https://github.com/freebsd/freebsd-src/pull/493
* Silence a macro-redefined warning when crossbuildingAlex Richardson2021-03-011-0/+2
| | | | | This is already defined by the ncurses headers, so just undef it before defining it again.