<div dir="ltr">Hi Bert,<div><br></div><div>    its necessary because the VM and the image must use the same libc.so, and to do that reliably one needs to specify a LD_LIBRARY_PATH that will include the directory containing the actual libc.so in use by the VM first.  LD_LIBRARY_PATH may need to be set by the user, e.g. to pick up specific versions of plugins or support libraries but if that LD_LIBRARY_PATH doesn&#39;t include the right dir for libc then the image may load the wrong libc and things will break.  This is a real case that Cadence customers saw in using a complex application that uses a number of C libraries.  i.e. even if my explanation sounds waffly there&#39;s actual experience behind it :)</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 8, 2013 at 12:35 PM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Why is this even necessary? To look up libc functions we used to leave the module name empty in the FFI declaration, so it wouldn&#39;t ever need to know the exact location of libc. This used to end up in a dlopen() call with a null file name.<br>

<span class="HOEnZb"><font color="#888888"><br>
- Bert -<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 08.01.2013, at 11:57, <a href="mailto:commits@squeakvm.org">commits@squeakvm.org</a> wrote:<br>
<br>
&gt;<br>
&gt; Revision: 2661<br>
&gt; Author:   eliot<br>
&gt; Date:     2013-01-08 11:57:41 -0800 (Tue, 08 Jan 2013)<br>
&gt; Log Message:<br>
&gt; -----------<br>
&gt; Add yet another libc line to the linux launch script(s), and try and make the<br>
&gt; script suggest users extend it themselves.  you can lead a horse to water...<br>
&gt; Rationalize the includes in sqUnixUUID.c.<br>
&gt;<br>
&gt; Modified Paths:<br>
&gt; --------------<br>
&gt;    branches/Cog/platforms/unix/config/<a href="http://bin.squeak.sh.in" target="_blank">bin.squeak.sh.in</a><br>
&gt;    branches/Cog/platforms/unix/config/<a href="http://squeak.sh.in" target="_blank">squeak.sh.in</a><br>
&gt;    branches/Cog/platforms/unix/plugins/UUIDPlugin/sqUnixUUID.c<br>
&gt;<br>
&gt; Property Changed:<br>
&gt; ----------------<br>
&gt;    branches/Cog/platforms/Cross/vm/sqSCCSVersion.h<br>
&gt;<br>
&gt;<br>
&gt; Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h<br>
&gt; ___________________________________________________________________<br>
&gt; Modified: checkindate<br>
&gt;   - Mon Jan  7 13:52:47 PST 2013<br>
&gt;   + Tue Jan  8 11:56:08 PST 2013<br>
&gt;<br>
&gt; Modified: branches/Cog/platforms/unix/config/<a href="http://bin.squeak.sh.in" target="_blank">bin.squeak.sh.in</a><br>
&gt; ===================================================================<br>
&gt; --- branches/Cog/platforms/unix/config/<a href="http://bin.squeak.sh.in" target="_blank">bin.squeak.sh.in</a>       2013-01-07 21:54:37 UTC (rev 2660)<br>
&gt; +++ branches/Cog/platforms/unix/config/<a href="http://bin.squeak.sh.in" target="_blank">bin.squeak.sh.in</a>       2013-01-08 19:57:41 UTC (rev 2661)<br>
&gt; @@ -14,15 +14,18 @@<br>
&gt; # libc (e.g. through the FFI) then it must use the same version that the VM uses<br>
&gt; # and so it should take precedence over /lib libc.  This is done by setting<br>
&gt; # LD_LIBRARY_PATH appropriately, based on ldd&#39;s idea of the libc use by the VM.<br>
&gt; -case `/usr/bin/ldd &quot;$BIN/squeak&quot; | /bin/fgrep /libc. | sed &#39;s/^.*=&gt; //&#39;` in<br>
&gt; +LIBC_SO=&quot;`/usr/bin/ldd &quot;$BIN/squeak&quot; | /bin/fgrep /libc. | sed &#39;s/^.*=&gt; //&#39;`&quot;<br>
&gt; +case &quot;$LIBC_SO&quot; in<br>
&gt; /lib/libc*)                                   SVMLLP=&quot;/lib:/usr/lib&quot;;;<br>
&gt; /lib32/libc*)                         SVMLLP=&quot;/lib32:/usr/lib32&quot;;;<br>
&gt; /lib64/libc*)                         SVMLLP=&quot;/lib64:/usr/lib64&quot;;;<br>
&gt; /lib/tls/libc*)                               SVMLLP=&quot;/lib/tls:/lib:/usr/lib/tls:/usr/lib&quot;;;<br>
&gt; /lib/i386-linux-gnu/libc*)    \<br>
&gt; -     SVMLLP=&quot;/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu&quot;;;<br>
&gt; +     SVMLLP=&quot;/lib/i386-linux-gnu:/lib:/usr/lib/i386-linux-gnu:/usr/lib&quot;;;<br>
&gt; /lib/tls/i686/cmov/libc*)     \<br>
&gt;       SVMLLP=&quot;/lib/tls/i686/cmov:/lib:/usr/lib/tls/i686/cmov:/usr/lib&quot;;;<br>
&gt; +/lib/386-linux-gnu/i686/cmov/libc*)  \<br>
&gt; +     SVMLLP=&quot;/lib/386-linux-gnu/i686/cmov:/lib:/usr/lib/386-linux-gnu/i686/cmov:/usr/lib&quot;;;<br>
&gt; /lib/tls/i686/nosegneg/libc*) \<br>
&gt;       SVMLLP=&quot;/lib/i686/nosegneg/tls:/lib:/usr/lib/i686/nosegneg/tls:/usr/lib&quot;;;<br>
&gt; &quot;&quot;)   case `/bin/uname -m || /usr/bin/uname -m` in<br>
&gt; @@ -30,7 +33,7 @@<br>
&gt;       *)      echo &quot;/usr/bin/ldd didn&#39;t produce any output. Can&#39;t infer base LD_LIBRARY_PATH. Aborting.&quot; 1&gt;&amp;2<br>
&gt;       esac<br>
&gt;       exit 1;;<br>
&gt; -*)   echo &quot;Can&#39;t infer base LD_LIBRARY_PATH. Aborting.&quot; 1&gt;&amp;2<br>
&gt; +*)   echo &quot;Can&#39;t infer base LD_LIBRARY_PATH. Aborting. Try adding a line for $LIBC_SO to $0. Please report your edit to squeak vm-dev.&quot; 1&gt;&amp;2<br>
&gt;       exit 1<br>
&gt; esac<br>
&gt; # prepending is less flexible but safer because it ensures we find the plugins<br>
&gt;<br>
&gt; Modified: branches/Cog/platforms/unix/config/<a href="http://squeak.sh.in" target="_blank">squeak.sh.in</a><br>
&gt; ===================================================================<br>
&gt; --- branches/Cog/platforms/unix/config/<a href="http://squeak.sh.in" target="_blank">squeak.sh.in</a>   2013-01-07 21:54:37 UTC (rev 2660)<br>
&gt; +++ branches/Cog/platforms/unix/config/<a href="http://squeak.sh.in" target="_blank">squeak.sh.in</a>   2013-01-08 19:57:41 UTC (rev 2661)<br>
&gt; @@ -14,15 +14,18 @@<br>
&gt; # libc (e.g. through the FFI) then it must use the same version that the VM uses<br>
&gt; # and so it should take precedence over /lib libc.  This is done by setting<br>
&gt; # LD_LIBRARY_PATH appropriately, based on ldd&#39;s idea of the libc use by the VM.<br>
&gt; -case `/usr/bin/ldd &quot;$BIN/squeak&quot; | /bin/fgrep /libc. | sed &#39;s/^.*=&gt; //&#39;` in<br>
&gt; +LIBC_SO=&quot;`/usr/bin/ldd &quot;$BIN/squeak&quot; | /bin/fgrep /libc. | sed &#39;s/^.*=&gt; //&#39;`&quot;<br>
&gt; +case &quot;$LIBC_SO&quot; in<br>
&gt; /lib/libc*)                                   SVMLLP=&quot;/lib:/usr/lib&quot;;;<br>
&gt; /lib32/libc*)                         SVMLLP=&quot;/lib32:/usr/lib32&quot;;;<br>
&gt; /lib64/libc*)                         SVMLLP=&quot;/lib64:/usr/lib64&quot;;;<br>
&gt; /lib/tls/libc*)                               SVMLLP=&quot;/lib/tls:/lib:/usr/lib/tls:/usr/lib&quot;;;<br>
&gt; /lib/i386-linux-gnu/libc*)    \<br>
&gt; -     SVMLLP=&quot;/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu&quot;;;<br>
&gt; +     SVMLLP=&quot;/lib/i386-linux-gnu:/lib:/usr/lib/i386-linux-gnu:/usr/lib&quot;;;<br>
&gt; /lib/tls/i686/cmov/libc*)     \<br>
&gt;       SVMLLP=&quot;/lib/tls/i686/cmov:/lib:/usr/lib/tls/i686/cmov:/usr/lib&quot;;;<br>
&gt; +/lib/386-linux-gnu/i686/cmov/libc*)  \<br>
&gt; +     SVMLLP=&quot;/lib/386-linux-gnu/i686/cmov:/lib:/usr/lib/386-linux-gnu/i686/cmov:/usr/lib&quot;;;<br>
&gt; /lib/tls/i686/nosegneg/libc*) \<br>
&gt;       SVMLLP=&quot;/lib/i686/nosegneg/tls:/lib:/usr/lib/i686/nosegneg/tls:/usr/lib&quot;;;<br>
&gt; &quot;&quot;)   case `/bin/uname -m || /usr/bin/uname -m` in<br>
&gt; @@ -30,7 +33,7 @@<br>
&gt;       *)      echo &quot;/usr/bin/ldd didn&#39;t produce any output. Can&#39;t infer base LD_LIBRARY_PATH. Aborting.&quot; 1&gt;&amp;2<br>
&gt;       esac<br>
&gt;       exit 1;;<br>
&gt; -*)   echo &quot;Can&#39;t infer base LD_LIBRARY_PATH. Aborting.&quot; 1&gt;&amp;2<br>
&gt; +*)   echo &quot;Can&#39;t infer base LD_LIBRARY_PATH. Aborting. Try adding a line for $LIBC_SO to $0. Please report your edit to squeak vm-dev.&quot; 1&gt;&amp;2<br>
&gt;       exit 1<br>
&gt; esac<br>
&gt; # prepending is less flexible but safer because it ensures we find the plugins<br>
&gt;<br>
&gt; Modified: branches/Cog/platforms/unix/plugins/UUIDPlugin/sqUnixUUID.c<br>
&gt; ===================================================================<br>
&gt; --- branches/Cog/platforms/unix/plugins/UUIDPlugin/sqUnixUUID.c       2013-01-07 21:54:37 UTC (rev 2660)<br>
&gt; +++ branches/Cog/platforms/unix/plugins/UUIDPlugin/sqUnixUUID.c       2013-01-08 19:57:41 UTC (rev 2661)<br>
&gt; @@ -3,12 +3,12 @@<br>
&gt; #if defined(HAVE_SYS_UUID_H)<br>
&gt; # include &lt;sys/types.h&gt;<br>
&gt; # include &lt;sys/uuid.h&gt;<br>
&gt; -#endif<br>
&gt; -#if defined(HAVE_UUID_UUID_H)<br>
&gt; +#elif defined(HAVE_UUID_UUID_H)<br>
&gt; # include &lt;uuid/uuid.h&gt;<br>
&gt; -#endif<br>
&gt; -#if defined(HAVE_UUID_H)<br>
&gt; +#elif defined(HAVE_UUID_H)<br>
&gt; # include &lt;uuid.h&gt;<br>
&gt; +#else<br>
&gt; +# error cannot find a uuid.h to include<br>
&gt; #endif<br>
&gt;<br>
&gt; #include &quot;sq.h&quot;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div>