Hi, after changing mksh to no longer use mkstemp, I decided to try and build mksh-static with klcc on most platforms, in Debian. Here are the results by Debian architecture: alpha (4) fails amd64 works armel works armhf (3) fails i386 works ia64 works m68k (1) workaround mips works mipsel works powerpc (2) fails ppc64 works (!) s390 works s390x works sparc works Architectures not listed either do not have a working klibc 2.0~rc3, or did not build mksh or one of its dependencies due to issues with the port (such as debhelper being uninstallable), or do not have a Linux kernel. The ssize_t prototype is bogus at least on s390: ../../shf.c:453:3: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'ssize_t' [-Wformat] That is not a problem, though. (1) m68k: fails, unless I do *not* add -O2 or -Os to CFLAGS and do always add -g (might be a toolchain bug?); this workaround was added to the Debian mksh source package https://buildd.debian.org/status/fetch.php?pkg=mksh&arch=powerpc&ver=40.9.20120414-2&stamp=1334431629 (2) powerpc: amazingly, ppc64 does NOT fail? this looks like m68k without the above-mentioned workaround: the failure I already saw often: after running an external programme, control flow does not return to the shell, and the child is not cleaned up (sticks around as zombie); might be a signal delivery problem (SIGCHLD), signal mask stuff, etc. https://buildd.debian.org/status/fetch.php?pkg=mksh&arch=armhf&ver=40.9.20120414-2&stamp=1334433386 (3) armhf: one of the tests has the memory pool allocator error out as one of its internal data structures got corrupted, or a wrong pointer passed to aresize/afree http://buildd.debian-ports.org/status/fetch.php?pkg=mksh&arch=alpha&ver=40.9.20120414-2&stamp=1334504721 (4) alpha: random SIGSEGVs that happen with neither eglibc nor dietlibc so almost certainly (considering mksh also runs with other OSes on DEC Alpha systems, even with the Compaq C compiler) are problems in klibc If someone wants to have a stab at these: there are Debian porterboxen around for at least powerpc and armhf; alpha might one get access to; for m68k, there is an up-to-date (April 2012) VM base image and I can give instructions how to run the VM. Since the failures happen when executing certain shell code, tracking them down to C code is very difficult; the gdb way (or printf debugging, well, use shellf() inside mksh code instead) might be easier. bye, //mirabilos -- I believe no one can invent an algorithm. One just happens to hit upon it when God enlightens him. Or only God invents algorithms, we merely copy them. If you don't believe in God, just consider God as Nature if you won't deny existence. -- Coywolf Qi Hunt
Thorsten Glaser
2012-Apr-20 16:12 UTC
[klibc] ssize_t (was Re: klibc 2.0~rc3-1 ./. mksh 40.9.20120414-2)
Dixi quod?>The ssize_t prototype is bogus at least on s390: >../../shf.c:453:3: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'ssize_t' [-Wformat]And cris: ? klibc.git/usr/include/bits32/bitsize/stddef.h 9 #if defined(__s390__) || defined(__cris__) 10 typedef unsigned long size_t; 11 #else 12 typedef unsigned int size_t; 13 #endif 14 15 #define _PTRDIFF_T 16 typedef signed int ptrdiff_t; ? klibc.git/usr/include/sys/types.h 12 #define _SSIZE_T 13 typedef ptrdiff_t ssize_t; Combined, these two definitions make the problem. The fix applied to MirBSD, dietlibc and Android bionic libc is to rely on GCC?s definitions for size_t, and hack that into an ssize_t definition: ? mircvs://src/sys/sys/types.h 116 #if !defined(_GCC_SIZE_T) 117 #define _GCC_SIZE_T 118 typedef __SIZE_TYPE__ size_t; 119 #endif 120 121 /* e-eeeevil kludge, but apparently works */ 122 #define unsigned signed 123 typedef __SIZE_TYPE__ ssize_t; 124 #undef unsigned Something like this would also work: typedef __SIZE_TYPE__ size_t; #define unsigned /* nothing */ typedef signed __SIZE_TYPE__ ssize_t; #undef unsigned So far, the code from above MirBSD header has never been a problem though, as GCC is _very_ picky about its type definitions, such as size_t and wchar_t: ? mircvs://gcc/gcc/config/mirbsd.h 135 #define WCHAR_TYPE "short unsigned int" 141 #define WINT_TYPE "unsigned int" 144 #define SIZE_TYPE "long unsigned int" 147 #define PTRDIFF_TYPE "long int" Even changing the order to, say, "unsigned short int" for WCHAR_TYPE, led to errors later on, so this is pretty constrained. If you want, I can prepare and submit a klibc patch to use GCC?s definitions similar to what I?ve done for bionic and dietlibc. bye, //mirabilos -- FWIW, I'm quite impressed with mksh interactively. I thought it was much *much* more bare bones. But it turns out it beats the living hell out of ksh93 in that respect. I'd even consider it for my daily use if I hadn't wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh
H. Peter Anvin
2012-Apr-30 18:38 UTC
[klibc] ssize_t (was Re: klibc 2.0~rc3-1 ./. mksh 40.9.20120414-2)
On 04/20/2012 09:12 AM, Thorsten Glaser wrote:> > If you want, I can prepare and submit a klibc patch to use GCC?s > definitions similar to what I?ve done for bionic and dietlibc. >Yes, that would be the right thing. -hpa