On 2013-06-18 20:40, Thorsten Glaser wrote:
Jens Staal dixit:

Apparently, by passing -L to Build.sh, ape/cc can build without a workaround.

That will build lksh, not mksh, which is an entirely different thing.

But that means we know more closely which of the assertions fail(s):

#ifndef MKSH_LEGACY_MODE
/* the next assertion is probably not really needed */
cta(ari_is_4_char, sizeof(mksh_ari_t) == 4);
/* but this is */
cta(ari_has_31_bit, 0 < (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 
1));
/* the next assertion is probably not really needed */
cta(uari_is_4_char, sizeof(mksh_uari_t) == 4);
/* but the next three are; we REQUIRE unsigned integer wraparound */
cta(uari_has_31_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 2 
+ 1));
cta(uari_has_32_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 
+ 3));
cta(uari_wrap_32_bit,
     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3) >
     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4));
#endif

This means that either
b>    to b> b> b> b>

Very nice that something I observed might be of help :)

Does this mean that I should try to put in a test for "unknown" compiler on
Plan9 early in the script and trigger "legacy"?

Absolutely not!

OK I won't ;)


The gcc port on Plan9 can build without any modifications to Build.sh (except
the re-definitions for seteuid and setegid).

Interesting.

Try this, with both of them:

---------------------------------------------------------------->8
#include <stdio.h>
#ifdef attempt1
#include <stdint.h>
#endif

#ifdef attempt2
typedef u_int32_t uint32_t;
#endif
#ifdef attempt3
typedef signed int int32_t;
typedef unsigned int uint32_t;
#endif

typedef int32_t mksh_ari_t;
typedef uint32_t mksh_uari_t;
>
int
main(void)
{
        mksh_ari_t i;
        mksh_uari_t u, v;

        printf("sizes: %u %u\n", (unsigned)sizeof(mksh_ari_t), 
(unsigned)sizeof(mksh_uari_t));
        i = (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 1);
        printf("ari_has_31_bit: 0 < %X = %d\n", (unsigned)i, 0 < i);
        u = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 2 + 1);
        printf("uari_has_31_bit: 0 < %X = %d\n", (unsigned)u, 0 < u);
        u = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3);
        printf("uari_has_32_bit: 0 < %X = %d\n", (unsigned)u, 0 < u);
        v = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4);
        printf("uari_wrap_32_bit: %X > %X = %d\n", (unsigned)u, (unsigned)v, u 
> v);

        return (0);
}
---------------------------------------------------------------->8

Define -Dattempt1 and, only if that doesnb> or even -Dattempt3.

I modified attempt1 by changing from <stdint.h> to <inttypes.h> (stdint.h does not exist).

sorry if there are any typo's below (written over by hand from my VM)

under APE, running
cc -Dattempt1 -D_SUSV2_SOURCE thorsten-test.c : WORKS!

./a.out
sizes: 4 4
ari_has_31_bit: 0 < 7FFFFFFF = 1
uari_has_31_bit: 0 < 7FFFFFFF = 1
uari_has_32_bit: 0 < FFFFFFFF = 1
uari_wrap_32_bit: FFFFFFFF > 0 = 1

cc -Dattempt2 thorsten-test.c : FAIL
cc -Dattempt3 thorsten-test.c : WORKS!
./a.out gives the same output as attempt1

Any reason to also try gcc?


bye,
//mirabilos


BTW: I checked the man pages of Plan9 diff and it does not have -u. On the other hand, APE got its own diff so I will test that one or else just copy my changed Build.sh to my host Linux and do the diff there.

I will add -DMKSH__NO_SETEUGID and -DMKSH_NOPROSPECTOFWORK to Plan9 (since both ape/cc and gcc - compiled binaries suffer from the same issues regarding those two).

Reply via email to