[Toybox] FreeBSD support patch.

Ed Maste emaste at freebsd.org
Tue May 31 17:53:34 PDT 2016


On 31 May 2016 at 21:29, Rob Landley <rob at landley.net> wrote:
>
> You CD down into sysutils/toybox (which I'm guessing are freebsd's
> package categorization stuff for their repository),

Yes, this shar file is intended to build toybox as part of the FreeBSD
ports tree, not necessarily (or only) changes appropriate for
consideration upstream.

> and in there is
> "patch-toys.h", but also another one in
> sysutils/toybox/files/patch-toys.h.

The ../files/.. path is where patches go in the ports tree; I'd guess
the other patch-toys.h is just an accidentally included older version.

> Both are patches against toys.h, but
> the difference between them is the second has:
>
> @@ -88,7 +90,7 @@
>
>  // Flags describing command behavior.
>
> -#define TOYFLAG_USR      (1<<0)
> +#define TOYFLAG_USR      (0)
>  #define TOYFLAG_BIN      (1<<1)
>  #define TOYFLAG_SBIN     (1<<2)
>  #define TOYMASK_LOCATION ((1<<4)-1)
>
>
> Which turns TOYFLAG_USR from 1 to 0, meaning you can't NOT install
> commands in /usr. (Um, why? I know <<0 is a NOP but it aligns it with
> the <<1 and <<2 below it and the compiler optimizes it out...?)

I don't understand the context enough to know why this was done.

> The common part is:
>
> --- toys.h.orig 2016-02-02 17:12:05 UTC
> +++ toys.h
> @@ -62,10 +62,12 @@
>  #include <wctype.h>
>
>  // LSB 4.1 headers
> +#ifndef __FreeBSD__
>  #include <pty.h>
> -#include <sys/ioctl.h>
>  #include <sys/statfs.h>
>  #include <sys/sysinfo.h>
> +#endif
> +#include <sys/ioctl.h>
>
>  #include "lib/lib.h"
>  #include "lib/lsm.h"
>
> Which confuses me because FreeBSD has a Linux runtime emulation
> environment, but at build time doesn't have the ability to provide the
> Linux Standard Base headers?

That's correct, the FreeBSD base system does not provide Linux headers
and libraries. Linux emulation is intended to run native Linux
binaries, so could run a toybox built on a Linux system. Or, one could
install a set of Linux dev packages and toolchain. But that's not
particularly interesting to me; my desire is for a native FreeBSD
toybox.

> patch-dotconfig is adding a .config file, to avoid running "make
> defconfig" or similar. I'm guessing this is the set of commands that
> could be made to build on freebsd? It's switching on a bunch of comands
> in pending and switching _off_ ones like cp/stat/blkid/od/tail that
> would seem more portable...?

I'm not sure what was done here.

> The patches to lib/interestingtimes.c (which I should rename) and
> lib/lib.c belong in lib/portability.h
>
> As for the lib/portability.h patch: FreeBSD doesn't have features.h, but
> Linux and MacOS X agree on that one? Odd. Speaking of which, we have
> __FreeBSD__ without #including features.h?

Yes, __FreeBSD__ is a built-in macro defined by the compiler.



More information about the Toybox mailing list