<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 23, 2017 at 12:18 PM, Joseph Rushton Wakeling <span dir="ltr"><<a href="mailto:joseph.wakeling@webdrake.net" target="_blank">joseph.wakeling@webdrake.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello all,<br>
<br>
I've encountered a couple of further issues with the ldc2 compiler snap when it's installed on a 14.04 system.  I'm sharing here to confirm if these are indeed ABI issues which might be fixable in terms of how snapcraft constructs the package.<br>
<br>
The first [1] relates to zlib, which is included as part of the D standard library.  This is built from a copy of the zlib C source and linked in to the rest of the library.<br>
<br>
However, if I try to build a program that makes use of the zlib library modules, linking fails with the following error:<br>
<br>
/usr/bin/gcc zlibtest.o -o zlibtest -L/snap/ldc2/x1/bin/../lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -lrt -ldl -lpthread -lm -m64<br>
/usr/bin/ld: /snap/ldc2/x1/bin/../lib/libph<wbr>obos2-ldc.a(zutil.c.o): unrecognized relocation (0x2a) in section `.text'<br>
/usr/bin/ld: final link failed: Bad value<br>
collect2: error: ld returned 1 exit status<br>
Error: /usr/bin/gcc failed with status: 1<br>
<br>
This matches the error message observed in a past Ubuntu issue related to binutils: <a href="https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/1545653" rel="noreferrer" target="_blank">https://bugs.launchpad.net/ubu<wbr>ntu/+source/binutils/+bug/1545<wbr>653</a><br>
<br>
which would suggest that there's a problematic mismatch between the binutils used to build snap packages versus the one available on 14.04.<br>
<br>
The second issue [2] relates to a plugin for the gold linker that is built for LDC to enable it to use link-time optimization.  This works fine on 16.04, 16.10 and 17.04, but requesting LTO on 14.04 results in linking failing:<br>
<br>
/usr/bin/gcc hello.o -o hello -Xlinker -plugin -Xlinker /snap/ldc2/x1/lib/LLVMgold-ldc<wbr>.so -Xlinker -plugin-opt=O0 -L/snap/ldc2/x1/bin/../lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -lrt -ldl -lpthread -lm -m64<br>
/usr/bin/ld: /snap/ldc2/x1/lib/LLVMgold-ldc<wbr>.so: error loading plugin: /snap/core/current/lib/x86_64-<wbr>linux-gnu/libpthread.so.0: symbol __libc_vfork, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference<br>
collect2: error: ld returned 1 exit status<br>
Error: /usr/bin/gcc failed with status: 1<br>
<br>
... which looks to me like it is probably a mismatch between the libc used to build the plugin, versus the libc of either the host system or the core snap?<br>
<br>
I would presume that both the above would need a fix either snapcraft-side or core snap side ... ?  Can anyone advise/assist?<br><br></blockquote><div><br>I think you have come to a cross roads where you will need to choose to either always use the linker from the core snap and link to things from your snap or provide multiple zlib targets for different versions of glibc (or any other library you want to link with and provide it in your snap).<br><br></div><div>If you are going to have things like /snap/core/current/lib/x86_64-<wbr>linux-gnu/libpthread.so.0 you would certainly want to use the linker in core. If you are going to use /usr/bin/gcc you probably shouldn't include libraries from `/snap/...`.<br><br></div><div>I am sorry that I cannot help you more without deep diving into your project.<br></div></div></div></div>