Commit Graph

75 Commits

Author SHA1 Message Date
Simon J. Gerraty
644d346d99 We do not need readpassphrase from openssh
When building tar for linux, just disable HAVE_READPASSPHRASE
in config_freebsd.h and libarchive will provide for readpassphrase
Otherwise the two conflict.
2023-04-24 13:50:18 -07:00
Simon J. Gerraty
976ba7f02a Enable building tar for non-FreeBSD host
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
2023-04-24 10:20:17 -07:00
Simon J. Gerraty
db98bc2c0d Allow tools/build to work for DIRDEPS_BUILD
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
2023-04-22 12:25:54 -07:00
Mark Johnston
0ec03c0b10 cross-build: Add secure_getenv() for MacOS cross builds
Reviewed by:	arichardson
Fixes:		68ca8363c7 ("libc: Use secure_getenv(3) where appropriate")
Differential Revision:	https://reviews.freebsd.org/D39295
2023-03-30 00:54:13 -04:00
John Baldwin
7d8e1e8dd9 libcasper: Move helper libraries from /lib/casper to /lib.
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
2023-03-29 15:04:28 -07:00
John Baldwin
ac6b2b4344 build: glibc on Linux defines explicit_bzero in <string.h>.
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
2023-03-27 14:27:16 -07:00
Ed Maste
c5e54e56e6 tools/build: Hide spurious errors if sys/stat.h does not exist
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38757
2023-03-01 19:59:26 -05:00
Brooks Davis
3b073d2ee5 tools/build: Always bootstrap (sys/)bitstring.h
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
2023-01-09 19:17:48 +00:00
Jessica Clarke
548f8a657b tools/build: Provide fls* when cross-building on Linux
flsll is needed for makefs's new ZFS support, and the others are added
for completeness.

Reviewed by:	emaste, arichardson
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Differential Revision:	https://reviews.freebsd.org/D36134
2022-08-18 02:46:28 +01:00
Jessica Clarke
e9ba1fd5ed tools/build: Provide FreeBSD's bitstring API when cross-building
This is needed for building makefs as a cross-tool since the ZFS code
uses these APIs.

Reviewed by:	emaste
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Differential Revision:	https://reviews.freebsd.org/D36133
2022-08-18 02:46:27 +01:00
Reid Linnemann
000321bab7 namespace nv names, version libnv and libnvpair library symbols
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
2022-07-21 18:35:23 +02:00
Mark Johnston
2d5d2a986c ctf: Import ctf.h from OpenBSD
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
2022-03-07 10:43:18 -05:00
Mark Johnston
ddf312e8d7 tools/build: Fix the error message used when a host tool is not present
MFC after:	1 week
2022-01-26 15:34:21 -05:00
Ed Maste
6f6fbfa3a8 Remove quotes around Makefile .error/.warn/.info strings
The text after .error et al is emitted verbatim.

Reviewed by:	sjg
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33904
2022-01-22 14:03:07 -05:00
Jessica Clarke
7ba31d58f0 tools: Also create ${WORLDTMP}/legacy/usr/libdata/pkgonfig
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
2021-12-06 19:16:27 +00:00
Kyle Evans
8c22b9f3ba Fix cross-building on Linux/aarch64
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
2021-10-18 11:09:00 -05:00
Justin Hibbits
7b81e6c7ca Support bootstrapping from Linux/ppc* 2021-09-04 11:47:30 -05:00
Ka Ho Ng
5425ba8332 truncate(1): Fix cross-build CI failure due to missing fspacectl
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
2021-08-24 17:08:28 +08:00
Alex Richardson
5c9cb96a23 Fix BUILD_WITH_STRICT_TMPPATH build after adding time to ITOOLS
This is needed after bbd16236e9 (and
99feb137f5).
2021-08-02 15:34:26 +01:00
Jessica Clarke
8c9e45503f tools/build: Improve host-symlinks failure mode
Since set -e is enabled by sys.mk, if the tool cannot be found in PATH
then the entire shell command line fails, causing us to not print the
error message below and instead silently (due to the @) fail, only
getting the usual "Error code 1" print from bmake. Thus, provide a dummy
default that will never exist (the same as is used by meta2deps.sh) if
which fails so that we get the error message as intended.

MFC after:	1 week
2021-03-20 13:00:34 +00:00
Alex Richardson
962a3814d4 Fix bootstrap tools build on macOS after 02af91c52e
After changing the namespace.h header we need to provide _err on macOS, too.
Previously we used the system libc err*/warn*, but that does not provide
_err/_warn (which is used by other bootstrapped files from libc).
To fix this problem bootstrap err.c on macOS as well.

Fixes:		02af91c52 (Fix crossbuild bootstrap tools build with Clang 12)
2021-02-17 16:35:14 +00:00
Alexander Richardson
a8b20f4fab Create symlinks to host tools on non-FreeBSD hosts
This is unnecessary when cross-building from Linux/macOS.
Additionally, cp -p appears to be broken on macOS Big Sur
(https://openradar.appspot.com/8957219).

For some unknown reason this commit appears to fix
freezes when building on macOS Big Sur.
This also fixes building in docker with volume mounts
with ACLs, since setting the ACL with cp -p fails otherwise.

Obtained From:	CheriBSD
Tested By:	gnn (macOS Big Sur), Nathaniel Wesley Filardo (docker)
Reviewed By:	jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D28267
2021-01-25 15:09:43 +00:00
Mariusz Zaborski
aefe30c543 cat: capsicumize it
Reviewed by:	markj, arichardson
Differential Revision:	https://reviews.freebsd.org/D28083
2021-01-15 21:23:42 +01:00
Alex Richardson
4e64fb9f49 Fix warnings during bootstrap on Linux systems
Most warnings are currently off for the boostrap phase, but once D27598
lands they will be enabled again.
2021-01-07 09:30:50 +00:00
Alex Richardson
ed8455806e Fix all warnings emitted in make kernel-toolchain
With this change and D27598 make kernel-toolchain no longer emits any
warnings for me.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D27599
2021-01-07 09:26:22 +00:00
Alex Richardson
a525283161 Fix more -Wundef warnings during bootstrap 2020-10-14 12:28:54 +00:00
Alex Richardson
5bb9250e0a Add necessary Makefile.inc1 infrastructure for building on non-FreeBSD
The most awkward bit in this patch is the bootstrapping of m4:
We can't simply use the host version of m4 since that is not compatible
with the flags passed by lex (at least on macOS, possibly also on Linux).
Therefore we need to bootstrap m4, but lex needs m4 to build and m4 also
depends on lex (which needs m4 to generate any files). To work around this
cyclic dependency we can build a bootstrap version of m4 (with pre-generated
files) then use that to build the real m4.

This patch also changes the xz/unxz/dd tools to always use the host version
since the version in the source tree cannot easily be bootstrapped on macOS
or Linux.

Reviewed By:	brooks, imp (earlier version)
Differential Revision: https://reviews.freebsd.org/D25992
2020-08-25 13:29:57 +00:00
Alex Richardson
7ec1ec4fdb Add missing FreeBSD functions to -legacy when building on macOS/Linux
In most cases this simply builds the file from lib/libc for missing
functions (e.g. strlcpy on Linux etc.). In cases where this is not possible
I've added an implementation to tools/build/cross-build.

The fgetln.c/fgetwln.c/closefrom.c compatibility code was obtained from
https://gitlab.freedesktop.org/libbsd/libbsd, but I'm not sure it makes
sense to import it into to contrib just for these three bootstrap files.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D25978
2020-08-25 13:23:31 +00:00
Warner Losh
0e533c72bc When copying over the binaries, use '-p' to preserve date/time
Although I can't reproduce it, others are seeing different lex/yacc
programs always regenerated after my change to copy rather than
symlink the files. The reported fix is to add '-p' to the copies.
Since it doesn't hurt, go head and add it, though the reasons for
this mattering remain at best obscure and poorly articulated.
2020-08-24 16:06:11 +00:00
Alex Richardson
0d5e651861 crunchgen: use pwd -P without env
The -P flag is required by POSIX so we don't have to care whether pwd is
a shell builtin or not. This also allows removing pwd from the list of
bootstrap tools since all shells we care about for building have a
builtin pwd command. This effectively reverts r364190.

Suggested By:	rgrimes, jrtc27
2020-08-14 09:45:41 +00:00
Alex Richardson
54f7867b83 Add pwd to the list of tools that are linked to $WORLDTMP/legacy
After r364166 and r364174, crunchgen needs a pwd binary in $PATH instead
of using a hardcoded absolute path. This commit is needed for
BUILD_WITH_STRICT_TMPPATH builds (currently not on by default).
2020-08-13 14:14:46 +00:00
Alex Richardson
313232ddf9 Fix bootstrapping ldd after r362152
r362152 started using DF_1_PIE, which is not present in older versions
of sys/elf_common.h. To fix this include the ELF headers as part of -legacy.
2020-08-11 16:46:33 +00:00
Warner Losh
33176cdc87 The practice of creating symbolic links is somewhat fragile. Always
make copies instead.

There's too many times that we can't run the new binaries with old
libraries. Making the links when things are known to be 'safe' is a
nice optimization, but a copy of all the binaries is only 30MB, so
saving the copies at the cost of increased support when new symbols
are added and used as part of the bootstrap seems to be unwise.

There may be additional optimizations possible here, especially for
!FreeBSD hosts. However, that's beyond the scope of the problem I'm
trying to fix with make failing mid-way through an installworld across
change r363679. This optimization there caused us to run a new binary
with an old library once a new make was installed due to the symbolic
link. One could just copy make, but then other binaries fail as well,
so rather than play whack-a-mole, I opted to take us back to the old
way.  Before r340157 or so we did copies (thogh of a lot fewer
artifacts), and we didn't have issues like this.

Reviewed by: arichards@
Differential Revision: https://reviews.freebsd.org/D25967
2020-08-07 16:26:56 +00:00
Alex Richardson
ea6c594cbc Fix BUILD_WITH_STRICT_TMPPATH builds
We need dd in $PATH for some of the MK_BOOT code and some tests also use it.

Obtained from:	CheriBSD
2020-07-15 12:08:06 +00:00
Ryan Moeller
94a8266684 flua: add ucl library
libucl comes with a Lua library binding.  Build it into flua.

This lets us parse/generate config files in the various formats supported by
libucl with flua.  For example, the following script will detect the format of
an object written to stdin as one of UCL config, JSON, or YAML and write it to
stdout as pretty-printed JSON:

local ucl = require('ucl')
local parser = ucl.parser()
parser:parse_string(io.read('*a'))
local obj = parser:get_object()
print(ucl.to_format(obj, 'json'))

Reviewed by:	kevans, pstef
Approved by:	mmacy (mentor)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D25009
2020-06-22 03:14:43 +00:00
Toomas Soome
e7fd9688ea Move font related data structured to sys/font.c and update vtfontcvt
Prepare support to be able to handle font data in loader, consolidate
data structures to sys/font.h and update vtfontcvt.

vtfontcvt update is about to output set of glyphs in form of C source,
the implementation does allow to output compressed or uncompressed font
bitmaps.

Reviewed by:	bcr
Differential Revision:	https://reviews.freebsd.org/D24189
2020-06-14 06:58:58 +00:00
Alex Richardson
162ae9c834 Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOS
In order to do so we need to install the msdosfs headers to the bootstrap
sysroot and avoid includes of kernel headers that may not exist on every
host (e.g. sys/lockmgr.h). This change should allow bootstrapping of makefs
on FreeBSD 11+ as well as Linux and macOS.

We also have to avoid using the IO_SYNC macro since that may not be
available. In makefs it is only used to switch between calling
bwrite() and bdwrite() which both call the same function. Therefore we
can simply always call bwrite().

For our CheriBSD builds we always bootstrap makefs by setting
LOCAL_XTOOL_DIRS='lib/libnetbsd usr.sbin/makefs' and use the makefs binary
from the build tree to create a bootable disk image.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D23201
2020-01-27 12:02:41 +00:00
Kyle Evans
4f47920e9c Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH
${WORLDTMP}/legacy/usr/libexec will only have libexec/ bits that we've
pushed as bootstrap tools, so this is generally safe to include prior to
PATH. The following are the ramifications of this change:

- BPATH addition gets us at least bootstrap flua in WMAKEENV path for
  buildenv, for those earlier systems where it's bootstrapped still

- Reworked the sysent target to just set PATH and let it get worked out in
  src.lua.mk or individual sysent makefiles -- this gives us back the
  ability to overwrite LUA_CMD and use a different/external lua for these
  targets.  sysent can also now work cleanly in buildenv.

- tools/build/Makefile will now symlink the host flua into build's host
  tools so that the above can work without needing to add the host's
  /usr/libexec explicitly into TMPPATH.

Reviewed by:	arichardson, brooks, imp (all slightly earlier version)
Differential Revision:	https://reviews.freebsd.org/D22464
2020-01-12 04:18:36 +00:00
Kyle Evans
f22a592111 Convert in-tree sysent targets to use new makesyscalls.lua
flua is bootstrapped as part of the build for those on older
versions/revisions that don't yet have flua installed. Once upgraded past
r354833, "make sysent" will again naturally work as expected.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D21894
2019-11-18 23:28:23 +00:00
Simon J. Gerraty
17adf17b30 Building head on stable/11 requires libzstd
Add lib/libzstd to _elftoolchain_libs

tools/build/Makefile needs to create the install dir for libzstd
Since this would make the line too long, rework to use a list
in one per line format (easier to add in future)
and dispense with the .for loop

Reviewed by:	emaste bapt
Differential Revision:	https://reviews.freebsd.org/D220134
2019-10-28 20:45:29 +00:00
Mark Johnston
fbe12f2085 Include caph_rights_limit() in libegacy if need be.
Reported by:	jenkins
Sponsored by:	The FreeBSD Foundation
2019-08-01 19:26:16 +00:00
Marius Strobl
c36f427632 Add <sys/dnv.h> required for libnv to SYSINCS, too, apparently missed
in r336335.
2019-06-15 09:45:00 +00:00
Cy Schubert
6389bef8f1 As an interim measure until a more permanent solution is implemented
workaround the following error:

/usr/src/contrib/elftoolchain/strings/strings.c:198:55: error: use of
undeclared identifier
'FA_OPEN' fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);

Reported by:	O. Hartmann <ohartmann@walstatt.org>
Reported by:	Michael Butler <imb@protected-networks.net>
Reported by:	gjb@ & cy@ (implicit)
Reviewed by:	emaste@
Noted by:	rgrimes@
2019-04-18 01:02:00 +00:00
Mariusz Zaborski
d5f4dd1be7 Add cap_fileargs.h to -legacy if needed.
Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D19685
2019-04-04 04:14:20 +00:00
Alex Richardson
3b7e9bfef4 Add capsicum_helpers.h to -legacy if needed
This fixes bootstrap of capsicumized strings on FreeBSD 11.

Reviewed By:	oshogbo, bdrewery
Differential Revision: https://reviews.freebsd.org/D17971
2018-11-19 18:58:34 +00:00
Alex Richardson
b25c717954 Fix -DNO_CLEAN build after r340157
Approved By:	jhb (mentor)
2018-11-05 21:30:00 +00:00
Alex Richardson
8f62bca488 Allow building world without inheriting $PATH
Inheriting $PATH during the build phase can cause the build to fail when
compiling on a different system due to missing build tools or incompatible
versions somewhere in $PATH. This has cause build failures for us before
due to the jenkins slaves still running FreeBSD 10.
Listing the tools we depend on explicitly instead of just using whatever
happens to be in $PATH allows us to check that we don't accidentally add a
new build dependency.

All tools that do no need to be bootstrapped will now be symlinked to
${WORLDTMP}/legacy/bin and during the build phase $PATH will only contain
${WORLDTMP}. There is also a new variable "BOOTSTRAP_ALL_TOOLS" which can
be set to force compiling almost all bootstrap tools instead of symlinking
them. This will not bootstrap tools such as cp,mv, etc. since they may be
used during the build and for those we should really only be using POSIX
compatible options.

Furthermore, this change is required in order to be able to build on
non-FreeBSD hosts. While the same binaries may exist on Linux/MacOS they
often accept different flags or produce incompatible output.

Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D16815
2018-11-05 19:51:10 +00:00
Alex Richardson
4acc8a67ba Don't create directories in ${WORLDTMP}/legacy with mtree
This has two advantages:
1) We no longer create lots of empty directories that are not needed
2) This is a requirement for building on non-FreeBSD hosts since mtree will
only exist after the bootstrap-tools phase there.

Aproved By:	jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D16773
2018-08-20 10:39:53 +00:00
Alex Richardson
8d14ced6ea Fix buildworld on FreeBSD 10
Since r336126 we depend on explicit_bzero() for the libmd
bootstrap. Add it to -legacy if it is not found in /usr/include/strings.h.

Reviewed By:	ian
Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D16245
2018-07-16 11:03:05 +00:00
Alex Richardson
63889bbde0 No longer install sys/nv.h and sys/cnv.h in lib/libnv/Makefile
Use tools/build/Makefile to install the headers into ${WORLDTMP}/legacy
instead. Compared to r336026 this has the minor advantage that it avoids
unncessary header installation when building the non-bootstrap libnv.

Reviewed By:	bdrewery, kevans
Approved By:	brooks (mentor)
Differential Revision: https://reviews.freebsd.org/D16187
2018-07-16 10:57:26 +00:00