jacob-carlborg/dvm

symlinks for libs on Linux (e.g.) are not properly done

Opened this issue · 3 comments

The symlinks for dynamic libs are not extracted correctly

E.g.:

$ ls -l ~/.dvm/compilers/dmd-2.100.2/linux/lib64/
total 64224
-rw-rw-r-- 1 steves steves 56738472 Sep 10 06:02 libphobos2.a
-rw-rw-r-- 1 steves steves       21 Sep 10 06:02 libphobos2.so
-rw-rw-r-- 1 steves steves       21 Sep 10 06:02 libphobos2.so.0.100
-rw-rw-r-- 1 steves steves  9012616 Sep 10 06:02 libphobos2.so.0.100.2

It should look like this:

-rw-rw-r-- 1 steves steves 56738472 Sep 10 06:02 libphobos2.a
lrwxrwxrwx 1 steves steves       21 Sep 20 23:37 libphobos2.so -> libphobos2.so.0.100.2
lrwxrwxrwx 1 steves steves       21 Sep 20 23:37 libphobos2.so.0.100 -> libphobos2.so.0.100.2
-rw-rw-r-- 1 steves steves  9012616 Sep 10 06:02 libphobos2.so.0.100.2

This results in a failure when you try to use the shared lib version of phobos:

$ dmd -defaultlib=libphobos2.so prog.d
/usr/bin/ld:/home/steves/.dvm/compilers/dmd-2.100.2/linux/bin/../lib64/libphobos2.so: file format not recognized; treating as linker script
/usr/bin/ld:/home/steves/.dvm/compilers/dmd-2.100.2/linux/bin/../lib64/libphobos2.so:0: syntax error

Hmm, it's probably the Tango ZIP module that doesn't support symlinks. It should be replaced with the one in Phobos.

It's probably an issue with the API. I don't know what Tango does, but dub has the same exact problem, and it uses std.zip. I'm going to put in a fix for that, as I need it in the case of one project.

The issue with dub is that the zip API doesn't have a "just extract this file the same as it would be if you did unzip on the command line" function, it just gives you the bytes and the file attributes. It's possible to check the attributes to see if it's a symlink, and then call the symlink function, but the current code just writes the bytes to a file, and then applies the attributes (which doesn't magically turn it into a symlink).

FYI, this is the fix in dub: dlang/dub#2489