static compilation option?
After I successfully compiled a test python program using codon build <demo.py>, on macOS Monterey (intel), I checked the dependencies as per the following:
$ otool -L demo
demo:
@rpath/libcodonrt.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
The two @rpath dependencies, libcodonrt.dylib and libomp.dylib are included in the codon distribution, they are 1.2M and 772K respectively so not so large.
Is there any thought to having static libraries of these two dependencies available so one may statically compile the executable instead to make it more relocatable?
Hi @shakfu
This is something that I'd like to see as well---among other things, it is major PITA to deal with weird cluster environments when you have dynamic libraries. However, there are currently two major roadblocks:
- libomp is really not happy about static linking. It is possible to force it, but AFAIK it will misbehave if one Codon app calls another Codon app.
- We have seen some weird crashes when statically linking Boehm GC. This needs to be investigated further.
For this reason, we provide two small runtime libraries with minimal dependencies that can be copied together with the executable and distributed accordingly.
I'll keep this one open for now—if anybody has an idea how to fix these issues, we will be happy to consider them.
I would like this feature too, if static linkable support. The build binary could deploy or share more easier.
liudonghua@DESKTOP-DELL:~/codon$ cat fib.py
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
fib(1000)
liudonghua@DESKTOP-DELL:~/codon$
liudonghua@DESKTOP-DELL:~/codon$ codon build -release fib.py
liudonghua@DESKTOP-DELL:~/codon$
liudonghua@DESKTOP-DELL:~/codon$ ldd fib
linux-vdso.so.1 (0x00007ffc321eb000)
libcodonrt.so => /home/liudonghua/.codon/lib/codon/libcodonrt.so (0x00007fd26297e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd262742000)
libomp.so => /home/liudonghua/.codon/lib/codon/libomp.so (0x00007fd262658000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd262653000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd26264e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd262647000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd262560000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd262540000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd262e60000)
liudonghua@DESKTOP-DELL:~/codon$
I would like this feature too. --relocation-model=static will not link into a static file.