pthread problems with gcc 4.1 includes?

I'm trying to build an app with clang against libraries that are using
GCC 4.1 ABI.

I'm getting an error "weakref declaration must have internal linkage"

Now I'm stumped though, perhaps it is an incompatibility between clang
trunk and gcc 4.1 include files?

- I've built clang from trunk
- fixed include paths to point to gcc 4.1 include paths

When I modify clang to use gcc 4.5 include files, then the file below builds.

clang -v -x c++ /dev/null -fsyntax-only
clang version 3.0 (trunk 134402)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/usr/local/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu
-fsyntax-only -disable-free -main-file-name null -mrelocation-model
static -mdisable-fp-elim -masm-verbose -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -target-linker-version
2.21.0.20110327 -momit-leaf-frame-pointer -v -resource-dir
/usr/local/bin/../lib/clang/3.0 -fdeprecated-macro -ferror-limit 19
-fmessage-length 80 -fgnu-runtime -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -x c++ /dev/null
clang -cc1 version 3.0 based upon llvm 3.0svn hosted on x86_64-unknown-linux-gnu
ignoring nonexistent directory "/usr/include/i686-linux-gnu/64"
ignoring nonexistent directory "/usr/include/i486-linux-gnu/64"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
/usr/local/include
/usr/local/gcc-4.1/include
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/include
/usr/include
/usr/local/bin/../lib/clang/3.0/include
/usr/include/x86_64-linux-gnu
End of search list.

clang -o /home/oyvind/oharboe/build/git/testautomation/linux-amd64-gcc_4_1-debug/testsuite/test.os
-c -fPIC -g -W -Wall -m64 -fPIC -DQT_NO_CAST_TO_ASCII -DDEBUG -DLINUX
-DLITTLEENDIAN -DQT -DQT_THREAD_SUPPORT -DQT3_SUPPORT -DQT_DEBUG
-DBOOST_ALL_NO_LIB -I.
-I/home/oyvind/oharboe/packages/linux-amd64-gcc_4_1/qt-4_7_1_patched/include
-I/home/oyvind/oharboe/packages/linux-amd64-gcc_4_1/qt-4_7_1_patched/mkspecs/linux-g++-64
-I/home/oyvind/oharboe/packages/linux-amd64-gcc_4_1/boost-1_37_0_patched--python-2_6_1/include
-I/home/oyvind/oharboe/packages/linux-amd64-gcc_4_1/python-2_6_1/include/release/python2.6
testsuite/test.cpp
In file included from testsuite/test.cpp:8:
In file included from ./testsuite/precompile.h:4:
In file included from ./util/precompile.h:17:
In file included from
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/iosfwd:45:
In file included from
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu/bits/c++io.h:38:
In file included from
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu/bits/gthr.h:114:
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu/bits/gthr-default.h:88:1:
error:
      weakref declaration must have internal linkage
__gthrw(pthread_once)
^
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu/bits/gthr-default.h:71:23:
note: instantiated from:
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/local/gcc-4.1/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../include/c++/4.1.2/x86_64-unknown-linux-gnu/bits/gthr-default.h:63:46:
note: instantiated from:
  extern __typeof(type) name __attribute__ ((__weakref__(#name2)));
                                             ^