Just for fun, I gave libitm a try on alpha-dec-osf5.1b, too. Here's
what I found:
* config/alpha/sjlj.S needs trivial changes for the non-ELF/non-Linux
platform.
* Initially, all C tests were failing like this:
333619:./simple-1.exe: /sbin/loader: Error: libitm.so.0: symbol
"_ZnamRKSt9nothrow_t" unresolved
333619:./simple-1.exe: /sbin/loader: Fatal Error: Load of "./simple-1.exe"
failed: Unresolved symbol name
This happens because the platform doesn't support weak definitions
(i.e. an extern symbol declared weak working as if defined with a NULL
value), you need to provide a dummy implementation instead. To check
if it works, I'm testing __osf__ for now, but a test like the
following can be used to construct a configure test:
void weakdef (void) __attribute__ ((weak));
int
main (void)
{
if (weakdef != 0)
weakdef ();
return 0;
}
It fails to link on osf. libgfortran/acinclude.m4 (LIBGFOR_GTHREAD_WEAK)
has another test, but mostly uses a blacklist approach instead.
With those changes, libitm.so built, but with loads of problems in the
testsuite:
* Most tests fail with an ICE:
FAIL: libitm.c/cancel.c (internal compiler error)
FAIL: libitm.c/cancel.c (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/libitm/testsuite/libitm.c/cancel.c:55:1: internal
compiler error: in default_no_named_section, at varasm.c:6293
WARNING: libitm.c/cancel.c compilation failed to produce executable
I couldn't determine where tm tries to use named sections (which are
missing in ECOFF), since even gdb 7.3.1 SEGVs on cc1. This may be due
to being compiled as C++.
* All tests using <pthread.h> need an explicit -pthread:
FAIL: libitm.c/notx.c (test for excess errors)
Excess errors:
/var/gcc/regression/trunk/5.1b-gcc/build/gcc/include-fixed/pthread.h:1427:4:
error: #error "Please compile the module including pthread.h with -pthread"
WARNING: libitm.c/notx.c compilation failed to produce executable
This patch adds this unconditionally.
Even with those changes, I run into PR middle-end/50598, just as on
Solaris 8.
Rainer
2011-11-09 Rainer Orth <[email protected]>
libitm:
* config/alpha/sjlj.S (_ITM_beginTransaction) [!__ELF__]: Don't use
.hidden.
(.note.GNU-stack): Only use if __linux__.
* alloc_cpp.cc [!HAVE_WEAKDEF] (_ZnaXRKSt9nothrow_t): Dummy function.
* testsuite/libitm.c/notx.c: Use dg-options "-pthread".
* testsuite/libitm.c/reentrant.c: Likewise.
* testsuite/libitm.c/simple-2.c: Likewise.
* testsuite/libitm.c/txrelease.c: Likewise.
* testsuite/libitm.c++/static_ctor.C: Likewise.
diff --git a/libitm/alloc_cpp.cc b/libitm/alloc_cpp.cc
--- a/libitm/alloc_cpp.cc
+++ b/libitm/alloc_cpp.cc
@@ -60,6 +60,14 @@ extern void _ZdlPvRKSt9nothrow_t (void *
extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
+#ifdef __osf__ /* Really: !HAVE_WEAKDEF */
+void *
+_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p)
+{
+ return NULL;
+}
+#endif /* __osf__ */
+
/* Wrap the delete nothrow symbols for usage with a single argument.
Perhaps should have a configure type check for this, because the
std::nothrow_t reference argument is unused (empty class), and most
diff --git a/libitm/config/alpha/sjlj.S b/libitm/config/alpha/sjlj.S
--- a/libitm/config/alpha/sjlj.S
+++ b/libitm/config/alpha/sjlj.S
@@ -74,7 +74,9 @@ _ITM_beginTransaction:
.align 4
.globl GTM_longjmp
+#ifdef __ELF__
.hidden GTM_longjmp
+#endif
.ent GTM_longjmp
GTM_longjmp:
@@ -105,4 +107,6 @@ GTM_longjmp:
ret
.end GTM_longjmp
+#ifdef __linux__
.section .note.GNU-stack, "", @progbits
+#endif
diff --git a/libitm/testsuite/libitm.c++/static_ctor.C b/libitm/testsuite/libitm.c++/static_ctor.C
--- a/libitm/testsuite/libitm.c++/static_ctor.C
+++ b/libitm/testsuite/libitm.c++/static_ctor.C
@@ -1,4 +1,5 @@
/* { dg-do run } */
+/* { dg-options "-pthread" } */
/* { dg-xfail-if "" { *-*-* } { "*" } { "" } } */
/* Tests static constructors inside of transactional code. */
diff --git a/libitm/testsuite/libitm.c/notx.c b/libitm/testsuite/libitm.c/notx.c
--- a/libitm/testsuite/libitm.c/notx.c
+++ b/libitm/testsuite/libitm.c/notx.c
@@ -1,5 +1,8 @@
/* These tests all check whether initialization happens properly even if no
transaction has been used in the current thread yet. */
+
+/* { dg-options "-pthread" } */
+
#include <stdlib.h>
#include <pthread.h>
#include <libitm.h>
diff --git a/libitm/testsuite/libitm.c/reentrant.c b/libitm/testsuite/libitm.c/reentrant.c
--- a/libitm/testsuite/libitm.c/reentrant.c
+++ b/libitm/testsuite/libitm.c/reentrant.c
@@ -1,4 +1,5 @@
/* { dg-do run { xfail *-*-* } }
+/* { dg-options "-pthread" } */
/* Tests that new transactions can be started from both transaction_pure and
transaction_unsafe code. This also requires proper handling of reentrant
diff --git a/libitm/testsuite/libitm.c/simple-2.c b/libitm/testsuite/libitm.c/simple-2.c
--- a/libitm/testsuite/libitm.c/simple-2.c
+++ b/libitm/testsuite/libitm.c/simple-2.c
@@ -1,5 +1,7 @@
/* Simplest test involving real threads. Verify we get the correct answer. */
+/* { dg-options "-pthread" } */
+
#include <stdlib.h>
#include <pthread.h>
diff --git a/libitm/testsuite/libitm.c/txrelease.c b/libitm/testsuite/libitm.c/txrelease.c
--- a/libitm/testsuite/libitm.c/txrelease.c
+++ b/libitm/testsuite/libitm.c/txrelease.c
@@ -2,6 +2,8 @@
transaction data when a thread exists, potentially repeatedly. However,
we currently cannot check whether the data has indeed been released. */
+/* { dg-options "-pthread" } */
+
#include <stddef.h>
#include <stdlib.h>
#include <pthread.h>
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University