dlang-community / D-YAML

YAML parser and emitter for the D programming language
https://dlang-community.github.io/D-YAML/
Boost Software License 1.0
119 stars 38 forks source link

Linker options in dyaml.pc not correct? #137

Open russel opened 6 years ago

russel commented 6 years ago

The libgtkd-3-dev package on Debian Sid installs /usr/lib/x86_64-linux-gnu/pkgconfig/gtkd-3.pc:

Name: GtkD
Description: A D binding and OO wrapper for GTK+.
Version: 3.8.2
Libs: -L-L/usr/lib/x86_64-linux-gnu/ -L-lgtkd-3 -L-ldl
Cflags: -I/usr/include/d/gtkd-3/

which works for dmd and ldc2, I suspect perhaps not for gdc. D-YAML creates:

prefix=/home/users/russel/Built
libdir=${prefix}/lib
includedir=${prefix}/include

Name: dyaml
Description: YAML parser and emitter for the D programming language.
Version: 0.6.5
Requires.private: tinyendian
Libs: -L${libdir} -ldyaml
Cflags: -I${includedir}/d/yaml

Which doesn't work fordmd or ldc2 without adding a -L in front of the Libs options. So who has it right GtkD or D-YAML?

ximion commented 6 years ago

Both, actually, although GtkD is probably a bit more correct. Since D has no ABI stability and you can't use any library compiled with one D compiler with code compiled with another D compiler, the libraries and therefore the .pc files are generally tied to the respective compiler and compiler version that the code was originally compiled with.

In pkg-config files, we generally expect GCC/Clang compatible compiler flags, which makes the dyaml case correct. At the same time though, ldc and dmd are not fully compatible to GCC/Clang's arguments, therefore GtkD could be correct.

What actually happens though is that at least when using Meson, Meson will transparently convert the flags to whatever the currently used D compiler is comfortable with, and AFAIK dub will do the same.

russel commented 6 years ago

OK. I am stuck with Dub and SCons for build since Meson cannot build Unit-Threaded stuff because there is no unitary build. (I just do a small hack for the SCons build which is irritating but I can cope.)

ximion commented 6 years ago

Meson supports unity builds, but the D support likely doesn't. Implementing this should be easy though.

DMD and LDC not following GCC/Clang flags is an incredible nuisance, so much so that we actually ship a script in Debian as part of the dlang debhelper support to work around this issue. Dub should actually already deal with pkg-config flags correctly, if not this should be fixed. For SCons, you might find the code we ship in Debian as part of our packaging helpers useful: https://salsa.debian.org/d-team/dh-dlang/blob/master/gcc-to-ldc-flags.py (it's a hack, but the best we got at time to work around the compiler flag differences).