[PATCH] RFC: fs to be compiled with -Dlinux

From: Linus Walleij
Date: Fri Oct 28 2011 - 06:25:21 EST


I dunno how to solve this problem the real way or if I'm just doing
something idiotic. I'm using a vanilla GCC "arm-none-eabi-gcc" not
targeted at any specific OS so the environment variable "linux" is
not set. Then I try to compile an arch that by default wants to
generate an a.out image, actually mach-rpc (Acorn RISC PC) from
rpc_defconfig. (This is the grandfather in arch/arm/* if I'm not
mistaken.)

Without this patch that currently fails like this with a "none"
compiler:

CC fs/binfmt_aout.o
/home/elinwal/linux/fs/binfmt_aout.c: In function 'load_aout_binary':
/home/elinwal/linux/fs/binfmt_aout.c:256: error: 'SEGMENT_SIZE' undeclared (first use in this function)
/home/elinwal/linux/fs/binfmt_aout.c:256: error: (Each undeclared identifier is reported only once
/home/elinwal/linux/fs/binfmt_aout.c:256: error: for each function it appears in.)
make[3]: *** [fs/binfmt_aout.o] Error 1
make[2]: *** [fs] Error 2

However the kernel compilation process in fs/binmft_aout.c require
SEGMENT_SIZE which is in turn defined in <linux/a.out.h> like this:

#ifdef linux
#ifdef __KERNEL__
#include <asm/page.h>
#else
#include <unistd.h>
#endif
#if defined(__i386__) || defined(__mc68000__)
#define SEGMENT_SIZE 1024
#else
#ifndef SEGMENT_SIZE
#ifdef __KERNEL__
#define SEGMENT_SIZE PAGE_SIZE
#else
#define SEGMENT_SIZE getpagesize()
#endif
#endif
#endif
#endif

I don't know what the intent of all the pre-git
specific-machine detection code surrounding this statement
is, sorry I'm too young and naive. I don't dare to just delete
it though since it looks like stuff some userspace programs may
depend on, or intended for cross-compilation somekindof or
both.

Instead I chicken out and stick -Dlinux into the fs
Makefile, since that sure as hell cannot get the definition
of SEGMENT_SIZE from any other place than this file.

That doesn't feel good either, so: help.

Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
fs/Makefile | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fs/Makefile b/fs/Makefile
index d2c3353..128debc 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -3,7 +3,12 @@
#
# 14 Sep 2000, Christoph Hellwig <hch@xxxxxxxxxxxxx>
# Rewritten to use lists instead of if-statements.
-#
+#
+
+# binfmt_aout includes <linux/a.out.h> which requires that the compiler
+# defines "linux" to provide SEGMENT_SIZE and such things for the kernel
+# compilation
+ccflags-y := -Dlinux

obj-y := open.o read_write.o file_table.o super.o \
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
--
1.7.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/