[prev in list] [next in list] [prev in thread] [next in thread] 

List:       musl
Subject:    Re: [musl] A question about pure static linking with libdl
From:       John Hu <heat0415 () gmail ! com>
Date:       2017-05-17 4:28:40
Message-ID: CAJ4NsxR1dQ7ArecW5F3Xn1qNo4qOeHK1Wk0+MZ2--mYu+neV1g () mail ! gmail ! com
[Download RAW message or body]

Dear Mr.Nagy,

First thanks for your sincere reply but I still have some questions. The
reason why I do this test is that I want to build my project on my machine
and distribute it to any other Linux (I can't ask other people to compile
my project on their machine, that is totally unacceptable). I think full
static linking can do this. Since full static linking does not support
dlopen I made another test: generate ld.gold that ONLY dynamic links with
musl-libc(libc.so) and so does LLVMgold.so. Then I copy them to Ubuntu
16.04 and exec ldd command on both and I found that "libc.musl-x86_64.so.1
=> not found"  in the output. Finally I exec "./ld.gold --plugin
LLVMgold.so" and an error occurred that "could not load plugin library:
libc.musl-x86_64.so.1: cannot open shared object file: No such file or
directory". I test the basic function of these two files that works well
because they can find glibc ld.so on Ubuntu16.04 as ldd shows.
Now I have no idea how to workaround this problem, my question is that
whether there is a way that generating some binary executable files in one
system and they are portable and compatible on any other Linux
distributions (means these binary files can run normally without any
problem).

2017-05-16 18:30 GMT+08:00 Szabolcs Nagy <nsz@port70.net>:

> * John Hu <heat0415@gmail.com> [2017-05-16 15:40:28 +0800]:
> > Recently I have an experiment about whether full static-linked ld.gold
> with
> > plugin function enabled can use its --plugin option to dynamically load
> > plugins such as LLVMgold.so. I use "./configure --enable --enable-plugins
> > --disable-werror LDFLAGS="-static" "  to generate a full statically
> linked
> > ld.gold which does not have any dynamic library dependency, then I exec
> > "./ld.gold --plugin LLVMgold.so" but an error occurs that "could not load
> > plugin library: Dynamic loading not supported". I doubt this is a bug
> > because it is claimed that musl supports full static linking but I am not
> > sure about that. BTW, my experiment environment is Alpine 3.5.
>
> dlopen is not supported in static linked binaries yet, that is non-trivial
> to support and in your use case it does not make sense: the loaded lib is
> linked against the host libc (and many other libs) and is in a package that
> is updated independently of the libc, there is no guarantee that the static
> linked libc is compatible with the host libc (and if there is then you
> don't really need static linking anyway, you could get the same effect
> by using your custom libc to launch ld.gold as ./mylibc.so ld-gold ).
>
> >
> > Now I send this email again because I want this email to be replied
> > according to "If you are not subscribed and want to receive a reply,
> please
> > mention in your email that you want to be Cc'd." in the website.
>

[Attachment #3 (text/html)]

<div dir="ltr">Dear Mr.Nagy,<div><br></div><div>First thanks for your sincere reply \
but I still have some questions. The reason why I do this test is that I want to \
build my project on my machine and distribute it to any other Linux (I can&#39;t ask \
other people to compile my project on their machine, that is totally unacceptable). I \
think full static linking can do this. Since full static linking does not support \
dlopen I made another test: generate ld.gold that ONLY dynamic links with \
musl-libc(libc.so) and so does LLVMgold.so. Then I copy them to Ubuntu 16.04 and exec \
ldd command on both and I found that &quot;libc.musl-x86_64.so.1 =&gt; not \
found&quot;   in the output. Finally I exec &quot;./ld.gold --plugin \
LLVMgold.so&quot; and an error occurred that &quot;could not load plugin library: \
libc.musl-x86_64.so.1: cannot open shared object file: No such file or \
directory&quot;. I test the basic function of these two files that works well because \
they can find glibc ld.so on Ubuntu16.04 as ldd shows.</div><div>Now I have no idea \
how to workaround this problem, my question is that whether there is a way that \
generating some binary executable files in one system and they are portable and \
compatible on any other Linux distributions (means these binary files can run \
normally without any problem).</div><div class="gmail_extra"><br><div \
class="gmail_quote">2017-05-16 18:30 GMT+08:00 Szabolcs Nagy <span dir="ltr">&lt;<a \
href="mailto:nsz@port70.net" \
target="_blank">nsz@port70.net</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* John Hu \
&lt;<a href="mailto:heat0415@gmail.com">heat0415@gmail.com</a>&gt; [2017-05-16 \
15:40:28 +0800]:<br> <span class="">&gt; Recently I have an experiment about whether \
full static-linked ld.gold with<br> &gt; plugin function enabled can use its --plugin \
option to dynamically load<br> &gt; plugins such as LLVMgold.so. I use \
&quot;./configure --enable --enable-plugins<br> &gt; --disable-werror \
LDFLAGS=&quot;-static&quot; &quot;   to generate a full statically linked<br> &gt; \
ld.gold which does not have any dynamic library dependency, then I exec<br> &gt; \
&quot;./ld.gold --plugin LLVMgold.so&quot; but an error occurs that &quot;could not \
load<br> &gt; plugin library: Dynamic loading not supported&quot;. I doubt this is a \
bug<br> &gt; because it is claimed that musl supports full static linking but I am \
not<br> &gt; sure about that. BTW, my experiment environment is Alpine 3.5.<br>
<br>
</span>dlopen is not supported in static linked binaries yet, that is non-trivial<br>
to support and in your use case it does not make sense: the loaded lib is<br>
linked against the host libc (and many other libs) and is in a package that<br>
is updated independently of the libc, there is no guarantee that the static<br>
linked libc is compatible with the host libc (and if there is then you<br>
don&#39;t really need static linking anyway, you could get the same effect<br>
by using your custom libc to launch ld.gold as ./mylibc.so ld-gold ).<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt; Now I send this email again because I want this email to be replied<br>
&gt; according to &quot;If you are not subscribed and want to receive a reply, \
please<br> &gt; mention in your email that you want to be Cc&#39;d.&quot; in the \
website.<br> </div></div></blockquote></div><br></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic