Bug#191033: hugs98_98.200211-1(unstable/ia64): FTBFS: undefined reference to `main'

Ross Paterson ross@soi.city.ac.uk
Fri, 2 May 2003 23:01:55 +0100


On Fri, May 02, 2003 at 03:46:32PM -0400, Isaac Jones wrote:
> The Debian autobuilders were unable to build hugs on a few platforms,
> and I tried building Hugs from the distribution tarball and got
> similar results on ia64 (on both Debian and Redhat).  Here's what
> information I have.  Please let me know if I can get more information
> for you.
> 
> [...]
> 
> This is what looks like the relevant configure output on ia64:
> checking if '/LD' builds loadable libraries... 
> checking if '/LD /ML /nologo' builds loadable libraries... 
> checking if '-shared' builds loadable libraries... 
> checking if '-bundle' builds loadable libraries... 
> checking if '-bundle -lc' builds loadable libraries... 
> checking if '-r' builds loadable libraries... 
> 
> And the same configure output on i386:
> checking if '/LD' builds loadable libraries...
> checking if '/LD /ML /nologo' builds loadable libraries...
> checking if '-shared' builds loadable libraries... -shared
> checking if '-bundle' builds loadable libraries... (cached) -shared
> checking if '-bundle -lc' builds loadable libraries... (cached) -shared
> checking if '-r' builds loadable libraries... (cached) -shared

Yes, the test HUGS_TRY_DYNLINK("-shared") is failing.

Please try running the attached script, which is the test this is using.

> However, when I alter config.h by hand to include the -shared flag,
> and rerun make;make install (without rerunning configure) I get this
> output:
> 
> [...]
> ERROR "/house/ijones/tmp//lib/hugs/libraries/Foreign/C/TypesISO.hs":41 - Implementation of .&. requires extra context
> *** Expected type   : Bits CPtrdiff => CPtrdiff -> CPtrdiff -> CPtrdiff
> *** Missing context : Bits Int64

You can work around this one by adding an empty Bits instance

instance Bits Int64

to libraries/Hugs/Int.hs -- it shouldn't be needed, but a future release
will have a real instance.  While you're at it, might as well add

instance Bits Word64

to libraries/Hugs/Word.hs just in case.
------------------------ test script ------------------------------
cat >conftest_dl.c <<EOF
int x = 0;    /* global */
int y;        /* common */
static int z; /* static */
static int test2() { return (test() + x + y + z); }
int test() { return test2(); }
EOF

cat >conftest.c <<EOF
#define SYMBOL1 "test"
#define SYMBOL2 "_test"

#define CANTRUN  1
#define CANTOPEN 2
#define SYM1_OK  3
#define SYM2_OK  4
#define CANTFIND 5

#include <stdio.h>
#include <dlfcn.h>

main()
{
	void *instance;
	void *sym;

	instance = dlopen("./conftest_dl.so",1);
	if (instance==0) exit(CANTOPEN);

	sym = dlsym(instance,SYMBOL1);
	if (sym != 0) exit(SYM1_OK);

	sym = dlsym(instance,SYMBOL2);
	if (sym != 0) exit(SYM2_OK);

	exit(CANTFIND);
}
EOF

gcc -shared conftest_dl.c -o conftest_dl.so
gcc conftest.c -ldl
./a.out
echo $?