———————————————————————-
mcflurry:~/tmp/stratego-tests nix$ more foo.str
module foo
strategies

main = id
———————————————————————-

Compile:
———————————————————————-
mcflurry:~/tmp/stratego-tests nix$ /nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/bin/strc -i foo.str
compiling foo.str
front-end succeeded: user 0.66 system 0.85
back-end succeeded: user 0.43 system 0.69
mkdir .libs
gcc foo.o -o foo -bind_at_load -L/nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/stratego-lib /nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/stratego-lib/libstratego-lib-native-opt.dylib -L/nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/srts /nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/srts/libstratego-runtime-choice-opt.dylib /nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/srts/libstratego-runtime-opt.dylib -L/nix/store/kxs9j11mk9jkymv1h8mfik85ynf9c75z-aterm-2.3.1/lib -lATerm-gcc -lm
C compilation succeeded: user 0.47 system 1.11
—–
compilation succeeded: user 1.56 system 2.66
———————————————————————-

run:
———————————————————————————
mcflurry:~/tmp/stratego-tests nix$ ktrace ./foo
dyld: ./foo Undefined symbols:
_AT_getAnnotations
_AT_setAnnotations
_ATempty
_ATfprintf
_ATinit
_ATinsert
_ATmakeAFun
_ATmakeAppl0
_ATmakeAppl2
_ATmakeApplArray
_ATprotectAFun
_ATreverse
_ATsetArgument
_at_lookup_table_alias
_ATmake
_ATmakeAppl1
_ATmakeAppl3
_ATmakeAppl4
_ATmakeAppl5
_ATmakeAppl6
_ATmakeApplList
_ATmakeList1
_ATwriteToString
_at_lookup_table
Trace/BPT trap
———————————————————————————

ldd:
———————————————————————————
mcflurry:~/tmp/stratego-tests nix$ otool -L ./foo
./foo:
/nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/stratego-lib/libstratego-lib-native-opt.dylib (compatibility version 0.0.0, current version 0.0.0)
/nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/srts/libstratego-runtime-choice-opt.dylib (compatibility version 0.0.0, current version 0.0.0)
/nix/store/rhik746qyvl995vc86pz01bzdhaw2qcf-strategoxt-from-tarball/lib/srts/libstratego-runtime-opt.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.3)
———————————————————————————

C code:
———————————————————————————
mcflurry:~/tmp/stratego-tests nix$ more foo.c
#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static void init_module_constructors (void)
{
}
static void init_module_constant_terms (void)
{
}
#include <srts/init-stratego-application.h>
ATerm main_0_0 (ATerm t);
ATerm main_0 (ATerm t)
{
SRTS_stratego_initialize();
t = main_0_0(t);
return(t);
}
ATerm main_0_0 (ATerm t)
{
return(t);
}
———————————————————————————

The problem seems to be that SRTS_stratego_initialize (in the stratego runtime) requires symbols from the static library ATerm-gcc that are not included by the linker.

Larger programs work fine.

Submitted on 18 July 2005 at 21:08

On 18 July 2005 at 21:51 Jira commented:

STR-343, martin:
Eelco Dolstra to the rescue:

niksnut_ bravo: I’ve taken a look at mcflurry
bravo niksnut_: ah, cool, and?
niksnut_ neither the 3 dylibs used by foo nor foo itself include ATerm (according to nm)
bravo niksnut_: right, but according to the manpage the static lib wil be searched for symbols used in one of the dylibs. Isn’t that what should solve this problem?
bravo ATerm-gcc is the final -l argument, so there is now way that these symbols could not have been found …
bravo I could try to use -all_load, but that’s quite a hack …
bravo niksnut_: there is a small test program on mcflurry in ~/tmp/stratego-tests
niksnut_ that’s what I’m looking at
bravo ah, right
niksnut_ bravo: I now have a working executable
bravo ah, what have you changed?
niksnut_ the trick is to force the linker to include libATerm.a in the executable
niksnut_ it apparently doesn’t do that by default
bravo humz, using which flag? -all-load?
niksnut_ so I added a dummy reference to a symbol inside foo.c (void * s = &ATinit)
bravo ah, right
niksnut_ bravo: hopefully there is a flag to do it
niksnut_ but probably a better way is to link ATerm dynamically
bravo yepz…
niksnut_ probably libtoolizing aterm is easier than fixing this
bravo well, the -all-load is a solution, but it will increate the size of all binaries
niksnut_ the aterm build process is really quite trivial, if you toss out all the silly variants
bravo yes, the main problem is that we have to create our own release then
niksnut_ jep, -all_load works
niksnut_ shrugs
bravo it does? Humz, doesn’t work here :o
niksnut_ we already have a billions packages in the build farm, so we can handle aterm too ;-)
bravo humz …. I agree that it is the most attractive solution …
niksnut_ bravo: see cmd_line in ~/tmp/stratego-tests
bravo ah, should use an _ …
bravo right, now it works here as well
bravo ( strc -i foo.str -Xlinker -all_load )
bravo niksnut_: thanks a lot for the help … now we have to choose a solution …


On 20 July 2005 at 14:01 Jira commented:

STR-343, martin:
Solved with aterm-dynamic (which still has to be released)

Log in to post comments