Re: Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn

On Tuesday, 25 October 2022 at 10:55:33 UTC, Kagamin wrote:

ldc2 -link-defaultlib-shared=false or something like that


Thanks.


Re: Static executable (ldc, linux)

2022-10-25 Thread Kagamin via Digitalmars-d-learn

ldc2 -link-defaultlib-shared=false or something like that


Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn
I'm having problems compiling my thing into an executable that 
doesn't require ldc's phobos/druntime .so's. I want to distribute 
it in a form where it's okay if 
`/usr/lib/libphobos2-ldc-shared.so.100` and friends don't exist.


`--static` seems to do the trick in that the compiled file is no 
longer a dynamic executable, but then it doesn't work and just 
segfaults upon trying to use OpenSSL (via `arsd.http2`). The only 
other flag I specifically pass to ldc is `-linkonce-templates`.


```
Linking...
/usr/bin/ld: 
../../.dub/packages/arsd-official-10.9.2/arsd-official/.dub/build/with_openssl-debug-linux.posix-x86_64-ldc_v1.30.0-328F22C7CA122C28C3639482CB724003/libarsd-official_http.a(arsd.http2.o): in function `_D4arsd5http211loadOpenSslFZv':

/home/wob/src/kameloso/../../.dub/packages/arsd-official-10.9.2/arsd-official/http2.d:3679:
 warning: Using 'dlopen' in statically linked applications requires at runtime 
the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(path.o): in function 
`_D3std4path11expandTildeFNbNfAyaZ18expandFromDatabaseFNbNfQBdZQBh':

path.d:(.text._D3std4path11expandTildeFNbNfAyaZ18expandFromDatabaseFNbNfQBdZQBh+0x147):
 warning: Using 'getpwnam_r' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket25_sharedStaticCtor_L282_C1FZv':

socket.d:(.text._D3std6socket25_sharedStaticCtor_L282_C1FZv+0x14): warning: 
Using 'getaddrinfo' in statically linked applications requires at runtime the 
shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket12InternetHost__T7getHostVAyaa118_0a2020202020202020202020206175746f2078203d2068746f6e6c28706172616d293b0a2020202020202020202020206175746f206865203d20676574686f73746279616464722826782c20342c206361737428696e7429204164647265737346616d696c792e494e4554293b0a2020202020202020TkZQJwMFkZb':

socket.d:(.text._D3std6socket12InternetHost__T7getHostVAyaa118_0a2020202020202020202020206175746f2078203d2068746f6e6c28706172616d293b0a2020202020202020202020206175746f206865203d20676574686f73746279616464722826782c20342c206361737428696e7429204164647265737346616d696c792e494e4554293b0a2020202020202020TkZQJwMFkZb+0x37):
 warning: Using 'gethostbyaddr' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket12InternetHost__T7getHostVAyaa75_0a202020202020202020202020202020206175746f206865203d20676574686f737462796e616d6528706172616d2e74656d7043537472696e672829293b0a202020202020202020202020TAxaZQGpMFQjZb':

socket.d:(.text._D3std6socket12InternetHost__T7getHostVAyaa75_0a202020202020202020202020202020206175746f206865203d20676574686f737462796e616d6528706172616d2e74656d7043537472696e672829293b0a202020202020202020202020TAxaZQGpMFQjZb+0x43):
 warning: Using 'gethostbyname' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket8Protocol17getProtocolByTypeMFNbNeEQBuQBt12ProtocolTypeZb':

socket.d:(.text._D3std6socket8Protocol17getProtocolByTypeMFNbNeEQBuQBt12ProtocolTypeZb+0xa):
 warning: Using 'getprotobynumber' in statically linked applications requires 
at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket8Protocol17getProtocolByNameMFNbNeMAxaZb':

socket.d:(.text._D3std6socket8Protocol17getProtocolByNameMFNbNeMAxaZb+0x26): 
warning: Using 'getprotobyname' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket7Service16getServiceByNameMFNbNeMAxaMQeZb':

socket.d:(.text._D3std6socket7Service16getServiceByNameMFNbNeMAxaMQeZb+0x57): 
warning: Using 'getservbyname' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/libphobos2-ldc.a(socket.o): in function 
`_D3std6socket7Service16getServiceByPortMFNbNetMAxaZb':

socket.d:(.text._D3std6socket7Service16getServiceByPortMFNbNetMAxaZb+0x30): 
warning: Using 'getservbyport' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking
```

```
Thread 10 "twitchworker" received signal SIGSEGV, Segmentation 
fault.

[Switching to LWP 965536]
0x77bd7ec0 in CONF_parse_list () from 
/opt/dell/dcc/libcrypto.so.3

(gdb) bt
#0  0x77bd7ec0 in CONF_parse_list () from 
/opt/dell/dcc/libcrypto.so.3
#1  0x77f3f152 in SSL_CTX_set_ciphersuites () from 
/opt/dell/dcc/libssl.so.3
#2  0x77f4c9df in SSL_CTX_new_ex () from