From: David Stacey <drstacey@tiscali.co.uk>
To: cygwin@cygwin.com
Subject: Re: static vs. shared linking
Date: Sat, 11 Apr 2015 19:21:00 -0000 [thread overview]
Message-ID: <5529742A.7000902@tiscali.co.uk> (raw)
In-Reply-To: <5526EFDE.4090901@cygwin.com>
On 09/04/15 22:32, Larry Hall (Cygwin) wrote:
> On 04/09/2015 04:15 AM, David Stacey wrote:
>
> <snip>
>
>> I can't believe that I'm the first person to fall foul of this - any
>> library
>> that relies heavily on templates risks falling into the same trap.
>
> <snip>
>
> It's true that someone using STL strings has the potential to see this
> bug
> but I doubt there are allot of template libraries out there pulling
> the same
> memory trick or doing so with the same catastrophic results.
It's going to affect all templates that have a static member variable,
where an instantiation of said template is passed across a DLL boundary.
Maybe there aren't too many of those.
> In addition,
> this is not the first time this has come up as an issue (for Cygwin or
> other
> platforms) in one form or another. Here's a good reference:
>
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16612>
Wow - that was an interesting read, thank you! Obviously a different
context, but most definitely the same problem. It looks as though I
stumbled into a bear trap that's been around for at least ten years.
> There they recommend the "--enable-fully-dynamic-string" flag as a
> solution
> for this particular problem but I agree if the "-frepo" will solve
> this as
> well, it's better because it manages templates better overall and aligns
> with Linux behavior.
I'm not sure I like '--enable-fully-dynamic-string', because it changes
the API of std::string, and the two APIs are not interchangeable. So a
library compiled with '--enable-fully-dynamic-string' can't be used with
code that omitted that compiler option. You have to use it everywhere or
not at all.
Poco is a network-centric library for other programmes to use. If I were
to use '--enable-fully-dynamic-string' in compiling Poco then that would
force users of the Poco library to use that compiler option too. And if,
at the same time, they tried to link against another C++ API that wasn't
built that way then the code wouldn't link - or if it did link it would
crash when run.
So I either have to use '-frepo' or explicitly export the templates that
Poco uses. '-frepo' might take longer to compile, and I suspect that it
will force users of Poco to compile with '-frepo' as well. But it's
guaranteed to catch other templates that I might have missed, and it
will work with other C++ libraries that weren't built with
'--enable-fully-dynamic-string'. So I'll stick with '-frepo'.
Anyway, thanks again for the link - interesting stuff.
Dave.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2015-04-11 19:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 8:07 David Stacey
2015-03-24 18:50 ` David Stacey
2015-03-25 9:17 ` Corinna Vinschen
2015-03-25 17:10 ` Warren Young
2015-03-25 22:42 ` David Stacey
2015-03-25 23:28 ` David Stacey
2015-03-25 22:48 ` David Stacey
2015-03-30 11:04 ` Corinna Vinschen
2015-03-30 19:17 ` David Stacey
2015-03-30 23:02 ` Andrey Repin
2015-03-31 0:50 ` David Stacey
2015-03-31 3:26 ` Andrey Repin
2015-03-31 9:05 ` Achim Gratz
2015-03-31 10:04 ` Corinna Vinschen
2015-03-31 9:07 ` Corinna Vinschen
2015-03-31 18:00 ` David Stacey
2015-04-09 8:15 ` David Stacey
2015-04-09 17:24 ` Corinna Vinschen
2015-04-11 18:51 ` David Stacey
2015-04-09 21:32 ` Larry Hall (Cygwin)
2015-04-11 19:21 ` David Stacey [this message]
2015-03-25 23:29 ` David Stacey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5529742A.7000902@tiscali.co.uk \
--to=drstacey@tiscali.co.uk \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).