* Re: 1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5)
@ 2002-06-08 6:51 librik
0 siblings, 0 replies; 3+ messages in thread
From: librik @ 2002-06-08 6:51 UTC (permalink / raw)
To: cygwin
I wrote:
> The -undef flag, "do not predefine any macros," fails in CPP (GCC)
> for Cygwin. This is version 2.95.3-5 of GCC.
> This flag is supposed to invoke the preprocessor without any built-in
> macros defined. Cygwin's special CPP defines several macros which
> rewrite Microsoft keywords (such as __cdecl and __declspec) to GCC form
> (using the __attribute__ syntax). The -undef flag fails to undefine any
> of these automatically defined CPP macros.
Heribert Dahms responded:
> did you have a look into the specs file
> /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs ?
This specs file seems to contain the same information as the
source file /usr/src/gcc-2.95.3-5/gcc/config/i386/cygwin.h
(is it generated from the .h file during the build process
for gcc, or is it sort of redundant?)
But since it's easier to make changes to the specs file,
I was able to determine the fix to the -undef bug in GCC.
Fix: wrap "%{!undef:" and "}" around the CPP_SPEC in /usr/src/
gcc-2.95.3-5/gcc/config/i386/cygwin.h and also (unless the
specs file is autogenerated) in /usr/lib/gcc-lib/i686-pc-cygwin/
2.95.3-5/specs.
Here is a unified diff patch for cygwin.h:
--- cygwin.h Sat Jun 08 02:56:05 2002
+++ cygwin.h.old Sun Jun 17 19:57:59 2001
@@ -91,26 +91,26 @@
predefined attributes later on. This can be solved by using one attribute,
say __declspec__, and passing args to it. The problem with that approach
is that args are not accumulated: each new appearance would clobber any
existing args. */
#undef CPP_SPEC
-#define CPP_SPEC "%{!undef:%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
+#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
-D__stdcall=__attribute__((__stdcall__)) \
-D__cdecl=__attribute__((__cdecl__)) \
%{!ansi:-D_stdcall=__attribute__((__stdcall__)) \
-D_cdecl=__attribute__((__cdecl__))} \
-D__declspec(x)=__attribute__((x)) \
%{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
%{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{mthreads:-D_MT} "\
MINGW_INCLUDES "} \
%{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix"\
CYGWIN_INCLUDES "}\
%{mwin32|mno-cygwin:%{!ansi:-DWIN32 -DWINNT -D_WIN32} -D_WIN32 -D__WIN32 -D__WIN32__}\
%{!mno-win32:" W32API_INC "}\
-}"
+"
#undef CPLUSPLUS_CPP_SPEC
#define CPLUSPLUS_CPP_SPEC "\
%{!mno-cygwin:" CYGWIN_CPP_INCLUDES "}\
%{mno-cygwin:" MINGW_CPP_INCLUDES "}\
Make the same change to the *cpp entry in "specs".
But is this all? Are there other specs strings that should be changed
to fix this bug as well? I'd like to ask a GCC expert ... D.J. Delorie,
where are you?
- David Librik
librik@panix.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: 1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5)
@ 2002-05-28 3:36 Heribert Dahms
0 siblings, 0 replies; 3+ messages in thread
From: Heribert Dahms @ 2002-05-28 3:36 UTC (permalink / raw)
To: 'librik@panix.com', cygwin
Hi David,
did you have a look into the specs file
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs ?
Bye, Heribert (heribert_dahms@icon-scm.com)
> -----Original Message-----
> From: librik@panix.com [SMTP:librik@panix.com]
> Sent: Monday, May 27, 2002 06:33
> To: cygwin@cygwin.com
> Subject: 1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5)
>
[Heribert] [snip]
> cygwin$ cpp -v -undef
> Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
>
[Heribert] [snip]
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
* 1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5)
@ 2002-05-27 5:31 librik
0 siblings, 0 replies; 3+ messages in thread
From: librik @ 2002-05-27 5:31 UTC (permalink / raw)
To: cygwin
1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5)
DESCRIPTION OF THE BUG:
The -undef flag, "do not predefine any macros," fails in CPP (GCC)
for Cygwin. This is version 2.95.3-5 of GCC.
This flag is supposed to invoke the preprocessor without any built-in
macros defined. Cygwin's special CPP defines several macros which
rewrite Microsoft keywords (such as __cdecl and __declspec) to GCC form
(using the __attribute__ syntax). The -undef flag fails to undefine any
of these automatically defined CPP macros. Thus it is difficult to use
Cygwin's CPP with the IMAKE make system (which uses CPP to preprocess
Makefiles) or with a "cross compilation" preprocess targeted at a non-
GCC compiler.
DEMONSTRATION OF THE BUG:
On Linux, the CPP -undef flag works. Here we invoke CPP with the -dM
flag, which dumps the values of all predefined macros:
linux% /lib/cpp -dM /dev/null
#define linux 1
#define __i386__ 1
#define i386 1
#define __ELF__ 1
#define unix 1
linux%
When -undef is added, all these predefined macros go away:
linux% /lib/cpp -dM -undef /dev/null
linux%
On Cygwin, most of the predefined macros do not go away when you use
-undef. Here is a dump without -undef:
cygwin$ cpp -dM /dev/null
#define _stdcall __attribute__((__stdcall__))
#define __i386__ 1
#define _X86_ 1
#define __i386 1
#define __i686 1
#define __declspec(x) __attribute__((x))
#define pentiumpro 1
#define __CYGWIN__ 1
#define _cdecl __attribute__((__cdecl__))
#define __pentiumpro 1
#define i386 1
#define i686 1
#define __pentiumpro__ 1
#define __stdcall __attribute__((__stdcall__))
#define __unix 1
#define __unix__ 1
#define __i686__ 1
#define __cdecl __attribute__((__cdecl__))
#define __CYGWIN32__ 1
#define unix 1
When -undef is added, predefined macros remain:
cygwin$ cpp -dM -undef /dev/null
#define _stdcall __attribute__((__stdcall__))
#define __i386__ 1
#define __i386 1
#define __i686 1
#define __declspec(x) __attribute__((x))
#define pentiumpro 1
#define __CYGWIN__ 1
#define _cdecl __attribute__((__cdecl__))
#define __pentiumpro 1
#define i386 1
#define i686 1
#define __pentiumpro__ 1
#define __stdcall __attribute__((__stdcall__))
#define __unix 1
#define __unix__ 1
#define __i686__ 1
#define __cdecl __attribute__((__cdecl__))
#define __CYGWIN32__ 1
#define unix 1
In particular, the transformations of __cdecl, __stdcall, __declspec,
etc. are retained. There seems to be no way to turn off all predefined
macros, despite the documentation for -undef.
Cygwin version is 1.3.10. GCC version is 2.95.3-5. Host OS is Windows 2000.
DISCUSSION OF THE BUG:
Apparently CPP predefines these flags by passing them as command-line
arguments to /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/cpp0.exe. The -v
flag reveals that cpp0 is invoked as follows:
cygwin$ cpp -v -undef
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
gcc version 2.95.3-5 (cygwin special)
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/cpp0.exe -lang-c -v
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686
-Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
-D__stdcall=__attribute__((__stdcall__))
-D__cdecl=__attribute__((__cdecl__))
-D_stdcall=__attribute__((__stdcall__))
-D_cdecl=__attribute__((__cdecl__))
-D__declspec(x)=__attribute__((x)) -D__CYGWIN32__ -D__CYGWIN__
-Dunix -D__unix__ -D__unix -isystem /usr/local/include
-idirafter /usr/include -idirafter /usr/include/w32api -
The -undef flag should cause CPP to not pass all those -D macros to cpp0.
FIX FOR THE BUG:
Sorry I don't have a patch. (I've been told that really understanding
GCC takes six months of intense study. Hopefully someone who's put in
the six months can easily spot how to patch the sources to fix this bug.)
It looks like /usr/src/gcc-2.95.3-5/gcc/config/i386/cygwin.h is the
right place to make the change. Perhaps {!undef:...} should be wrapped
around all of the options in CPP_SPEC?
One workaround is to use a lot of -U options, to turn off each macro
individually. But that is not upwardly compatible with potential later
additions to the predefined macros. -undef is the only way to turn them
all off at once.
This is breaking an IMAKE-based build system I'm trying to port to Cygwin.
Thanks for any help,
- David Librik
librik@panix.com
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-06-08 8:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-08 6:51 1.3.10: Bug: -undef does not work in cpp (gcc 2.95.3-5) librik
-- strict thread matches above, loose matches on Subject: below --
2002-05-28 3:36 Heribert Dahms
2002-05-27 5:31 librik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).