x10-lang / x10

Core implementation of X10 programming language including compiler, runtime, class libraries, sample programs and test suite
Eclipse Public License 1.0
70 stars 15 forks source link

statically linked X10 program #24

Open yohm opened 6 years ago

yohm commented 6 years ago

I'd like compile an X10 program statically linked to x10 runtime libraries in order to distribute it as a stand-alone executable file. As far as I understand, libx10, libx10rt_sockets, libgc are dynamically linked by default but I'd like to link them statically.

I found that the static libraries are created when we build x10 with an environment variable X10_STATIC_LIB as follows.

export X10_STATIC_LIB=1
cd x10/x10.dist
ant -Davailable.procs=8 -Doptimize=true -DNO_CHECKS=true dist

Even though I found .a files are created under x10.dist/*/lib directories, x10c++ tries to use "libgc.so" file, which causes a run-time error like

./hello.out: error while loading shared libraries: libgc.so.1: cannot open shared object file: No such file or directory

I found a tentative workaround of deleting libgc.so to force a static link, but this must not be a canonical way. Please tell me how to link it statically.

dgrove-oss commented 6 years ago

Hi, sorry for the slow response.

I think we need to add a test for X10_STATIC_LIB being set in x10.runtime/build.xml in the various stanzas of the build-bdwgc rule that don't already pass: <arg value="--disable-shared" /> to the configure command so that if X10_STATIC_LIB is set, then bdwgc is configured to not build libgc.so. If both libgc.a and libgc.so are available, the C++ compiler will prefer to link to the .so version. So we need to prevent libgc.so from being built.

Does this make sense?

yohm commented 6 years ago

Thank you for your reply. It makes sense. Do you have a plan to add an option to suppress building libgc.so?