You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Liviu Nicoara <ni...@hates.ms> on 2012/09/22 06:51:20 UTC
SUNPro 5.12 compilation failure in optimized Linux builds
Optimized (but not debug) builds fail to compile setlocale.cpp with the error:
$ cat t.cpp; CC -c t.cpp
#define _XOPEN_SOURCE
#include <cwchar>
"/opt/sunpro/12_3/prod/include/cc/wchar.h", line 90: Error: tm is not defined.
"/opt/sunpro/12_3/prod/include/cc/wchar.h", line 92: Error: fgetwc is not defined.
...
and so on for every wide-char function in wchar.h.
The definition of _XOPEN_SOURCE at the top of setlocale.cpp is not entirely
correct in that it interacts with the various guards in the C library headers.
AFAICT, Oracle/Sun wchar.h includes C library wchar.h, which includes C library
wctype.h, which includes again wchar.h, coming full circle to the compiler
wchar.h which uses the names w/o them being defined, yet. The fact that
Oracle/Sun headers include_next corresponding C library headers outside of a
inclusion guard does not help.
(Debug builds are not affected because of interaction from the difference in the
structure and includes of rw/_traits.h in debug vs. optimized builds).
The poor man's fix is to guard that _XOPEN_SOURCE define for SUNPro builds (see
below). However, I am not sure whose side the error is.
Thanks,
Liviu
PS. Is it still called SUNPro? Oracles seems it has sanitized that name out on
their website.
Index: src/setlocale.cpp
===================================================================
--- src/setlocale.cpp (revision 1388733)
+++ src/setlocale.cpp (working copy)
@@ -34,8 +34,10 @@
#include <rw/_defs.h>
#if defined (__linux__) && !defined (_XOPEN_SOURCE)
+# if !defined (__SUNPRO_CC)
// need S_IFDIR on Linux
# define _XOPEN_SOURCE
+# endif // !__SUNPRO_CC
#endif // __linux__ && !_XOPEN_SOURCE
#include <locale.h> // for setlocale()
Re: [PATCH] STDCXX-1069 [was: Re: SUNPro 5.12 compilation failure
in optimized Linux builds]
Posted by Martin Sebor <ms...@gmail.com>.
On 09/27/2012 06:15 AM, Liviu Nicoara wrote:
> On 09/23/12 12:15, Liviu Nicoara wrote:
>> On 09/22/12 00:51, Liviu Nicoara wrote:
>>> Optimized (but not debug) builds fail to compile setlocale.cpp with
>>> the error:
>>
>> A patch and a comment have been attached to the issue.
>
> I am posting it here to save a trip to the JIRA issue. Any feed-back is
> appreciated.
>
> "The issue can be tracked down to the interaction between the definition
> of _XOPEN_SOURCE in src/setlocale.cpp and util/path.cpp, the system
> headers, and Solaris Studio C . It seems that the original purpose for
> the definitions has been lost because both S_IFDIR and symlink are
> defined and declared, respectively, on modern Linux (edit: by default).
> Moreover, it seems that the original definition of _XOPEN_SOURCE was
> incorrect, without a value. I propose we remove the two blocks – see the
> patch."
I successfully tested the patch with GCC 3.4.6 on RHEL 4.8,
with GLIBC 2.3.4, the oldest Linux distribution I could get
my hands on.
That said, by my reading of POSIX, to get the definition of
S_IFDIR (marked as an XSI extension), a conforming application
is supposed to define the _XOPEN_SOURCE macro (to 500 or 600
depending on the version of POSIX) in order to get the former
macro defined. POSIX also says that every conforming application
should define _POSIX_C_SOURCE before including any header. We
don't try to do that (on Linux, GCC defines _GNU_SOURCE which
I think takes care of it, but I'm not sure we can count on it
with all other compilers on all other UNIX systems).
In any case, I think the patch is fine.
Martin
>
> Thanks,
> Liviu
>
> Index: src/setlocale.cpp
> ===================================================================
> --- src/setlocale.cpp (revision 1388733)
> +++ src/setlocale.cpp (working copy)
> @@ -33,11 +33,6 @@
>
> #include <rw/_defs.h>
>
> -#if defined (__linux__) && !defined (_XOPEN_SOURCE)
> - // need S_IFDIR on Linux
> -# define _XOPEN_SOURCE
> -#endif // __linux__ && !_XOPEN_SOURCE
> -
> #include <locale.h> // for setlocale()
> #include <stdlib.h> // for getenv()
> #include <string.h> // for memcpy(), strcmp()
> Index: util/path.cpp
> ===================================================================
> --- util/path.cpp (revision 1388733)
> +++ util/path.cpp (working copy)
> @@ -27,16 +27,6 @@
>
> **************************************************************************/
>
> #ifndef _WIN32
> -# ifdef __linux__
> - // for symlink()
> -# ifndef _XOPEN_SOURCE
> -# define _XOPEN_SOURCE
> -# endif
> -# ifndef _XOPEN_SOURCE_EXTENDED
> -# define _XOPEN_SOURCE_EXTENDED
> -# endif
> -# endif // __linux__
> -
> # include <unistd.h> // for getcwd()
> # include <sys/stat.h> // for struct stat, stat()
> #else
>
Re: [PATCH] STDCXX-1069 [was: Re: SUNPro 5.12 compilation failure
in optimized Linux builds]
Posted by Liviu Nicoara <ni...@hates.ms>.
On 09/23/12 12:15, Liviu Nicoara wrote:
> On 09/22/12 00:51, Liviu Nicoara wrote:
>> Optimized (but not debug) builds fail to compile setlocale.cpp with the error:
>
> A patch and a comment have been attached to the issue.
I am posting it here to save a trip to the JIRA issue. Any feed-back is appreciated.
"The issue can be tracked down to the interaction between the definition of _XOPEN_SOURCE in src/setlocale.cpp and util/path.cpp, the system headers, and Solaris Studio C . It seems that the original purpose for the definitions has been lost because both S_IFDIR and symlink are defined and declared, respectively, on modern Linux (edit: by default). Moreover, it seems that the original definition of _XOPEN_SOURCE was incorrect, without a value. I propose we remove the two blocks – see the patch."
Thanks,
Liviu
Index: src/setlocale.cpp
===================================================================
--- src/setlocale.cpp (revision 1388733)
+++ src/setlocale.cpp (working copy)
@@ -33,11 +33,6 @@
#include <rw/_defs.h>
-#if defined (__linux__) && !defined (_XOPEN_SOURCE)
- // need S_IFDIR on Linux
-# define _XOPEN_SOURCE
-#endif // __linux__ && !_XOPEN_SOURCE
-
#include <locale.h> // for setlocale()
#include <stdlib.h> // for getenv()
#include <string.h> // for memcpy(), strcmp()
Index: util/path.cpp
===================================================================
--- util/path.cpp (revision 1388733)
+++ util/path.cpp (working copy)
@@ -27,16 +27,6 @@
**************************************************************************/
#ifndef _WIN32
-# ifdef __linux__
- // for symlink()
-# ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE
-# endif
-# ifndef _XOPEN_SOURCE_EXTENDED
-# define _XOPEN_SOURCE_EXTENDED
-# endif
-# endif // __linux__
-
# include <unistd.h> // for getcwd()
# include <sys/stat.h> // for struct stat, stat()
#else
[PATCH] STDCXX-1069 [was: Re: SUNPro 5.12 compilation failure in
optimized Linux builds]
Posted by Liviu Nicoara <ni...@hates.ms>.
On 09/22/12 00:51, Liviu Nicoara wrote:
> Optimized (but not debug) builds fail to compile setlocale.cpp with the error:
A patch and a comment have been attached to the issue.
Thanks,
Liviu