<div dir="ltr"><div dir="ltr">> One peculiarity with the ordering is that linkers only search static<br>
> archives for existing undefined references. If the reference to `Cffi`<br>
> actually comes first, then nothing should be required from it yet and<br>
> *it shouldn't be linked* (absent options like GNU ld's<br><div>
> `--whole-archive`).</div><div><br></div><div><span style="font-family:arial,sans-serif">Hm, this doesn't seem to be the case when I try things locally on macOS. If I try compiling this C libffi example [1] like so: </span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"> $ <span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">gcc "-L$(ghc --print-libdir)/rts" -lCffi -lffi -Wl,-dead_</span>strip_dylibs test.c -o test<br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Then `otool -L test` does not indicate a dynamic dependency on libffi.dylib:</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"> $ otool -L test<br> test:<br> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">On the other hand, if I swap the order of -lCffi and -lffi:</span></div><div><br></div><div> $ <span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">gcc "-L$(ghc --print-libdir)/rts" -lffi -lCffi -Wl,-dead_</span>strip_dylibs test.c -o test</div><div><br></div><div>Then `otool -L test` _does_ indicate a dynamic dependency on libffi.dylib:</div><div><br></div><div> $ otool -L test<br> test:<br> @rpath/libffi.dylib (compatibility version 9.0.0, current version 9.0.0)<br> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)</div><div><br></div><div>So on macOS at least, the order does seem to matter.</div><div><br></div><div>Ryan<br></div><div>-----<br></div><div>[1] <a href="https://www.chiark.greenend.org.uk/doc/libffi-dev/html/Simple-Example.html">https://www.chiark.greenend.org.uk/doc/libffi-dev/html/Simple-Example.html</a></div></div></div>