Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#988465: ldc: using std.stdio causes static link to fail

7 views
Skip to first unread message

Witold Baryluk

unread,
May 13, 2021, 11:10:04 AM5/13/21
to
Package: ldc
Version: 1:1.24.0-2
Severity: normal
X-Debbugs-Cc: witold....@gmail.com


```
import std.stdio;
void main() {}
```

$ ldc2 -Os -static hello.d
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket25_sharedStaticCtor_L282_C1FZv: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket8Protocol17getProtocolByNameMFNbNeMAxaZb: warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket8Protocol17getProtocolByTypeMFNbNeEQBuQBt12ProtocolTypeZb: warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket7Service16getServiceByNameMFNbNeMAxaMQeZb: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket7Service16getServiceByPortMFNbNetMAxaZb: warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket12InternetHost__T7getHostVAyaa75_0a202020202020202020202020202020206175746f206865203d20676574686f737462796e616d6528706172616d2e74656d7043537472696e672829293b0a202020202020202020202020TAxaZQGpMFQjZb: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket12InternetHost__T7getHostVAyaa118_0a2020202020202020202020206175746f2078203d2068746f6e6c28706172616d293b0a2020202020202020202020206175746f206865203d20676574686f73746279616464722826782c20342c206361737428696e7429204164647265737346616d696c792e494e4554293b0a2020202020202020TkZQJwMFkZb: warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(socket.o):function _D3std6socket12InternetHost__T13getHostNoSyncVAyaa245_0a2020202020202020202020206175746f2078203d20696e65745f6164647228706172616d2e74656d7043537472696e672829293b0a202020202020202020202020656e666f726365287820213d20494e414444525f4e4f4e452c0a202020202020202020202020202020206e657720536f636b6574506172616d65746572457863657074696f6e2822496e76616c6964204950763420616464726573732229293b0a2020202020202020202020206175746f206865203d20676574686f73746279616464722826782c20342c206361737428696e7429204164647265737346616d696c792e494e4554293b0a2020202020202020TAxaZQTzMFQjZb: warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress5errorMFiZv: error: undefined reference to 'deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress6__dtorMFZv: error: undefined reference to 'deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress8compressMFAxvZQe: error: undefined reference to 'deflate'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress5flushMFiZAv: error: undefined reference to 'deflate'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress5flushMFiZAv: error: undefined reference to 'deflate'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress5flushMFiZAv: error: undefined reference to 'deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib10UnCompress5errorMFiZv: error: undefined reference to 'inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib10UnCompress6__dtorMFZv: error: undefined reference to 'inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib10UnCompress10uncompressMFAxvZQe: error: undefined reference to 'inflate'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function deflateInit2: error: undefined reference to 'deflateInit2_'
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function inflateInit2: error: undefined reference to 'inflateInit2_'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
$


That is very unfortunate.

Similar problem occur when using few other phobos modules:

std.file
std.datetime
std.encoding
std.signals
std.process

most likely because they do import transitively std.strio or std.file.

Importing other modules, like std.math, std.format, and many others does not
cause the issue.

log when executed with -v in attachement.





-- System Information:
Debian Release: 11.0
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-6-amd64 (SMP w/32 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ldc depends on:
ii libc6 2.31-12
ii libgcc-s1 10.2.1-6
ii libllvm11 1:11.0.1-2
ii libphobos2-ldc-shared-dev 1:1.24.0-2
ii libstdc++6 10.2.1-6
ii zlib1g 1:1.2.11.dfsg-2

ldc recommends no packages.

ldc suggests no packages.

-- no debconf information
hello_ldc2_static.log

Witold Baryluk

unread,
Nov 19, 2021, 1:50:04 PM11/19/21
to
Package: ldc
Version: 1:1.28.0-1+b1
Followup-For: Bug #988465
X-Debbugs-Cc: witold....@gmail.com

Still same issue in 1.28, but example now actually need to use something from stdio:

```
import std.stdio;
void main() {
writefln("Hello");
}
```
0 new messages