[Top][All Lists]

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

Re: .ctor section of shared libraries with PathScale compiler

From: Jeff Squyres
Subject: Re: .ctor section of shared libraries with PathScale compiler
Date: Thu, 26 Apr 2007 04:54:04 -0400

Noah --

Awesome; thanks!  (you code is a bit simpler than mine, which is good)

I think the only difference is that the C++ library must be a shared library. It will always work fine if the library is static. I saw some references in some of the other .at files that there is a way to figure out if Libtool was built with shared library support, but I didn't figure that part out before I sent my original patch.

On Apr 25, 2007, at 10:58 PM, Noah Misch wrote:

On Wed, Apr 25, 2007 at 12:36:23PM -0400, Jeff Squyres wrote:
I'm told that I can describe the patch in implementation-free terms
in the hope that someone else can implement it who either can setup
to transfer copyright to the FSF or already has such a transfer
agreement in place.

The patch is very simple.  It's a test that makes a shared library
containing a single instance of a class in the global scope.  The
class has a specific constructor that should be invoked before main()
(since the instance is in the global scope).  It is easy enough to
test whether the constructor has run before main(); if it has, the
test passes.  If it has not, the test fails.

Does the test this patch adds exercise the bug affecting your compiler?

2007-04-25  Noah Misch  <address@hidden>

        * tests/ctor.at: New file.
        * Makefile.am (TESTSUITE_AT): Add tests/ctor.at.

diff -NurpX dontdiff lt-bootstrap/Makefile.am lt-ctortest/Makefile.am
--- lt-bootstrap/Makefile.am    2007-04-24 16:46:17.000000000 -0400
+++ lt-ctortest/Makefile.am     2007-04-25 22:52:10.000000000 -0400
@@ -448,6 +448,7 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/nonrecursive.at \
                  tests/recursive.at \
                  tests/template.at \
+                 tests/ctor.at \
                  tests/early-libtool.at \
                  tests/deplibs-ident.at \
                  tests/stresstest.at \
diff -NurpX dontdiff lt-bootstrap/tests/ctor.at lt-ctortest/tests/ ctor.at
--- lt-bootstrap/tests/ctor.at  1969-12-31 19:00:00.000000000 -0500
+++ lt-ctortest/tests/ctor.at   2007-04-25 22:54:19.000000000 -0400
@@ -0,0 +1,66 @@
+# ctor.at -- Test constructors via C++ -*- Autotest -*-
+#   Copyright (C) 2007 Free Software Foundation, Inc.
+#   Written by Noah Misch, 2007
+#   This file is part of GNU Libtool.
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+AT_SETUP([C++ static constructors])
+[[class Foo {
+       Foo() { bar = 0xaabbccdd; }
+       unsigned bar;
+extern Foo instance;
+[[#include "class.h"
+Foo instance;
+[[#include "class.h"
+int main(int argc, char **argv)
+  return instance.bar != 0xaabbccdd;
+         -c libctor.cpp -o libctor.lo], [0], [ignore], [ignore])
+         -c main.cpp -o main.lo], [0], [ignore], [ignore])
+         libctor.lo -o libctor.la -rpath /none], [0], [ignore], [ignore])
+         main.lo libctor.la -o main], [0], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./main], [0])

Jeff Squyres
Cisco Systems

reply via email to

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