Build problems with the multilanguage regression_test

The problem lay, somehow, in the linking. We noted above that the ghc command--the Glasgow Haskell Compiler--was generating the final link step. This seemed to be necessary, because ghc needs a lot of rather strange and voluminous options to link Haskell programs, adding in several undefined symbols through the use of the -u option to the linker. In fact, the actual link step produced by ghc is heinously long and convoluted:

 /usr/lib/gcc-lib/i686-pc-linux/2.95/collect2 -m elf_i386 -static -o regression_test -u PrelBase_Izh_static_info -u PrelBase_Czh_static_info -u PrelFloat_Fzh_static_info -u PrelFloat_Dzh_static_info -u PrelAddr_Azh_static_info -u PrelAddr_Wzh_static_info -u PrelAddr_I64zh_static_info -u PrelAddr_W64zh_static_info -u PrelStable_StablePtr_static_info -u PrelBase_Izh_con_info -u PrelBase_Czh_con_info -u PrelFloat_Fzh_con_info -u PrelFloat_Dzh_con_info -u PrelAddr_Azh_con_info -u PrelAddr_Wzh_con_info -u PrelAddr_I64zh_con_info -u PrelAddr_W64zh_con_info -u PrelStable_StablePtr_con_info -u PrelBase_False_static_closure -u PrelBase_True_static_closure -u PrelPack_unpackCString_closure -u PrelException_stackOverflow_closure -u PrelException_heapOverflow_closure -u PrelException_NonTermination_static_closure /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i686-pc-linux/2.95/crtbegin.o -L/home/vputz/download/polytemp/hdirect-0.16/lib -L/usr/lib/ghc-4.06 -L/usr/lib/ghc-4.06 -L/usr/lib/ghc-4.06 -L/usr/lib/gcc-lib/i686-pc-linux/2.95 Regression.o Regression_proxy.o Regression_proxy_stub.o regression_wrap.o wrap_start_haskell.o regression_test1.o regression_test2.o python_client_wrap.o wrap_python_macros.o swigptr.o /usr/lib/python1.5/config/libpython1.5.a -lhdirect -lpthread -ldl -lposix -lHSlang -lHSlang_cbits -lHS -lHS_cbits -lHSrts -lgmp -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i686-pc-linux/2.95/crtend.o /usr/lib/crtn.o

My goodness! But a comparison of the link step on our working sample programs showed that we had used slightly different options on our previous programs. The tipoff was the -static option above, which clashed with the knowledge that Python does a lot of dynamic linking--while it could be convinced to do so in a static manner, that was not what had worked before.

On a hunch, we convinced ghc to compile only without linking, and then changed the -static parameter above to -dynamic-linker /lib/, which was rather system-specific--but was what the early sample programs were using during their automatic linking steps.

Surprisingly, this actually worked, and cutting-and-pasting the modified linker command line into the makefile--as long and convoluted as it was--resulted in a working link. The regression program, in all its tri-language glory, worked correctly.