This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: readline build questions


Brian Dessent wrote:
> Unfortunately, yes.  A call to a function explicitly declared dllimport
> can only be satisfied by linking to a DLL containing that function, as
> essentially the compiler has inlined the indirection of the thunk stub
> into the call site.  So the client of such a library needs an explicit
> compile-time way of declaring intent to link statically, removing the
> __declspec.

Well...there IS another way. If you look at the build machinery of
gettext and libiconv, Bruno Haible has implemented a mechanism where ALL
of the library's symbols are ALWAYS decorated using declspec(dllimport)
-- whether the client is linking statically or dynamically.  However,
when building the static library, he has a bit of magic that explicitly
synthesizes the _imp_* symbols.

This still requires all symbols in the headers to be "uglified" with
some READLINE_IMPEXP symbol, that is "" on non-win32, but
unconditionally becomes declspec(dllimport) on win32.

> You could make the argument that any consumers of libreadline in the
> distro should already be using the shared version anyway on general
> principle, so this shouldn't affect them.  But then there could be
> potential users that want to statically link it into their own
> programs.  I'd say continue to provide the static version, but just note
> in the readme the new requirement to configure with
> CPPFLAGS=-DREADLINE_STATIC if they intend to statically link.  It's a
> reasonable request given that it's not an uncommon idiom which is found
> in other libraries, and it fixes a real bug.  (What's more, if anyone
> complains you can tell them that the alternative under consideration was
> simple removal of the static version in We're Just Mean fashion.)

Wow. Full circle: back before we had auto-import, I used to maintain
libreadline in exactly this fashion. It was a PAIN -- I sympathize with
Eric, because readline has a LOT of symbols that need decorating if you
go that route.

Further, Chet Ramey felt strongly about NOT uglifying the code with
those READLINE_IMPEXP symbols everywhere, so at the time those changes
were forever destined to be maintained out-of-tree, by hand. I don't
know if Chet has relaxed his position...if not, then I recommend that
Eric do the following (unless he's just a glutton for punishment):

1) Don't explicitly mark symbols as declspec(foo), unless Chet is
willing to accept the changes
2) Do pointer comparisons explicitly against _imp_foo. This will break
static builds, but at least it will be a much smaller out-of-tree patch
to maintain in perpetuity.
3) Drop the static library.

The only non-painful alternative is *if* Chet accepts the
READLINE_IMPEXP uglifications, then you should consider some of the
other options, such as requiring -DREADLINE_STATIC, or attempting to
duplicate Bruno's machinery.

--
Chuck


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]