Skip to contentSkip to conversation

Can't build external module against 2.6.0-test6 kernel

DISCUSSION Mark Hounschell 3 participants 6 messages Oct 9, 2003 – Oct 14, 2003

lore
Share & tools
lore
#0 lore raw

I'm trying to build a driver external to the kernel. I'm running 2.6.0-test6 kernel.
It appears to me (I'm probably wrong) that there is a kernel include file issue.

gcc -c rtom.c -D__KERNEL__ -DMODULE -DDEBUG -DDEBUG_LEVEL=6 -I/lib/modules/2.6.0-test6/build/include -I../include/linux/sys -I../include/linux -I../include -O -o rtom
In file included from /lib/modules/2.6.0-test6/build/include/asm/smp.h:18,

                 from /lib/modules/2.6.0-test6/build/include/linux/smp.h:17,
                 from /lib/modules/2.6.0-test6/build/include/linux/sched.h:23,
                 from /lib/modules/2.6.0-test6/build/include/linux/module.h:10,
                 from rtom.c:2:
/lib/modules/2.6.0-test6/build/include/asm/mpspec.h:6:25: mach_mpspec.h: No such
file or directory
In file included from /lib/modules/2.6.0-test6/build/include/asm/smp.h:18,
                 from /lib/modules/2.6.0-test6/build/include/linux/smp.h:17,
                 from /lib/modules/2.6.0-test6/build/include/linux/sched.h:23,
                 from /lib/modules/2.6.0-test6/build/include/linux/module.h:10,
                 from rtom.c:2:

/lib/modules/2.6.0-test6/build/include/asm/mpspec.h:8: error `MAX_MP_BUSSES' undeclared here
(not in a function)
.
.

harley:/usr/src/linux-2.6.0-test6 # find ./ -name mach_mpspec.h

./include/asm-i386/mach-default/mach_mpspec.h
./include/asm-i386/mach-es7000/mach_mpspec.h
./include/asm-i386/mach-generic/mach_mpspec.h
./include/asm-i386/mach-summit/mach_mpspec.h
./include/asm-i386/mach-numaq/mach_mpspec.h
./include/asm-i386/mach-bigsmp/mach_mpspec.h

In the 'include/asm/mpspec.h' file:
#ifndef __ASM_MPSPEC_H
#define __ASM_MPSPEC_H

#include <linux/cpumask.h>
#include <asm/mpspec_def.h>
#include <mach_mpspec.h> <-----------------------------------------------

extern int mp_bus_id_to_type [MAX_MP_BUSSES];

It seems like something is amiss here. Isn't the include statment incorrect above?

Thanks
Mark

#1 lore raw

Review

Quoted 8 lines · Mark Hounschell

I'm trying to build a driver external to the kernel. I'm running 2.6.0-test6 kernel.
It appears to me (I'm probably wrong) that there is a kernel include file issue.

gcc -c rtom.c -D__KERNEL__ -DMODULE -DDEBUG -DDEBUG_LEVEL=6

(quoted diff) +0 -2
-I/lib/modules/2.6.0-test6/build/include -I../include/linux/sys
-I../include/linux -I../include -O -o rtom

This compilation command line dos not look like it came from the kerel build system? If indeed you're using your own build system, please use the kernel's build system to compile external modules. See Documentation/kbuild/* for details, as well as lwn.net's "Compling External Modules" article - http://lwn.net/Articles/21823/. I'm guessing that you do not have something set up properly that the kernel's build system would've set up for you.

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org
#2 lore raw
In reply to Mark Hounschell
Quoted 3 lines · Mark Hounschell

I'm trying to build a driver external to the kernel. I'm running 2.6.0-test6 kernel.
It appears to me (I'm probably wrong) that there is a kernel include file issue.

Please follow Documentation/kbuild/modules.txt when building external modules.

Please come back if you continue to have problems.

Sam

#3 lore raw
Quoted 11 lines · Sam Ravnborg
Quoted 3 lines · Mark Hounschell

I'm trying to build a driver external to the kernel. I'm running 2.6.0-test6 kernel.
It appears to me (I'm probably wrong) that there is a kernel include file issue.

Please follow Documentation/kbuild/modules.txt when building external modules.

Please come back if you continue to have problems.

Sam

Ok, I can now build it but I have to hardcode _my_ include directories in the Makefile like:

/home/markh/work2/pcirtom_tst/driver/Makefile:

EXTRA_CFLAGS = -I/home/markh/work2/pcirtom_tst/include/linux/sys -I/home/markh/work2/pcirtom_tst/include/linux -I/home/markh/work2/pcirtom_tst/include

ifneq ($(KERNELRELEASE),)

        obj-m   += rtom.o
else
        KDIR    := /lib/modules/$(shell uname -r)/build
        PWD     := $(shell pwd)
default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

endif

My driver tree looks like

driver/
include/
diags/
samples/
library/

I've also tried setting the EXTRA_CFLAGS var in the top makefile but it doesn't seem to get passed down when the driver is compiled?? I've also tried creating a link in the driver directory pointing back to the include dir and adjusting the paths in the EXTRA_CFLAGS to
-Iinclude/linux/sys -Iinclude/linux -Iinclude to no avail.

Thanks
Mark

#4 lore raw

Review

Quoted 8 lines · Mark Hounschell

Ok, I can now build it but I have to hardcode _my_ include directories in the Makefile like:

/home/markh/work2/pcirtom_tst/driver/Makefile:

EXTRA_CFLAGS = -I/home/markh/work2/pcirtom_tst/include/linux/sys

(quoted diff) +0 -2
-I/home/markh/work2/pcirtom_tst/include/linux
-I/home/markh/work2/pcirtom_tst/include

Use:
EXTRA_CFLAGS := -I$(src)/include/linux/sys
EXTRA_CFLAGS += -I$(src)/include/linux
EXTRA_CFLAGS += -I$(src)/include

[Sidenote - you should only need the second line. Files in include/sys should be included as:
#include <sys/file.h>

And there should be no .h files in the linux directory].

Quoted 11 lines

ifneq ($(KERNELRELEASE),)

        obj-m   += rtom.o
else
        KDIR    := /lib/modules/$(shell uname -r)/build
        PWD     := $(shell pwd)
default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

endif

My driver tree looks like

Quoted 8 lines

driver/
include/
diags/
samples/
library/

I've also tried setting the EXTRA_CFLAGS var in the top makefile but it doesn't seem to get passed down when the driver is compiled??

EXTRA_CFLAGS are only relevant for the current kbuild Makefile - so it does not make sense to add it to the top-level Makefile.

Sam

#5 lore raw
Quoted 38 lines · Sam Ravnborg

Review

Quoted 8 lines · Mark Hounschell

Ok, I can now build it but I have to hardcode _my_ include directories in the Makefile like:

/home/markh/work2/pcirtom_tst/driver/Makefile:

EXTRA_CFLAGS = -I/home/markh/work2/pcirtom_tst/include/linux/sys

(quoted diff) +0 -2
-I/home/markh/work2/pcirtom_tst/include/linux
-I/home/markh/work2/pcirtom_tst/include

Use:
EXTRA_CFLAGS := -I$(src)/include/linux/sys
EXTRA_CFLAGS += -I$(src)/include/linux
EXTRA_CFLAGS += -I$(src)/include

[Sidenote - you should only need the second line. Files in include/sys should be included as:
#include <sys/file.h>

And there should be no .h files in the linux directory].

Quoted 17 lines

ifneq ($(KERNELRELEASE),)

        obj-m   += rtom.o
else
        KDIR    := /lib/modules/$(shell uname -r)/build
        PWD     := $(shell pwd)
default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

endif

My driver tree looks like

driver/
include/
diags/
samples/
library/

Quoted 6 lines
Quoted 2 lines

I've also tried setting the EXTRA_CFLAGS var in the top makefile but it doesn't seem to get passed down when the driver is compiled??

EXTRA_CFLAGS are only relevant for the current kbuild Makefile - so it does not make sense to add it to the top-level Makefile.

Sam

Thanks, defining the EXTRA-CFLAGS how and where you indicated did the trick. Is there also now special tricks for getting a library that goes with the driver to work? None of my IOCTLS are making it into the driver.

Ragards
Mark