[klibc] testing by building mksh (was Re: RFT: klibc 2.0.5)

Thorsten Glaser tg at mirbsd.de
Sun Jan 20 06:18:03 PST 2019

Hi Ben,

*massive* thanks for picking up klibc work. This might motivate
me to pick up some of the TODOs for it that have piled on in my
TODO (but only after the freeze, I’m sorry to say, I have more
to do for other packages).

>And I spotted another test program that has this property (setjmptest

setjmp is a good topic… I found that building mksh and running its
testsuite is a good test to find compiler/toolchain/libc/kernel
bugs and would be glad if you could add this to your tests on all
platforms (should even work on those not supported by Debian).

The easiest way is to just package klibc, throw that into an sbuild
or cowbuilder/pbuilder chroot and try to rebuild mksh with it, then
look at the build log (look for “Build information for static-klibc
mksh” and some lines blow “Result: regressed” and “| Total failed: 0”
are the important knobs, but lksh is also currently built with klibc
if it failed, so a few lines below, under “Build information for
legacy mksh” the same should be, plus “| CC='klcc'” under “Variables

This does not test shared klibc, but should give you an idea what
flags to use. To build manually, get the source (apt-get source mksh
will do, or just extract the origtgz somewhere), go into either a
new empty build directory or the source one, and run something like:

export CC=klcc CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2'
export CFLAGS='-Wformat -Werror=format-security -Wall -Wextra -g -fno-stack-protector -Os'
export LDFLAGS='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed'
#export LDSTATIC='-static'   # optional
sh /path/to/mksh/Build.sh -r && ./test.sh

(You can also add -DMKSH_SMALL -DMKSH_SMALL_BUT_FAST for non-lksh
test builds to match what Debian does, but that’s not important.)

Oh, and install the ed package before running test.sh if you
haven’t already, otherwise, three tests for the history function
will fail.

(When test-building for lksh, add '-DMKSH_BINSHPOSIX -DMKSH_BINSHREDUCED'
to CPPFLAGS, the -L flag to the Build.sh invocation, debian/printf.c
to the current working directory, and export USE_PRINTF_BUILTIN=1 in
addition. But that should also not make enough of a difference, so just
running the normal build from above, once for static once for shared,
should suffice.)

11:56⎜«liwakura:#!/bin/mksh» also, i wanted to add mksh to my own distro │
i was disappointed that there is no makefile │ but somehow the Build.sh is
the least painful built system i've ever seen │ honours CC, {CPP,C,LD}FLAGS
properly │ looks cleary like done by someone who knows what they are doing

More information about the klibc mailing list