www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18526] New: Linker error when calling rt_init from C code


          Issue ID: 18526
           Summary: Linker error when calling rt_init from C code
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: mihails.strasuns gmail.com

Linux, both Ubuntu and Arch, both tarball downloads and from package manager:

$ cat main.c
extern int rt_init();

int main ( )
    return 0;
$ gcc ./main.c /path/to/druntime.a
/usr/bin/ld: error: /path/to/libdruntime.a(dmain2_65f_2f9.o): size of section
.dtors.d_dso_dtor[.data.d_dso_rec] is not multiple of address size
/usr/bin/ld: final link failed: Error reading (null): No error

Am I missing something obvious here? Adding trivial D wrapper like this:

extern(C) void rt_init ( );

extern(C) void foo ( )

.. fixes the problem, so the assumption is it is somehow related to how runtime
library is built.

Feb 26 2018