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 <[EMAIL PROTECTED]>
* 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.am2007-04-24 16:46:17.0 -0400
+++ lt-ctortest/Makefile.am 2007-04-25 22:52:10.0 -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.0 -0500
+++ lt-ctortest/tests/ctor.at 2007-04-25 22:54:19.0 -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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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_BANNER([Constructors.])
+
+AT_SETUP([C++ static constructors])
+LT_AT_TAG([CXX])
+AT_KEYWORDS([libtool])
+
+AT_DATA(class.h,
+[[class Foo {
+public:
+ Foo() { bar = 0xaabbccdd; }
+ unsigned bar;
+};
+
+extern Foo instance;
+]])
+
+AT_DATA(libctor.cpp,
+[[#include "class.h"
+Foo instance;
+]])
+
+AT_DATA(main.cpp,
+[[#include "class.h"
+
+int main(int argc, char **argv)
+{
+ return instance.bar != 0xaabbccdd;
+}
+]])
+
+AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS
$CXXFLAGS \
+ -c libctor.cpp -o libctor.lo], [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS
$CXXFLAGS \
+ -c main.cpp -o main.lo], [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
+ libctor.lo -o libctor.la -rpath /none], [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
+ main.lo libctor.la -o main], [0], [ignore], [ignore])
+
+LT_AT_EXEC_CHECK([./main], [0])
+
+AT_CLEANUP
--
Jeff Squyres
Cisco Systems
___
Bug-libtool mailing list
Bug-libtool@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-libtool