[Matroska-devel] [Patches] Portability, support for CloudABI, etc.

Ed Schouten ed at nuxi.nl
Wed Nov 18 10:27:51 CET 2015


Hi there,

CloudABI is a UNIX-like runtime environment that is built on the
concept of pure capability-based security. It allows you to more
easily build testable sandboxed software. More details, including a
recording of a talk at a conference, can be found here:
https://nuxi.nl/.

CloudABI ships with its own package collection
(https://github.com/NuxiNL/cloudabi-ports). Some time ago I added
packages for libebml and libmatroska. These seemed to build almost
entirely out of the box, but I had to make a couple of local
modifications. I thought I'd send them out here.

1. Determinism

CloudABI's package collection relies on software to build
deterministically. This makes it easier to manage versions, do
debugging and allows us to automatically detect potential ABI
breakages by looking at checksums of reverse dependencies. Other
systems are also putting a focus on this nowadays, including Debian:

https://wiki.debian.org/ReproducibleBuilds

It looks like both libebml and libmatroska both use __TIMESTAMP__,
meaning that the library has a different checksum every time it is
built. Below are some local patches that I currently use to remove its
use:

https://github.com/NuxiNL/cloudabi-ports/blob/master/packages/libebml/patch-determinism
https://github.com/NuxiNL/cloudabi-ports/blob/master/packages/libmatroska/patch-determinism

2. Missing include of <stdlib.h>

The EbmlBinary.h header file calls into malloc() and free() without
including <stdlib.h>. This generates compiler errors in my case. The
following patch fixes this:

https://github.com/NuxiNL/cloudabi-ports/blob/master/packages/libebml/patch-malloc

3. Use of non-standard u_int*_t types

libebml's C bindings attempt to define standard integer types in a
portable way. For some reason they seem to prefer the use of
BSD-specific u_int*_t types over the ISO C99 standard uint*_t types
provided by <stdint.h> (and <inttypes.h>). This patch makes the build
work for me:

https://github.com/NuxiNL/cloudabi-ports/blob/master/packages/libebml/patch-stdint

It may be worth to remove all this code altogether and use
<stdint.h>/<inttypes.h> exclusively. I can't think of a (non-archaic)
UNIX-like operating system that doesn't provide these types.

4. CloudABI specific: disable StdIOCallback

This change is not in an upstreamable state, but I thought I'd mention
it briefly. Due to its security model, CloudABI does not provide
open(), fopen(), etc. Files can only be opened through file
descriptors pointing to directories (using POSIX openat()). This means
that the StdIOCallback class does not compile. The following patch
disables it:

https://github.com/NuxiNL/cloudabi-ports/blob/master/packages/libebml/patch-no-fopen

Anyway, it would be nice if issues 1-3 could be addressed. It would
make it a lot easier to keep both libebml and libmatroska up-to-date.

Thanks in advance,
-- 
Ed Schouten <ed at nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717


More information about the Matroska-devel mailing list