Gentoo Archives: gentoo-dev

From: "Marty E. Plummer" <hanetzer@×××××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] multilib: allow specifying the subtype of library in get_libname
Date: Fri, 03 Aug 2018 07:37:29
Message-Id: 20180803073540.g65xjqa23dhmc7tf@proprietary-killer
In Reply to: Re: [gentoo-dev] [PATCH] multilib: allow specifying the subtype of library in get_libname by Fabian Groffen
1 On Fri, Aug 03, 2018 at 09:13:35AM +0200, Fabian Groffen wrote:
2 > Just wondering, we have get_libname, get_modname, shouldn't we just
3 > introduce get_linklibname or something instead of trying to overload
4 > get_libname?
5 >
6 > The implementation of get_linklibname could be to just call get_libname
7 > for anything but mingw of course.
8 Actually that's a pretty good idea... Possibly with a warning to migrate
9 to the proper one in later eapis. Also, runtime libraries are a bit fun
10 too. for say, libFLAC(get_libname 8) on linux, you'd get libFLAC.so.8,
11 but on mingw-w64, you'd want libFLAC-8.dll on a mingw-w64 build.
12 >
13 > Fabian
14 >
15 > On 03-08-2018 00:09:41 -0500, Marty E. Plummer wrote:
16 > > Signed-off-by: Marty E. Plummer <hanetzer@×××××××××.com>
17 > > ---
18 > >
19 > > On mingw-w64 (and perhaps cygwin and mingw.org), there are two forms of
20 > > non-static libraries. Standard *.dll libraries are for runtime and are
21 > > loaded from %PATH% on windows systems, and are typically stored in
22 > > either /bin or /usr/bin on mingw-w64 cross-toolchain filesystems. Import
23 > > libraries, *.dll.a, are used when linking and live in the ''normal''
24 > > libdirs, eg, /lib, /usr/lib and so on.
25 > >
26 > > A number of ebuilds which otherwise work on mingw-w64 crossdev
27 > > toolchains exhibit failure due to usage of get_libname not being able to
28 > > specify which of the two types are required.
29 > >
30 > > For example, sys-libs/ncurses, uses the following snippet of code:
31 > > ln -sf libncurses$(get_libname) "${ED}"/usr/$(get_libdir)/libcurses$(get_libname) || die
32 > > in order to create a 'libcurses.so -> libncurses.so' symlink.
33 > >
34 > > However, on a crossdev-built mingw-w64 toolchain, one will end up with a
35 > > broken 'libcurses.dll -> libncurses.dll' symlink, which should properly
36 > > be a 'libcurses.dll.a -> libncurses.dll.a' symlink, as the symlink here
37 > > is provided to allow linking with -lcurses instead of -lncurses.
38 > >
39 > > eclass/multilib.eclass | 52 ++++++++++++++++++++++++++++++++++++++----
40 > > 1 file changed, 48 insertions(+), 4 deletions(-)
41 > >
42 > > diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
43 > > index 350b6f949d1..6a99f5977ec 100644
44 > > --- a/eclass/multilib.eclass
45 > > +++ b/eclass/multilib.eclass
46 > > @@ -239,26 +239,70 @@ get_exeext() {
47 > > }
48 > >
49 > > # @FUNCTION: get_libname
50 > > -# @USAGE: [version]
51 > > +# @USAGE: --link|--run [version]
52 > > # @DESCRIPTION:
53 > > # Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
54 > > # supplied version for the current platform identified by CHOST.
55 > > #
56 > > +# If '--link' argument is passed, the linktime library's suffix is returned,
57 > > +# as in the file that must exist to let `gcc -lfoo foo.c -o foo` to work.
58 > > +# If '--run' argument is passed, the runtime library's suffix is returned.
59 > > +#
60 > > +# In most unix-like platforms the two are identical, however on mingw-w64 the
61 > > +# linktime library has the suffix of '.dll.a' and the runtime library '.dll'.
62 > > +#
63 > > # Example:
64 > > # get_libname ${PV}
65 > > # Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
66 > > +# get_libname --link
67 > > +# Returns: .so (ELF) || .dylib (MACH) || .dll.a (PE32) || ...
68 > > get_libname() {
69 > > - local libname
70 > > - local ver=$1
71 > > + local libtype="undefined"
72 > > + local libname opt ver
73 > > + for opt; do
74 > > + case "${opt}" in
75 > > + --link)
76 > > + libtype="link"
77 > > + shift
78 > > + ;;
79 > > + --run)
80 > > + libtype="run"
81 > > + shift
82 > > + ;;
83 > > + *)
84 > > + ;;
85 > > + esac
86 > > + done
87 > > + ver="$1"
88 > > + # general unixy types
89 > > case ${CHOST} in
90 > > *-cygwin*) libname="dll.a";; # import lib
91 > > - mingw*|*-mingw*) libname="dll";;
92 > > *-darwin*) libname="dylib";;
93 > > *-mint*) libname="irrelevant";;
94 > > hppa*-hpux*) libname="sl";;
95 > > *) libname="so";;
96 > > esac
97 > >
98 > > + # wierd mingw-w64 stuff, maybe even cygwin
99 > > + case ${CHOST} in
100 > > + mingw*|*-mingw*)
101 > > + case ${libtype} in
102 > > + link)
103 > > + libname="dll.a" # import library
104 > > + ;;
105 > > + run)
106 > > + libname="dll" # runtime library
107 > > + ;;
108 > > + undefined)
109 > > + eerror "please specify either --link or --run to get_libname"
110 > > + eerror "for mingw builds, as there are two types of libraries"
111 > > + eerror "on this platform"
112 > > + die
113 > > + ;;
114 > > + esac
115 > > + ;;
116 > > + esac
117 > > +
118 > > if [[ -z $* ]] ; then
119 > > echo ".${libname}"
120 > > else
121 > > --
122 > > 2.18.0
123 > >
124 > >
125 >
126 > --
127 > Fabian Groffen
128 > Gentoo on a different level