digitalmars.D.ldc - How to get ldc2 to link dynamically to Phobos
- Shriramana Sharma (28/28) Oct 17 2015 W.r.t. my recent thread
- David Nadlinger via digitalmars-d-ldc (16/24) Oct 18 2015 This is a restriction in our current build system that could be easily
W.r.t. my recent thread http://forum.dlang.org/post/mvt67j$3dg$1 digitalmars.com on Phobos still being statically linked in, it was suggested that I should use the - defaultlib=libphobos2.so option. This works fine with DMD 2.068.2 but I'm not sure how to get it working with LDC. LDC doesn't seem to ship with a compiled Phobos SO so I just symlinked it from DMD's one (not sure whether that is compatible or not though): $ pwd /opt/ldc2-0.16.0-beta2-linux-x86_64/lib $ ls -l total 51956 -rw-r--r-- 1 samjnaa samjnaa 2403108 Oct 10 18:25 libdruntime-ldc.a -rw-r--r-- 1 samjnaa samjnaa 4822716 Oct 10 18:25 libdruntime-ldc-debug.a -rw-r--r-- 1 samjnaa samjnaa 15820544 Oct 10 18:28 libphobos2-ldc.a -rw-r--r-- 1 samjnaa samjnaa 30150532 Oct 10 18:29 libphobos2-ldc-debug.a lrwxrwxrwx 1 samjnaa samjnaa 18 Oct 18 08:19 libphobos2.so -> libphobos2.so.0.68 lrwxrwxrwx 1 samjnaa samjnaa 20 Oct 18 08:19 libphobos2.so.0.68 -> libphobos2.so.0.68.2 lrwxrwxrwx 1 samjnaa samjnaa 46 Oct 18 08:18 libphobos2.so.0.68.2 -> /usr/lib/x86_64-linux-gnu/libphobos2.so.0.68.2 ... but anyhow I keep getting the error: /usr/bin/ld: cannot find -llibphobos2.so collect2: error: ld returned 1 exit status Error: /usr/bin/gcc failed with status: 1 BTW why is LDC using gcc and not clang to link? --
Oct 17 2015
On 18 Oct 2015, at 5:07, Shriramana Sharma via digitalmars-d-ldc wrote:LDC doesn't seem to ship with a compiled Phobos SOThis is a restriction in our current build system that could be easily lifted by some refactoring; I wish somebody would take care of it (*hint, hint*).so I just symlinked it from DMD's one (not sure whether that is compatible or not though):It is not; not even between different releases of the same compiler.... but anyhow I keep getting the error: /usr/bin/ld: cannot find -llibphobos2.so collect2: error: ld returned 1 exit status Error: /usr/bin/gcc failed with status: 1Seems like that's an invalid linker command, right? (DMD might detect whether you pass a whole file name, but I'm not sure we do, although I vaguely remember Kai working on something to that effect.)BTW why is LDC using gcc and not clang to link?Because all we really care about is that it is a gcc-compatible C compiler that knows where to find its standard libraries. If not for the latter, we'd use the system linker directly. As for "gcc" vs. "clang", it turns out that for example on OS X, where Clang is the default, there is still a "gcc" symlink for compatibility purposes anyway (FreeBSD doesn't have one, though, IIRC). And on Linux, GCC is still more widespread than Clang, so simply using "gcc" just works on most systems. — David
Oct 18 2015