* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D36BF43.3050007@cs.ucla.edu>
@ 2011-01-19 15:54 ` Jan Djärv
2011-01-19 15:54 ` bug#7856: " Jan Djärv
` (3 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Jan Djärv @ 2011-01-19 15:54 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-19 11.38:
> grep -r __need_getopt . /usr/include
grep -nr __need_getopt . /usr/include
./lib/getopt.h:38:#ifndef __need_getopt
./lib/getopt.h:51:#if defined __GETOPT_PREFIX && !defined __need_getopt
./lib/getopt.h:57:# undef __need_getopt
./lib/getopt.h:86: This used to be `#if defined __GETOPT_PREFIX && !defined
__need_getopt',
./lib/getopt.h:89: __need_getopt.
./lib/getopt.h:93: only if __need_getopt is not defined, so it is quite safe
to rewrite
./lib/getopt.h:96:#if !defined __need_getopt
./lib/getopt.h:173:#ifndef __need_getopt
./lib/getopt.h:241:#ifndef __need_getopt
./lib/getopt.h:258:#undef __need_getopt
./lib/getopt.in.h:37:#ifndef __need_getopt
./lib/getopt.in.h:50:#if defined __GETOPT_PREFIX && !defined __need_getopt
./lib/getopt.in.h:56:# undef __need_getopt
./lib/getopt.in.h:85: This used to be `#if defined __GETOPT_PREFIX &&
!defined __need_getopt',
./lib/getopt.in.h:88: __need_getopt.
./lib/getopt.in.h:92: only if __need_getopt is not defined, so it is quite
safe to rewrite
./lib/getopt.in.h:95:#if !defined __need_getopt
./lib/getopt.in.h:162:#ifndef __need_getopt
./lib/getopt.in.h:230:#ifndef __need_getopt
./lib/getopt.in.h:247:#undef __need_getopt
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7856: bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D36BF43.3050007@cs.ucla.edu>
2011-01-19 15:54 ` Jan Djärv
@ 2011-01-19 15:54 ` Jan Djärv
[not found] ` <4D370928.1040601@swipnet.se>
` (2 subsequent siblings)
4 siblings, 0 replies; 17+ messages in thread
From: Jan Djärv @ 2011-01-19 15:54 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-19 11.38:
> grep -r __need_getopt . /usr/include
grep -nr __need_getopt . /usr/include
./lib/getopt.h:38:#ifndef __need_getopt
./lib/getopt.h:51:#if defined __GETOPT_PREFIX && !defined __need_getopt
./lib/getopt.h:57:# undef __need_getopt
./lib/getopt.h:86: This used to be `#if defined __GETOPT_PREFIX && !defined
__need_getopt',
./lib/getopt.h:89: __need_getopt.
./lib/getopt.h:93: only if __need_getopt is not defined, so it is quite safe
to rewrite
./lib/getopt.h:96:#if !defined __need_getopt
./lib/getopt.h:173:#ifndef __need_getopt
./lib/getopt.h:241:#ifndef __need_getopt
./lib/getopt.h:258:#undef __need_getopt
./lib/getopt.in.h:37:#ifndef __need_getopt
./lib/getopt.in.h:50:#if defined __GETOPT_PREFIX && !defined __need_getopt
./lib/getopt.in.h:56:# undef __need_getopt
./lib/getopt.in.h:85: This used to be `#if defined __GETOPT_PREFIX &&
!defined __need_getopt',
./lib/getopt.in.h:88: __need_getopt.
./lib/getopt.in.h:92: only if __need_getopt is not defined, so it is quite
safe to rewrite
./lib/getopt.in.h:95:#if !defined __need_getopt
./lib/getopt.in.h:162:#ifndef __need_getopt
./lib/getopt.in.h:230:#ifndef __need_getopt
./lib/getopt.in.h:247:#undef __need_getopt
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <4D370928.1040601@swipnet.se>]
* bug#7856: bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D370928.1040601@swipnet.se>
@ 2011-01-19 23:44 ` Paul Eggert
2011-01-19 23:44 ` Paul Eggert
[not found] ` <4D377768.8070504@cs.ucla.edu>
2 siblings, 0 replies; 17+ messages in thread
From: Paul Eggert @ 2011-01-19 23:44 UTC (permalink / raw)
To: Jan Djärv; +Cc: 7859, bug-gnulib, 7856, emacs-devel
I see that Jan Djärv tracked the problem down:
unexmacosx.c included <unistd.h> before <config.h>,
and this caused the problem. Generally speaking, <config.h>
should be included before all other files, since it
defines macros such as _FILE_OFFSET_BITS that may affect
the ABI, and compiling files sometimes with one ABI and
sometimes with another can lead to disaster.
I see that unexmacos.c still doesn't include <config.h> first,
though. I suggest that it be changed to do that.
A quick scan for other files with the problem show that
the following files probably need the "#include <config.h>"
moved to the top too:
w32.c
w32proc.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D370928.1040601@swipnet.se>
2011-01-19 23:44 ` Paul Eggert
@ 2011-01-19 23:44 ` Paul Eggert
[not found] ` <4D377768.8070504@cs.ucla.edu>
2 siblings, 0 replies; 17+ messages in thread
From: Paul Eggert @ 2011-01-19 23:44 UTC (permalink / raw)
To: Jan Djärv; +Cc: 7859, bug-gnulib, 7856, emacs-devel
I see that Jan Djärv tracked the problem down:
unexmacosx.c included <unistd.h> before <config.h>,
and this caused the problem. Generally speaking, <config.h>
should be included before all other files, since it
defines macros such as _FILE_OFFSET_BITS that may affect
the ABI, and compiling files sometimes with one ABI and
sometimes with another can lead to disaster.
I see that unexmacos.c still doesn't include <config.h> first,
though. I suggest that it be changed to do that.
A quick scan for other files with the problem show that
the following files probably need the "#include <config.h>"
moved to the top too:
w32.c
w32proc.c
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <4D377768.8070504@cs.ucla.edu>]
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D377768.8070504@cs.ucla.edu>
@ 2011-01-20 0:21 ` Eli Zaretskii
2011-01-20 6:45 ` Jan Djärv
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2011-01-20 0:21 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, emacs-devel
> Date: Wed, 19 Jan 2011 15:44:40 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> Cc: 7859@debbugs.gnu.org, bug-gnulib <bug-gnulib@gnu.org>, 7856@debbugs.gnu.org,
> emacs-devel@gnu.org
>
> A quick scan for other files with the problem show that
> the following files probably need the "#include <config.h>"
> moved to the top too:
>
> w32.c
> w32proc.c
These two have a comment saying that this is done on purpose:
/* must include CRT headers *before* config.h */
If someone wants to dig into the reasons, find out why and fix that,
please do. I had my share of fighting with (and being defeated by)
the order of included headers on Windows, so I'm not volunteering.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D377768.8070504@cs.ucla.edu>
2011-01-20 0:21 ` Eli Zaretskii
@ 2011-01-20 6:45 ` Jan Djärv
2011-01-20 6:45 ` bug#7856: " Jan Djärv
[not found] ` <4D37D9FD.3050805@swipnet.se>
3 siblings, 0 replies; 17+ messages in thread
From: Jan Djärv @ 2011-01-20 6:45 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-20 00.44:
> I see that Jan Djärv tracked the problem down:
> unexmacosx.c included<unistd.h> before<config.h>,
> and this caused the problem. Generally speaking,<config.h>
> should be included before all other files, since it
> defines macros such as _FILE_OFFSET_BITS that may affect
> the ABI, and compiling files sometimes with one ABI and
> sometimes with another can lead to disaster.
>
> I see that unexmacos.c still doesn't include<config.h> first,
> though. I suggest that it be changed to do that.
>
Not possible, I added this comment:
/* config.h #define:s malloc/realloc/free and then includes stdlib.h.
We want the undefined versions, but if config.h includes stdlib.h
with the #define:s in place, the prototypes will be wrong and we get
warnings. To prevent that, include stdlib.h before config.h. */
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7856: bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D377768.8070504@cs.ucla.edu>
2011-01-20 0:21 ` Eli Zaretskii
2011-01-20 6:45 ` Jan Djärv
@ 2011-01-20 6:45 ` Jan Djärv
[not found] ` <4D37D9FD.3050805@swipnet.se>
3 siblings, 0 replies; 17+ messages in thread
From: Jan Djärv @ 2011-01-20 6:45 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-20 00.44:
> I see that Jan Djärv tracked the problem down:
> unexmacosx.c included<unistd.h> before<config.h>,
> and this caused the problem. Generally speaking,<config.h>
> should be included before all other files, since it
> defines macros such as _FILE_OFFSET_BITS that may affect
> the ABI, and compiling files sometimes with one ABI and
> sometimes with another can lead to disaster.
>
> I see that unexmacos.c still doesn't include<config.h> first,
> though. I suggest that it be changed to do that.
>
Not possible, I added this comment:
/* config.h #define:s malloc/realloc/free and then includes stdlib.h.
We want the undefined versions, but if config.h includes stdlib.h
with the #define:s in place, the prototypes will be wrong and we get
warnings. To prevent that, include stdlib.h before config.h. */
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <4D37D9FD.3050805@swipnet.se>]
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D37D9FD.3050805@swipnet.se>
@ 2011-01-20 7:51 ` Paul Eggert
2011-01-20 7:51 ` bug#7856: " Paul Eggert
[not found] ` <4D37E970.2060803@cs.ucla.edu>
2 siblings, 0 replies; 17+ messages in thread
From: Paul Eggert @ 2011-01-20 7:51 UTC (permalink / raw)
To: Jan Djärv; +Cc: 7859, bug-gnulib, 7856, emacs-devel
On 01/19/2011 10:45 PM, Jan Djärv wrote:
> /* config.h #define:s malloc/realloc/free and then includes stdlib.h.
> We want the undefined versions, but if config.h includes stdlib.h
> with the #define:s in place, the prototypes will be wrong and we get
> warnings. To prevent that, include stdlib.h before config.h. */
OK, I see. There's a better way, one that doesn't potentially mess up
the ABI. Namely, Emacs can supply a stdlib.h wrapper that #defines
malloc/realloc/free the way we like. gnulib already does
that, but Emacs doesn't use gnulib's stdlib.h wrapper.
At some point, perhaps Emacs will, and then we can look into
this issue again.
Is stdlib.h the only include file that has the problem?
If so, I suggest modifying unexmacosx.c to include <stdlib.h>
first, <config.h> second, and everything else after that.
That should lessen the likelihood of an ABI mismatch.
If not, then what other include files have the problem?
This issue may come up if we add more wrappers from gnulib.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7856: bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D37D9FD.3050805@swipnet.se>
2011-01-20 7:51 ` Paul Eggert
@ 2011-01-20 7:51 ` Paul Eggert
[not found] ` <4D37E970.2060803@cs.ucla.edu>
2 siblings, 0 replies; 17+ messages in thread
From: Paul Eggert @ 2011-01-20 7:51 UTC (permalink / raw)
To: Jan Djärv; +Cc: 7859, bug-gnulib, 7856, emacs-devel
On 01/19/2011 10:45 PM, Jan Djärv wrote:
> /* config.h #define:s malloc/realloc/free and then includes stdlib.h.
> We want the undefined versions, but if config.h includes stdlib.h
> with the #define:s in place, the prototypes will be wrong and we get
> warnings. To prevent that, include stdlib.h before config.h. */
OK, I see. There's a better way, one that doesn't potentially mess up
the ABI. Namely, Emacs can supply a stdlib.h wrapper that #defines
malloc/realloc/free the way we like. gnulib already does
that, but Emacs doesn't use gnulib's stdlib.h wrapper.
At some point, perhaps Emacs will, and then we can look into
this issue again.
Is stdlib.h the only include file that has the problem?
If so, I suggest modifying unexmacosx.c to include <stdlib.h>
first, <config.h> second, and everything else after that.
That should lessen the likelihood of an ABI mismatch.
If not, then what other include files have the problem?
This issue may come up if we add more wrappers from gnulib.
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <4D37E970.2060803@cs.ucla.edu>]
* bug#7856: bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D37E970.2060803@cs.ucla.edu>
@ 2011-01-20 11:26 ` Jan D.
2011-01-20 11:26 ` Jan D.
1 sibling, 0 replies; 17+ messages in thread
From: Jan D. @ 2011-01-20 11:26 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-20 08:51:
> On 01/19/2011 10:45 PM, Jan Djärv wrote:
>> /* config.h #define:s malloc/realloc/free and then includes stdlib.h.
>> We want the undefined versions, but if config.h includes stdlib.h
>> with the #define:s in place, the prototypes will be wrong and we get
>> warnings. To prevent that, include stdlib.h before config.h. */
>
> OK, I see. There's a better way, one that doesn't potentially mess up
> the ABI. Namely, Emacs can supply a stdlib.h wrapper that #defines
> malloc/realloc/free the way we like. gnulib already does
> that, but Emacs doesn't use gnulib's stdlib.h wrapper.
> At some point, perhaps Emacs will, and then we can look into
> this issue again.
>
It is just for unexmacosx.c we want undefined malloc/free/realloc.
For other files we wan't the defined ones.
We can tweek the m/darwin.h file instead where these defines are.
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D37E970.2060803@cs.ucla.edu>
2011-01-20 11:26 ` Jan D.
@ 2011-01-20 11:26 ` Jan D.
1 sibling, 0 replies; 17+ messages in thread
From: Jan D. @ 2011-01-20 11:26 UTC (permalink / raw)
To: Paul Eggert; +Cc: 7859, bug-gnulib, 7856, emacs-devel
Paul Eggert skrev 2011-01-20 08:51:
> On 01/19/2011 10:45 PM, Jan Djärv wrote:
>> /* config.h #define:s malloc/realloc/free and then includes stdlib.h.
>> We want the undefined versions, but if config.h includes stdlib.h
>> with the #define:s in place, the prototypes will be wrong and we get
>> warnings. To prevent that, include stdlib.h before config.h. */
>
> OK, I see. There's a better way, one that doesn't potentially mess up
> the ABI. Namely, Emacs can supply a stdlib.h wrapper that #defines
> malloc/realloc/free the way we like. gnulib already does
> that, but Emacs doesn't use gnulib's stdlib.h wrapper.
> At some point, perhaps Emacs will, and then we can look into
> this issue again.
>
It is just for unexmacosx.c we want undefined malloc/free/realloc.
For other files we wan't the defined ones.
We can tweek the m/darwin.h file instead where these defines are.
Jan D.
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7856: syncing Emacs from sources maintained elsewhere
[not found] ` <4D36BF43.3050007@cs.ucla.edu>
` (2 preceding siblings ...)
[not found] ` <4D370928.1040601@swipnet.se>
@ 2011-01-20 0:27 ` Eric Blake
2011-01-20 0:27 ` bug#7859: " Eric Blake
4 siblings, 0 replies; 17+ messages in thread
From: Eric Blake @ 2011-01-20 0:27 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel, bug-gnulib, 7856, 7859
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
On 01/19/2011 03:38 AM, Paul Eggert wrote:
> * unexmacosx.c includes the Gnulib <unistd.h>.
That's always a bug to include any gnulib-provided header prior to
<config.h>.
>
> * And when Gnulib <getopt.h> declares a 'struct option', this clashes
> with the 'struct option' declared in the system getopt.h.
And this is a known symptom of violating the above constraint.
>
> PS. This all seems to be a case where we should be using Gnulib's
> identifier replacement mechanism, but I don't understand it that
> well and if memory serves it doesn't work with struct tags anyway.
We've managed to modernize other headers to properly declare replacement
structs exactly once; it is merely a matter of someone having enough
time to modernize the gnulib getopt module to use modern constructs
rather than abusing config.h to define an rpl_ prefix.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* bug#7859: syncing Emacs from sources maintained elsewhere
[not found] ` <4D36BF43.3050007@cs.ucla.edu>
` (3 preceding siblings ...)
2011-01-20 0:27 ` bug#7856: " Eric Blake
@ 2011-01-20 0:27 ` Eric Blake
4 siblings, 0 replies; 17+ messages in thread
From: Eric Blake @ 2011-01-20 0:27 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel, bug-gnulib, 7856, 7859
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
On 01/19/2011 03:38 AM, Paul Eggert wrote:
> * unexmacosx.c includes the Gnulib <unistd.h>.
That's always a bug to include any gnulib-provided header prior to
<config.h>.
>
> * And when Gnulib <getopt.h> declares a 'struct option', this clashes
> with the 'struct option' declared in the system getopt.h.
And this is a known symptom of violating the above constraint.
>
> PS. This all seems to be a case where we should be using Gnulib's
> identifier replacement mechanism, but I don't understand it that
> well and if memory serves it doesn't work with struct tags anyway.
We've managed to modernize other headers to properly declare replacement
structs exactly once; it is merely a matter of someone having enough
time to modernize the gnulib getopt module to use modern constructs
rather than abusing config.h to define an rpl_ prefix.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread