public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] __linux__ and cross-compile
@ 2002-01-20 13:59 Momchil Velikov
  2002-01-20 14:23 ` Adrian Bunk
  0 siblings, 1 reply; 9+ messages in thread
From: Momchil Velikov @ 2002-01-20 13:59 UTC (permalink / raw)
  To: linux-kernel

Hi there,

The following patch fixes compilation/miscompilation problems, which
may happend iwtg variuos cross compile configuration, wherte the
compiler used to compile the kernel does not necessarily define
__linux__. The patch replaces __linux__ with __KERNEL__, using
__KERNEL_ as an indication that the source is compiled as a part of
linux.  Sources, which can be compiled in userspace as well, are
changed to use #if defined(__linux__) || defined(__KERNEL__).

Regards,
-velco

===== arch/alpha/kernel/entry.S 1.1 vs edited =====
--- 1.1/arch/alpha/kernel/entry.S	Sat Dec  8 02:15:19 2001
+++ edited/arch/alpha/kernel/entry.S	Sun Jan 20 15:26:53 2002
@@ -121,9 +121,6 @@
 
 .text
 .set noat
-#if defined(__linux__) && !defined(__ELF__)
-  .set singlegp
-#endif
 
 .align 3
 .globl	entInt
===== drivers/char/drm/drm.h 1.2 vs edited =====
--- 1.2/drivers/char/drm/drm.h	Sat Dec  8 02:36:06 2001
+++ edited/drivers/char/drm/drm.h	Sun Jan 20 15:29:13 2002
@@ -35,7 +35,7 @@
 #ifndef _DRM_H_
 #define _DRM_H_
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__KERNEL__)
 #include <linux/config.h>
 #include <asm/ioctl.h>		/* For _IO* macros */
 #define DRM_IOCTL_NR(n)	     _IOC_NR(n)
===== drivers/char/drm-4.0/drm.h 1.1 vs edited =====
--- 1.1/drivers/char/drm-4.0/drm.h	Thu Jan 10 15:28:33 2002
+++ edited/drivers/char/drm-4.0/drm.h	Sun Jan 20 15:29:57 2002
@@ -36,7 +36,7 @@
 #define _DRM_H_
 
 #include <linux/config.h>
-#if defined(__linux__)
+#if defined(__linux__) || defined(__KERNEL__)
 #include <asm/ioctl.h>		/* For _IO* macros */
 #define DRM_IOCTL_NR(n)	     _IOC_NR(n)
 #elif defined(__FreeBSD__)
===== drivers/scsi/aic7xxx/aic7xxx.c 1.1 vs edited =====
--- 1.1/drivers/scsi/aic7xxx/aic7xxx.c	Sat Dec  8 02:14:28 2001
+++ edited/drivers/scsi/aic7xxx/aic7xxx.c	Sun Jan 20 15:49:03 2002
@@ -3653,7 +3653,7 @@
 	case 2:
 		ahc_dma_tag_destroy(ahc, ahc->shared_data_dmat);
 	case 1:
-#ifndef __linux__
+#ifndef __KERNEL__
 		ahc_dma_tag_destroy(ahc, ahc->buffer_dmat);
 #endif
 		break;
@@ -3661,7 +3661,7 @@
 		break;
 	}
 
-#ifndef __linux__
+#ifndef __KERNEL__
 	ahc_dma_tag_destroy(ahc, ahc->parent_dmat);
 #endif
 	ahc_platform_free(ahc);
@@ -4121,7 +4121,7 @@
 	newcount = MIN(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
 	for (i = 0; i < newcount; i++) {
 		struct scb_platform_data *pdata;
-#ifndef __linux__
+#ifndef __KERNEL__
 		int error;
 #endif
 		pdata = (struct scb_platform_data *)malloc(sizeof(*pdata),
@@ -4138,7 +4138,7 @@
 		next_scb->sg_list_phys = physaddr + sizeof(struct ahc_dma_seg);
 		next_scb->ahc_softc = ahc;
 		next_scb->flags = SCB_FREE;
-#ifndef __linux__
+#ifndef __KERNEL__
 		error = ahc_dmamap_create(ahc, ahc->buffer_dmat, /*flags*/0,
 					  &next_scb->dmamap);
 		if (error != 0)
@@ -4254,7 +4254,7 @@
 	if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0)
 		ahc->features &= ~AHC_TARGETMODE;
 
-#ifndef __linux__
+#ifndef __KERNEL__
 	/* DMA tag for mapping buffers into device visible space. */
 	if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
 			       /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
===== drivers/scsi/aic7xxx/aic7xxx.h 1.1 vs edited =====
--- 1.1/drivers/scsi/aic7xxx/aic7xxx.h	Sat Dec  8 02:14:28 2001
+++ edited/drivers/scsi/aic7xxx/aic7xxx.h	Sun Jan 20 15:49:00 2002
@@ -547,7 +547,7 @@
 	ahc_io_ctx_t		  io_ctx;
 	struct ahc_softc	 *ahc_softc;
 	scb_flag		  flags;
-#ifndef __linux__
+#ifndef __KERNEL__
 	bus_dmamap_t		  dmamap;
 #endif
 	struct scb_platform_data *platform_data;
@@ -870,7 +870,7 @@
 struct ahc_softc {
 	bus_space_tag_t           tag;
 	bus_space_handle_t        bsh;
-#ifndef __linux__
+#ifndef __KERNEL__
 	bus_dma_tag_t		  buffer_dmat;   /* dmat for buffer I/O */
 #endif
 	struct scb_data		 *scb_data;
===== drivers/scsi/dpt/osd_defs.h 1.1 vs edited =====
--- 1.1/drivers/scsi/dpt/osd_defs.h	Sat Dec  8 02:14:34 2001
+++ edited/drivers/scsi/dpt/osd_defs.h	Sun Jan 20 15:45:09 2002
@@ -52,7 +52,7 @@
 /*Definitions - Defines & Constants ----------------------------------------- */
 
   /* Define the operating system */
-#if (defined(__linux__))
+#if defined(__linux__) || defined(__KERNEL__)
 # define _DPT_LINUX
 #elif (defined(__bsdi__))
 # define _DPT_BSDI
===== include/asm-mips/sgidefs.h 1.1 vs edited =====
--- 1.1/include/asm-mips/sgidefs.h	Sat Dec  8 02:13:26 2001
+++ edited/include/asm-mips/sgidefs.h	Sun Jan 20 15:48:28 2002
@@ -11,14 +11,6 @@
 #define __ASM_SGIDEFS_H
 
 /*
- * Using a Linux compiler for building Linux seems logic but not to
- * everybody.
- */
-#ifndef __linux__
-#error Use a Linux compiler or give up.
-#endif
-
-/*
  * Definitions for the ISA levels
  *
  * With the introduction of MIPS32 / MIPS64 instruction sets definitions
===== include/asm-mips64/sgidefs.h 1.1 vs edited =====
--- 1.1/include/asm-mips64/sgidefs.h	Sat Dec  8 02:13:55 2001
+++ edited/include/asm-mips64/sgidefs.h	Sun Jan 20 15:48:55 2002
@@ -11,14 +11,6 @@
 #define __ASM_SGIDEFS_H
 
 /*
- * Using a Linux compiler for building Linux seems logic but not to
- * everybody.
- */
-#ifndef __linux__
-#error Use a Linux compiler or give up.
-#endif
-
-/*
  * Definitions for the ISA levels
  *
  * With the introduction of MIPS32 / MIPS64 instruction sets definitions
===== include/linux/coda.h 1.1 vs edited =====
--- 1.1/include/linux/coda.h	Sat Dec  8 02:13:14 2001
+++ edited/include/linux/coda.h	Sun Jan 20 15:16:58 2002
@@ -98,7 +98,7 @@
 #endif /* !DJGPP */
 
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__KERNEL__)
 #define cdev_t u_quad_t
 #ifndef __KERNEL__
 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
@@ -211,8 +211,8 @@
 #endif	/* VICEFID */
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__KERNEL__)
 static __inline__ ino_t  coda_f2i(struct ViceFid *fid)
 {
 	if ( ! fid ) 


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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 13:59 [PATCH] __linux__ and cross-compile Momchil Velikov
@ 2002-01-20 14:23 ` Adrian Bunk
  2002-01-20 15:08   ` Momchil Velikov
  0 siblings, 1 reply; 9+ messages in thread
From: Adrian Bunk @ 2002-01-20 14:23 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: linux-kernel

On 20 Jan 2002, Momchil Velikov wrote:

> Hi there,
>
> The following patch fixes compilation/miscompilation problems, which
> may happend iwtg variuos cross compile configuration, wherte the
> compiler used to compile the kernel does not necessarily define
> __linux__. The patch replaces __linux__ with __KERNEL__, using

Isn't this a compiler bug?

> __KERNEL_ as an indication that the source is compiled as a part of
>...

This is definitely wrong in files that are not Linux-specific and that are
used on FreeBSD (and BSDI) as well (you would know that if you'd looked at
the files your patch changes)...

cu
Adrian



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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 14:23 ` Adrian Bunk
@ 2002-01-20 15:08   ` Momchil Velikov
  2002-01-20 15:17     ` Adrian Bunk
  0 siblings, 1 reply; 9+ messages in thread
From: Momchil Velikov @ 2002-01-20 15:08 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

>>>>> "Adrian" == Adrian Bunk <bunk@fs.tum.de> writes:

Adrian> On 20 Jan 2002, Momchil Velikov wrote:
>> Hi there,
>> 
>> The following patch fixes compilation/miscompilation problems, which
>> may happend iwtg variuos cross compile configuration, wherte the
>> compiler used to compile the kernel does not necessarily define
>> __linux__. The patch replaces __linux__ with __KERNEL__, using

Adrian> Isn't this a compiler bug?

Why would it be ? I may want to cross-compile from, e.g., NetBSD with
the host compiler, or I may want compile from GNU/Linux, but with a
compiler like arm-elf-gcc, that is, generic arm cross compiler, used
for other kernels too.

>> __KERNEL_ as an indication that the source is compiled as a part of
>> ...

Adrian> This is definitely wrong in files that are not Linux-specific and that are
Adrian> used on FreeBSD (and BSDI) as well (you would know that if you'd looked at
Adrian> the files your patch changes)...

*BSD define _KERNEL, don't they ?

Regards,
-velco

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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 15:08   ` Momchil Velikov
@ 2002-01-20 15:17     ` Adrian Bunk
  2002-01-20 16:04       ` Momchil Velikov
  2002-01-20 16:15       ` David Woodhouse
  0 siblings, 2 replies; 9+ messages in thread
From: Adrian Bunk @ 2002-01-20 15:17 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: linux-kernel

On 20 Jan 2002, Momchil Velikov wrote:

> >> The following patch fixes compilation/miscompilation problems, which
> >> may happend iwtg variuos cross compile configuration, wherte the
> >> compiler used to compile the kernel does not necessarily define
> >> __linux__. The patch replaces __linux__ with __KERNEL__, using
>
> Adrian> Isn't this a compiler bug?
>
> Why would it be ? I may want to cross-compile from, e.g., NetBSD with
> the host compiler, or I may want compile from GNU/Linux, but with a
>...

If your compiler is configured as a cross-compiler everything should work
as expected. If you are trying to compile a Linux kernel with a gcc that
is configured to build binaries for NetBSD this sounds evil.

> >> __KERNEL_ as an indication that the source is compiled as a part of
> >> ...
>
> Adrian> This is definitely wrong in files that are not Linux-specific and that are
> Adrian> used on FreeBSD (and BSDI) as well (you would know that if you'd looked at
> Adrian> the files your patch changes)...
>
> *BSD define _KERNEL, don't they ?

I don't know (I never tried to compile a *BSD kernel).
But if yes please consider what the following parts of your patch change:

-#ifndef __linux__
+#ifndef __KERNEL__

> Regards,
> -velco

cu
Adrian




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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 15:17     ` Adrian Bunk
@ 2002-01-20 16:04       ` Momchil Velikov
  2002-01-20 16:15       ` David Woodhouse
  1 sibling, 0 replies; 9+ messages in thread
From: Momchil Velikov @ 2002-01-20 16:04 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

>>>>> "Adrian" == Adrian Bunk <bunk@fs.tum.de> writes:
Adrian> If your compiler is configured as a cross-compiler everything should work
Adrian> as expected. If you are trying to compile a Linux kernel with a gcc that
Adrian> is configured to build binaries for NetBSD this sounds evil.

Could you elaborate why ? I think people do it all the time, compiling
linux (which is not a _linux_ binary, but a i386, alpha, etc. binary)
with a compiler configured to compile linux binaries.

>> >> __KERNEL_ as an indication that the source is compiled as a part of
>> >> ...
>> 
Adrian> This is definitely wrong in files that are not Linux-specific and that are
Adrian> used on FreeBSD (and BSDI) as well (you would know that if you'd looked at
Adrian> the files your patch changes)...
>> 
>> *BSD define _KERNEL, don't they ?

Adrian> I don't know (I never tried to compile a *BSD kernel).
Adrian> But if yes please consider what the following parts of your patch change:

Adrian> -#ifndef __linux__
Adrian> +#ifndef __KERNEL__

I have. Have you ?

Regards,
-velco


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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 15:17     ` Adrian Bunk
  2002-01-20 16:04       ` Momchil Velikov
@ 2002-01-20 16:15       ` David Woodhouse
  2002-01-20 16:29         ` Adrian Bunk
  1 sibling, 1 reply; 9+ messages in thread
From: David Woodhouse @ 2002-01-20 16:15 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Momchil Velikov, linux-kernel


bunk@fs.tum.de said:
>  If your compiler is configured as a cross-compiler everything should
> work as expected. If you are trying to compile a Linux kernel with a
> gcc that is configured to build binaries for NetBSD this sounds evil. 

What if he's trying to build UML to run on NetBSD? What if the best QA'd 
cross-gcc he has available is a generic arm-elf-gcc and he doesn't want to 
rebuild and do a full test and release cycle on it just because a handful 
of the kernel header files assume __linux__ will be defined?

> I don't know (I never tried to compile a *BSD kernel).

If you don't know, who was it that typed 'This is definitely wrong' in your 
first mail? Your cat?

> But if yes please consider what the following parts of your patch change:
> -#ifndef __linux__ 
> +#ifndef __KERNEL__

Well, if he hadn't explicitly mentioned that he made header files which 
could be included by userspace use defined(__KERNEL__)||defined(__linux__)
then I'd understand what you meant. As it is, I don't. Please explain.

--
dwmw2



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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 16:15       ` David Woodhouse
@ 2002-01-20 16:29         ` Adrian Bunk
  2002-01-20 16:37           ` David Woodhouse
  0 siblings, 1 reply; 9+ messages in thread
From: Adrian Bunk @ 2002-01-20 16:29 UTC (permalink / raw)
  To: David Woodhouse; +Cc: Momchil Velikov, linux-kernel

On Sun, 20 Jan 2002, David Woodhouse wrote:

>...
> > But if yes please consider what the following parts of your patch change:
> > -#ifndef __linux__
> > +#ifndef __KERNEL__
>
> Well, if he hadn't explicitly mentioned that he made header files which
> could be included by userspace use defined(__KERNEL__)||defined(__linux__)
> then I'd understand what you meant. As it is, I don't. Please explain.

This is part of his patch to drivers/scsi/aic7xxx/aic7xxx.c

It's clear that code that is part of an "#ifndef __linux__" will never be
included on any other OS than Linux. Is this also garuanteed for
"#ifndef __KERNEL__"?

> dwmw2

cu
Adrian





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

* Re: [PATCH] __linux__ and cross-compile
  2002-01-20 16:29         ` Adrian Bunk
@ 2002-01-20 16:37           ` David Woodhouse
  0 siblings, 0 replies; 9+ messages in thread
From: David Woodhouse @ 2002-01-20 16:37 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Momchil Velikov, linux-kernel


bunk@fs.tum.de said:
>  It's clear that code that is part of an "#ifndef __linux__" will
> never be included on any other OS than Linux.

True. But unfortunately that's not a useful guarantee. This code doesn't
(normally) run _on_ Linux. It is _in_ Linux, and it's still possible that
the offending code won't get included when it should.

> Is this also garuanteed for "#ifndef __KERNEL__"? 

We think *BSD uses _KERNEL, and don't know of anything else which defines 
__KERNEL__ other than Linux. So he's switching from something that's known 
broken to something which we _believe_ will be reliable.

--
dwmw2



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

* Re: [PATCH] __linux__ and cross-compile
@ 2002-01-22  7:43 Zwane Mwaikambo
  0 siblings, 0 replies; 9+ messages in thread
From: Zwane Mwaikambo @ 2002-01-22  7:43 UTC (permalink / raw)
  To: dwmw2; +Cc: velco, Linux Kernel

>We think *BSD uses _KERNEL, and don't know of anything else which defines 
>__KERNEL__ other than Linux. So he's switching from something that's known 
>broken to something which we _believe_ will be reliable.

I agree, frankly i don't think anyone should touch this particular code 
(aic7xx) unless they also build and test on the other target platforms. 
Was this cleanup cc'd to Justin Gibbs? What did he have to say about it?

Regards,
	Zwane Mwaikamob



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

end of thread, other threads:[~2002-01-22  7:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-20 13:59 [PATCH] __linux__ and cross-compile Momchil Velikov
2002-01-20 14:23 ` Adrian Bunk
2002-01-20 15:08   ` Momchil Velikov
2002-01-20 15:17     ` Adrian Bunk
2002-01-20 16:04       ` Momchil Velikov
2002-01-20 16:15       ` David Woodhouse
2002-01-20 16:29         ` Adrian Bunk
2002-01-20 16:37           ` David Woodhouse
  -- strict thread matches above, loose matches on Subject: below --
2002-01-22  7:43 Zwane Mwaikambo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox