[Toybox] FreeBSD support patch.

Rob Landley rob at landley.net
Tue May 31 14:29:53 PDT 2016


So I got a new freebsd support patch on the IRC channel (attached, no I
don't know why it's a "shell archive"). I'm trying to figure out which
oprtions to apply to the repo, and it's confusing...

You CD down into sysutils/toybox (which I'm guessing are freebsd's
package categorization stuff for their repository), and in there is
"patch-toys.h", but also another one in
sysutils/toybox/files/patch-toys.h. 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...?)

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? (I'm confused what this support patch is
trying to do to the code. Is it trying to make it build as a native
FreeBSD binary that doesn't  need the linux emulation layer? Or is the
Linux emulation layer capable of emulating things it doesn't provide a
build environment for?)

Most of the rest of the stuff in the toybox directory is freebsd build
plumbing: pkg-plist, pkg-descr, Makefile, and distinfo can be ignored.

Now we wander into the sysinfo/toybox/files directory. We already
covered patch-toys.h here.

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...?

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?

As for this bit:

-#if !defined(__GLIBC__) && !defined(__BIONIC__)
+#if !defined(__GLIBC__) && !defined(__BIONIC__) && !defined(__FreeBSD__)

If we didn't include features.h, we shouldn't have __GLIBC__ or
__BIONIC__ #defined because that's the header that defines them. I'd
also assume that if we're building on freebsd, we don't have those
#defined either because it's got its own libc? So why add a __FreeBSD__
guard symbol here?

This is why I like patches submitted to the list...

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: toybox.shar
Type: application/x-shar
Size: 15097 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20160531/5e357efe/attachment-0003.shar>


More information about the Toybox mailing list