bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FW: [PATCH] Fix optional variables in libargp


From: Fedin Pavel
Subject: FW: [PATCH] Fix optional variables in libargp
Date: Thu, 18 Jul 2013 17:55:15 +0400

 Hello!

 Cygwin guys suggested me to post this patch here. The patch allows
redefinition of four global variables related to argp_parse() to work on
Windows platform without code modification.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia


-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of
Fedin Pavel
Sent: Wednesday, July 17, 2013 10:32 AM
To: 'Andrew Schulman'; address@hidden
Subject: [PATCH] Fix optional variables in libargp

 Hello!

> Okay, well I agree that this sounds like a good solution.  For now you 
> have a workaround, and I'll be glad to consider a patch if you submit 
> one.

 Please take it. This is my experimental implementation which appears to be
simpler than i suggested.

 Some details: this implementation adds explicit dllexport attribute to
these 4 variables. This allows to look them up using GetProcAddress(). The
dllexport attribute has to be added explicitly because when compiling an
.exe file (without -shared switch) gcc does not mark externals as exportable
by default. When building a .dll, all external symbols are marked as
exportable by default, *UNLESS* we have at least one explicit dllexport
specification, hence i surrounded this with #ifndef DLL_EXPORT, this
definition is introduced by libtool when building a shared library.
 This implementation would not work in the following corner cases:
 a) .exe file uses some foo.dll library, which defines these variables and
uses libargp - symbols are picked up only from .exe file itself.
 b) Building that foo.dll manually without DLL_EXPORT definition can get
broken - the compiler will see dllexport attribute, and it will override the
default behavior to make all externs exportable.
 I believe these cases are quite unusual so it's OK. Getting rid of these
limitations would need more complex implementation with more changes.

 I have tested the implementation on x86-64 with RedHat's Prelink utility,
and it works quite fine. i386 should work too, but please retest, just in
case.

 Additionally, i added the second #ifdef _WIN32 in order to make the same
thing working also for MinGW target.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

Attachment: libargp-20110921-fix-optional-variables.diff
Description: Binary data

Attachment: ATT00047.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]