Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Mar 2013 08:03:05 -0700
From:      Ian Lepore <ian@FreeBSD.org>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-arm@FreeBSD.org
Subject:   Re: cross-compilation of sh(1) from x86 to arm
Message-ID:  <1362582185.1291.106.camel@revolution.hippie.lan>
In-Reply-To: <20130303231931.GD21318@stack.nl>
References:  <20130303231931.GD21318@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2013-03-04 at 00:19 +0100, Jilles Tjoelker wrote:
> There has long been a bug in sh(1) where it assumes (in mksyntax.c) that
> the properties of char are the same between build and run environments.
> This assumption does not hold if a cross build is done for arm on an x86
> machine. The main effect is that such a miscompiled sh incorrectly
> handles characters with bit 7 set. Various tests in
> tools/regression/bin/sh start failing, possibly in ways that eat huge
> amounts of CPU time and memory.
> 
> Christoph Mallon has submitted a fix for this and I have committed it to
> head and stable/9. It has, however, only been tested on x86 using the
> -funsigned-char compiler option to create the discrepancy.
> 
> Below is a backport of the fix to stable/8. It needs r247733 or at least
> the bin/sh/mksyntax.c of that revision.
> 
> Because I had to fix some conflicts and stable/8's sh differs quite a
> bit from head's, I would like to have some testing first before
> committing this. I again tested only on amd64 with and without the
> -funsigned-char compiler option and tools/regression/bin/sh. If the
> cross-compilation need not be supported on stable/8, I am fine with
> leaving it unfixed in stable/8.

It took me a while to get an arm 8-stable environment running to test
this.  I'm cross-building arm from an i386 build machine running 8.3.

Testing with 8-stable @ r247889 before applying your patch, I get two
failures:

not ok 12 - ./builtins/cd1.0 # wrong exit status
not ok 98 - ./expansion/ifs3.0 # wrong exit status

After applying your patch, only test 12 fails (still wrong exit status).

The failure of test 12 looks like this in both cases:

root@dpcur:/tmp/regression/bin/sh # sh -x builtins/cd1.0
+ set -e
+ P=/tmp
+ cd /tmp
+ mktemp -d sh-test.XXXXXX
+ T=sh-test.TkJqGN
+ chmod 0 sh-test.TkJqGN
+ cd -L sh-test.TkJqGN
+ exit 1

If I launch sh and enter that series of commands interactively, the cd
-L command returns a status of 0.

Now that I've remembered the incantations for getting 8.x to run on my
dreamplug I can test things pretty easily if you've got other changes.

I also tested -current cross-built on the same machine (using gcc and
oabi), and there are no failures there.

-- Ian





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1362582185.1291.106.camel>