|
|
Subscribe / Log in / New account

Don't embed timestamps!

Don't embed timestamps!

Posted Nov 3, 2009 9:46 UTC (Tue) by nix (subscriber, #2304)
In reply to: Don't embed timestamps! by edmundo
Parent article: Wheeler: Fully Countering Trusting Trust through Diverse Double-Compiling

GCC has a bit of a problem right now when bootstrapping itself using C++, because anonymous namespaces have random names rather than static linkage (I have no idea why the standard felt fit to require non-static linkage for such things), which leads to each bootstrap stage differing.


to post comments

Don't embed timestamps!

Posted Nov 3, 2009 10:52 UTC (Tue) by jwakely (subscriber, #60262) [Link] (6 responses)

I think the problem is fixed, or soon will be.

Some uses of C++ templates require names with external linkage, so anonymous namespaces can be used to get similar effects to static linkage, without actually having static linkage.

Don't embed timestamps!

Posted Nov 3, 2009 11:17 UTC (Tue) by nix (subscriber, #2304) [Link] (5 responses)

Ah, a random seed option or something?

(I've been wondering what uses could possibly require external linkage for some time. It's not as if you can put things in anonymous namespaces in two different translation units and have them refer to each other, and references via function pointers don't care if you're using static linkage or not. So why is this done?)

Don't embed timestamps!

Posted Nov 3, 2009 11:47 UTC (Tue) by quotemstr (subscriber, #45331) [Link] (2 responses)

For starters, pointers used as non-type template arguments must point to things with external linkage.

Don't embed timestamps!

Posted Nov 3, 2009 14:58 UTC (Tue) by nix (subscriber, #2304) [Link] (1 responses)

But if they're in an anonymous namespace the name can't leak outside the translation unit anyway (at least not in a way which could be used at compile time to instantiate a template; only as a pointer at runtime), so this seems like a pointless requirement.

C++ templates and static functions

Posted Nov 4, 2009 17:21 UTC (Wed) by jwakely (subscriber, #60262) [Link]

See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.ht... and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19092

Apparently the restriction on calling static functions from templates was put in place to allow template instantiation to be done at link-time, using only the information available to the linker (which might not include static functions.)

At the Santa Cruz meeting of the C++ committee this issue was just closed, with a change allowing static functions to be found (noone does instantiation at link time.)

I'll stop derailing this article with off-topic comments about C++ trivia now.

Don't embed timestamps!

Posted Nov 3, 2009 16:58 UTC (Tue) by jwakely (subscriber, #60262) [Link] (1 responses)

> Ah, a random seed option or something?

That option already exists, see -frandom-seed, but shouldn't be needed to bootstrap gcc. (It is useful for users who want to compare binaries though.)

Instead, the anon namespace will still cause a random string to be part of the mangled name, but that name will no longer be used in the context that was causing bootstrap comparison failures.

Also, N.B. since GCC 4.2 "Members of the anonymous namespace are now local to a particular translation unit, along with any other declarations which use them, though they are still treated as having external linkage for language semantics." (from http://gcc.gnu.org/gcc-4.2/changes.html)
That means you get most of the benefits of static linkage, without actually having static linkage as far as the language is concerned.

Don't embed timestamps!

Posted Nov 3, 2009 20:00 UTC (Tue) by nix (subscriber, #2304) [Link]

Ah. That's what surprised me: I noticed that NEWS item going past and
assumed it meant random names were no longer used. Foolish me didn't
bother to actually check the source code though.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds