Whilst trying to use greencard, I found that configure was incorrectly
setting LEADING_UNDERSCORE on FreeBSD.
$ nm -a ~/bin/hugs | grep main
08049c0c T main
$ grep LEADING_UNDERSCORE ~/install/hugs98-990222-all/src/config.h
#define LEADING_UNDERSCORE 1
Looking at the relevant part of configure.in, it looks as though the
test should default to 0.
Running the test manually shows that it justified in thinking that
leading underscores are allowed.
$ cat > /tmp/foo.c
#include <nlist.h>
struct nlist xYzzY[] = {{"_xYzzY", 0},{0}};
main(argc, argv)
int argc;
char **argv;
{
if(nlist(argv[0], xYzzY) == 0 && xYzzY[0].n_value != 0)
exit(0);
exit(1);
}
$ cc /tmp/foo.c
$ ./a.out
$ ./a.out || echo "no"
$ ./a.out && echo "yes"
yes
But looking at the binary, it's quite clear that they're not really there.
$ nm -a a.out | grep xYzzY
0804941c D xYzzY
What I think is going wrong is that nlist might be pretending that the
_ is present. Which would be fine if Hugs used nlist but it doesn't,
it uses dlopen
$ grep LEADING_UNDERSCORE src/*.c
src/config.h:#define LEADING_UNDERSCORE 1
src/machdep.c:#ifdef LEADING_UNDERSCORE
and it seems that dlopen doesn't pretend that the _ is present.
ERROR "/home/css/staff/reid/install/greencard-2.0/lib/hugs/StdDIS.hs": Unable to
load GreenCard primitives
This error goes away if I remove LEADING_UNDERSCORE from config.h
Suggested fix: replace the configure test with code that tries to use
dlopen, shl_load or LoadLibrary (as appropriate). Or replace it with
a shell-script which uses nm to look at a binary.
Alastair
ps Version info:
Hugs version: hugs98-990222-all
FreeBSD thistle.cs.utah.edu 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Mon Dec 14 11:28:13
MST 1998 [EMAIL PROTECTED]:/usr/src/sys/compile/SMPSIMP i386
bash$ gcc -v
gcc version 2.7.2.1
pps I think I'm responsible for this bug.
I vaguely remember thinking at the time that it was bogus to test
with nlist - but it seemed easier/safer to steal the code unmodified
from someone else (GHC?) than to write my own test.