Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static compilation option? #82

Open
shakfu opened this issue Dec 10, 2022 · 3 comments
Open

static compilation option? #82

shakfu opened this issue Dec 10, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@shakfu
Copy link

shakfu commented Dec 10, 2022

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?

@inumanag
Copy link
Contributor

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.

@inumanag inumanag added enhancement New feature or request help wanted Extra attention is needed labels Dec 18, 2022
@liudonghua123
Copy link

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$

@chuqingq
Copy link

chuqingq commented Aug 1, 2023

I would like this feature too. --relocation-model=static will not link into a static file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants