Closed Quuxplusone closed 5 years ago
Attached wchar_iso.h
(14669 bytes, text/x-chdr): iso/wchar_iso.h
The redefine_extname pragma has about the same semantics as the GNU asm
extension, which is already implemented in Clang via the AsmLabelAttr
attribute. The GNU extension uses the asm keyword on a function declarator, as
described here:
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Asm-Labels.html#Asm-Labels
The redefine_extname pragma could be implemented by looking at the logic for
#pragma weak, which shows how to associate names in pragmas with actual
declarations, then using that information to attach an AsmLabelAttr to the
function declaration referenced by redefine_extname. It might be worth adding a
bit to AsmLabelAttr to state whether it came from redefine_extname vs. coming
from __asm__("blah").
It seems we need to define:
__PRAGMA_REDEFINE_EXTNAME
In lib/Frontend/InitPreprocessor.cpp
when we have '#pragma redefine_extname' support, so we are blocked by the patch
in PR5326.
So something like;
Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp (revision 89660)
+++ lib/Frontend/InitPreprocessor.cpp (working copy)
@@ -369,6 +369,10 @@
}
}
+ if (LangOpts.Sun) {
+ DefineBuiltinMacro(Buf, "__PRAGMA_REDEFINE_EXTNAME");
+ }
+
if (LangOpts.Optimize)
DefineBuiltinMacro(Buf, "__OPTIMIZE__=1");
if (LangOpts.OptimizeSize)
Making a blocker to this PR.
Regards,
Attached PR5172.patch
(6179 bytes, text/plain): PR5172.patch outliner, non-workable.
Attached PR5172.patch
(8673 bytes, text/plain): PR5172.patch (2)
I am seeing this on Solaris as well.
A simple program emits many errors caused the stdc++ header file:
wchar
I am on gcc 4.5.0 - Solaris 10 x86
This is blocking the use of clang on my platform :(
This doesn't seem to be Solaris only. I have the same problem on Windows 7 with mingw gcc 4.5.0.
Same problem with MinGW reported @ http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-August/010475.html
On MinGW there is no redefine_extname in the headers, the problem might be somewhere else.
This is implemented in r150882.
It is now possible to compile C++ programs that use standard Solaris headers with clang.
clang behavior wrt this pragma still differs from GCC and Sun Studio C++ on
Solaris:
$ cat -n a.cpp
1 extern "C" {
2
3 struct statvfs64 {
4 };
5
6 #pragma redefine_extname statvfs64 statvfs
7
8 int statvfs64(struct statvfs64 *);
9
10 }
11
12 int main()
13 {
14 struct statvfs64 st;
15 statvfs64(&st);
16 return 0;
17 }
$ /opt/clang/bin/clang++ -c a.cpp && nm a.o | grep statvfs
[8] | 0| 0|NOTY |GLOB |0 |UNDEF |statvfs64
$ /opt/csw/gcc4/bin/g++ -c a.cpp && nm a.o | grep statvfs
[8] | 0| 0|NOTY |GLOB |0 |UNDEF |statvfs
$ CC -c a.cpp && nm a.o | grep statvfs
[22] | 0| 0|FUNC |GLOB |0 |UNDEF |statvfs
$ /opt/clang/bin/clang++ -v
clang version 3.1 (branches/release_31 155814)
Target: i386-pc-solaris2.10
Thread model: posix
I submitted a patch for the problem described in comment 11:
http://reviews.llvm.org/D10187
Yours,
Andrey
======
Software Engineer
Intel Compiler Team
Intel
Fix committed; r239466.
Andrey
wchar_iso.h
(14669 bytes, text/x-chdr)PR5172.patch
(6179 bytes, text/plain)PR5172.patch
(8673 bytes, text/plain)