linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [BUG] daemon.c blows up on OSX
@ 2006-12-21  2:52 Albert Cahalan
  0 siblings, 0 replies; 9+ messages in thread
From: Albert Cahalan @ 2006-12-21  2:52 UTC (permalink / raw)
  To: junkio, merlyn, git, linux-kernel

Linus Torvalds writes:

> So it would appear that for OS X, the
>
>       #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
>       #define _GNU_SOURCE
>       #define _BSD_SOURCE
> sequence actually _disables_ those things.

Yes, of course. The odd one here is glibc.

Normal systems enable everything by default. As soon as you
specify a feature define, you get ONLY what you asked for.
I'm not sure why glibc is broken, but I suspect that somebody
wants to make everyone declare their code to be GNU source.
(despite many "GNU" things not working on the HURD at all)

Define _APPLE_C_SOURCE to make MacOS X give you everything.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 23:17               ` Randal L. Schwartz
  2006-12-20 23:30                 ` Junio C Hamano
@ 2006-12-20 23:41                 ` Linus Torvalds
  1 sibling, 0 replies; 9+ messages in thread
From: Linus Torvalds @ 2006-12-20 23:41 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Junio C Hamano, git, linux-kernel



On Wed, 20 Dec 2006, Randal L. Schwartz wrote:
> 
> What I do know is (a) it worked before the header changes and (b)
> the patch I just gave you works.  If the patch doesn't break others,
> can we just leave it in?

Well, at some point it probably _will_ break on other systems, exactly 
because other systems want to have the extended declarations.

It would be much better to have all the weird system dependencies solved 
in ONE place, rather than have each file (depending on just what they 
happen to need) have their own hacks for each weird system header file 
situation.

So it really would be a hell of a lot better to figure out _why_ strings.h 
doesn't "just work" when _XOPEN_SOURCE_EXTENDED is set. Or if there are 
better alternatives that work on HP-UX.. 

Does adding a

	#define _SVID_SOURCE 1

help? Also, we should probably make the _GNU_SOURCE and _BSD_SOURCE 
defines define to 1 (which is the way they'd be if we used -D_GNU_SOURCE 
on the compiler command line)

IOW, the appended ...

The really sad part is that this seems to be an OS X _bug_. 
"strncasecmp()" is part of the standard Open UNIX definitions, it's not 
something that should be shut off by _XOPEN_SOURCE, afaik.

There were apparently some OS X developers on the git list, mind 
commenting on this?

		Linus

---
diff --git a/git-compat-util.h b/git-compat-util.h
index bc296b3..1400905 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -13,8 +13,9 @@
 
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
-#define _GNU_SOURCE
-#define _BSD_SOURCE
+#define _GNU_SOURCE 1
+#define _BSD_SOURCE 1
+#define _SVID_SOURCE 1
 
 #include <unistd.h>
 #include <stdio.h>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 23:17               ` Randal L. Schwartz
@ 2006-12-20 23:30                 ` Junio C Hamano
  2006-12-20 23:41                 ` Linus Torvalds
  1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2006-12-20 23:30 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Junio C Hamano, git, linux-kernel

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> But yes, _XOPEN_SOURCE_EXTENDED definitely does some damage to
> curses.h.  However, I don't see how that's relevant to strings.h
> or the others I need.  There's no "config" for "compatibility".
> Welcome to Linux vs Unix. :)
>
> What I do know is (a) it worked before the header changes and (b)
> the patch I just gave you works.  If the patch doesn't break others,
> can we just leave it in?

That would lead to maintenance nightmare in the longer term.  We
cannot do that unless we know more or less what is going on.
Including only some system headers in a random order before
feature macros are defined, and doing so in only some source
files randomly until it starts compiling, is not a solution
maintainable in the longer term.

The _EXTENDED stuff is minimally commented that AIX wants it;
otherwise we would have been tempted to say, "remove it, if it
breaks OSX" without thinking, and would have ended up breaking
AIX.

No matter what we do, I would really want a clear description of
in what way OSX headers are broken and what needs to be done to
avoid the breakage in git-compat-util.h where it sets up feature
macros and includes system headers.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 23:07             ` Linus Torvalds
@ 2006-12-20 23:17               ` Randal L. Schwartz
  2006-12-20 23:30                 ` Junio C Hamano
  2006-12-20 23:41                 ` Linus Torvalds
  0 siblings, 2 replies; 9+ messages in thread
From: Randal L. Schwartz @ 2006-12-20 23:17 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, git, linux-kernel

>>>>> "Linus" == Linus Torvalds <torvalds@osdl.org> writes:

Linus> 	#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
Linus> 	#define _GNU_SOURCE
Linus> 	#define _BSD_SOURCE

Well, _GNU_SOURCE and _BSD_SOURCE only get defined, and only by some
oddballs that aren't relevant here.

Linus> sequence actually _disables_ those things.

Linus> Some googling finds a python source diff:

Linus> 	   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
Linus> 	   # disables platform specific features beyond repair.
Linus> 	-  Darwin/8.*)
Linus> 	+  Darwin/8.*|Darwin/7.*)
Linus> 	     define_xopen_source=no
Linus> 	     ;;

Linus> (and Ruby shows up as well in the google)

Linus> Can you try to grovel around in the OS X headers, and see what the magic 
Linus> is to enable all the compatibility crud on OS X?


But yes, _XOPEN_SOURCE_EXTENDED definitely does some damage to
curses.h.  However, I don't see how that's relevant to strings.h
or the others I need.  There's no "config" for "compatibility".
Welcome to Linux vs Unix. :)

What I do know is (a) it worked before the header changes and (b)
the patch I just gave you works.  If the patch doesn't break others,
can we just leave it in?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 22:46           ` Randal L. Schwartz
@ 2006-12-20 23:07             ` Linus Torvalds
  2006-12-20 23:17               ` Randal L. Schwartz
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2006-12-20 23:07 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Junio C Hamano, git, linux-kernel



On Wed, 20 Dec 2006, Randal L. Schwartz wrote:
> 
> According to my headers, "strncasecmp" is defined in <string.h>,
> "NI_MAXSERV" is defined in <netdb.h>, and "initgrps" is defined
> in "unistd.h".  So this patch works (just verified on OSX), but I
> don't know what damage it does elsehwere:

Look at "cache.h": the first thing it does is to include 
"git-compat-util.h". And THAT in turn does include ALL the headers you 
added (string.h, netdb.h and unistd.h).

So it would appear that for OS X, the

	#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
	#define _GNU_SOURCE
	#define _BSD_SOURCE

sequence actually _disables_ those things.

Some googling finds a python source diff:

	   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
	   # disables platform specific features beyond repair.
	-  Darwin/8.*)
	+  Darwin/8.*|Darwin/7.*)
	     define_xopen_source=no
	     ;;

(and Ruby shows up as well in the google)

Can you try to grovel around in the OS X headers, and see what the magic 
is to enable all the compatibility crud on OS X?

		Linus

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 22:35         ` Randal L. Schwartz
  2006-12-20 22:44           ` Junio C Hamano
@ 2006-12-20 22:46           ` Randal L. Schwartz
  2006-12-20 23:07             ` Linus Torvalds
  1 sibling, 1 reply; 9+ messages in thread
From: Randal L. Schwartz @ 2006-12-20 22:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:

Randal> running "git version 1.4.4.3.g5485" on my openbsd box, but I can't get
Randal> there on my OSX box.

According to my headers, "strncasecmp" is defined in <string.h>,
"NI_MAXSERV" is defined in <netdb.h>, and "initgrps" is defined
in "unistd.h".  So this patch works (just verified on OSX), but I
don't know what damage it does elsehwere:

diff --git a/daemon.c b/daemon.c
index b129b83..5ce73ed 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,3 +1,7 @@
+#include <string.h>
+#include <netdb.h>
+#include <unistd.h>
+
 #include "cache.h"
 #include "pkt-line.h"
 #include "exec_cmd.h"

However, now imap-send.o blows up:

imap-send.c: In function 'imap_open_store':
imap-send.c:908: error: 'AF_LOCAL' undeclared (first use in this function)
imap-send.c:908: error: (Each undeclared identifier is reported only once
imap-send.c:908: error: for each function it appears in.)
imap-send.c:990: warning: implicit declaration of function 'getpass'
imap-send.c:990: warning: assignment makes pointer from integer without a cast
make: *** [imap-send.o] Error 1

and finding "getpass" wants me to add "unistd.h" there too.

Hmm.  Let's see if I can use git-format-patch as Linus intended.


[-- Attachment #2: patch for osx --]
[-- Type: text/plain, Size: 853 bytes --]

>From 1549561dc68a1ea71f137c40109c90d33c0f9887 Mon Sep 17 00:00:00 2001
From: Randal L. Schwartz <merlyn@4.sub-70-192-166.myvzw.com>
Date: Wed, 20 Dec 2006 14:45:49 -0800
Subject: [PATCH] patch for osx

---
 daemon.c    |    4 ++++
 imap-send.c |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/daemon.c b/daemon.c
index b129b83..5ce73ed 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,3 +1,7 @@
+#include <string.h>
+#include <netdb.h>
+#include <unistd.h>
+
 #include "cache.h"
 #include "pkt-line.h"
 #include "exec_cmd.h"
diff --git a/imap-send.c b/imap-send.c
index 894cbbd..afd7447 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -22,6 +22,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <unistd.h>
+
 #include "cache.h"
 
 typedef struct store_conf {
-- 
1.4.4.3.g5485-dirty


[-- Attachment #3: Type: text/plain, Size: 291 bytes --]


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 22:35         ` Randal L. Schwartz
@ 2006-12-20 22:44           ` Junio C Hamano
  2006-12-20 22:46           ` Randal L. Schwartz
  1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2006-12-20 22:44 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: git, linux-kernel

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> Lemme see if it breaks on OpenBSD as well.
>
> Oddly enough - it didn't. :)

Of course it didn't.  I was a bit more careful than usual with
this and fired up an OpenBSD bochs on my wife's machine to test
it before pushing out.

> running "git version 1.4.4.3.g5485" on my openbsd box, but I can't get
> there on my OSX box.

Sorry, I cannot be of immediate help -- I do not have one.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 22:25       ` [BUG] daemon.c blows up on OSX Junio C Hamano
@ 2006-12-20 22:35         ` Randal L. Schwartz
  2006-12-20 22:44           ` Junio C Hamano
  2006-12-20 22:46           ` Randal L. Schwartz
  0 siblings, 2 replies; 9+ messages in thread
From: Randal L. Schwartz @ 2006-12-20 22:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, linux-kernel

>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:

Junio> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>> Nope... can't compile:
>> ...
>> daemon.c:970: warning: implicit declaration of function 'initgroups'
>> make: *** [daemon.o] Error 1
>> 
>> This smells like we've seen this before.  Regression introduced with
>> some of the cleanup?

Junio> Most likely.  You were CC'ed on these messages:

Junio> 	<7v7iwnnzed.fsf@assigned-by-dhcp.cox.net>
Junio> 	<7vbqlye2zz.fsf@assigned-by-dhcp.cox.net>

I see in 979e32fa1483a32faa4ec331e29b357e5eb5ef25 that I had to change
some things for OpenBSD... I bet those are generic BSD things.

Lemme see if it breaks on OpenBSD as well.

Oddly enough - it didn't. :)

running "git version 1.4.4.3.g5485" on my openbsd box, but I can't get
there on my OSX box.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] daemon.c blows up on OSX
  2006-12-20 22:20     ` [BUG] daemon.c blows up on OSX (was Re: What's in git.git (stable), and Announcing GIT 1.4.4.3) Randal L. Schwartz
@ 2006-12-20 22:25       ` Junio C Hamano
  2006-12-20 22:35         ` Randal L. Schwartz
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2006-12-20 22:25 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Junio C Hamano, git, linux-kernel

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> Nope... can't compile:
> ...
>     daemon.c:970: warning: implicit declaration of function 'initgroups'
>     make: *** [daemon.o] Error 1
>
> This smells like we've seen this before.  Regression introduced with
> some of the cleanup?

Most likely.  You were CC'ed on these messages:

	<7v7iwnnzed.fsf@assigned-by-dhcp.cox.net>
	<7vbqlye2zz.fsf@assigned-by-dhcp.cox.net>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-12-21  2:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-21  2:52 [BUG] daemon.c blows up on OSX Albert Cahalan
  -- strict thread matches above, loose matches on Subject: below --
2006-12-20 20:48 What's in git.git (stable), and Announcing GIT 1.4.4.3 Junio C Hamano
2006-12-20 22:04 ` Randal L. Schwartz
2006-12-20 22:14   ` Linus Torvalds
2006-12-20 22:20     ` [BUG] daemon.c blows up on OSX (was Re: What's in git.git (stable), and Announcing GIT 1.4.4.3) Randal L. Schwartz
2006-12-20 22:25       ` [BUG] daemon.c blows up on OSX Junio C Hamano
2006-12-20 22:35         ` Randal L. Schwartz
2006-12-20 22:44           ` Junio C Hamano
2006-12-20 22:46           ` Randal L. Schwartz
2006-12-20 23:07             ` Linus Torvalds
2006-12-20 23:17               ` Randal L. Schwartz
2006-12-20 23:30                 ` Junio C Hamano
2006-12-20 23:41                 ` Linus Torvalds

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 NNTP newsgroup(s).