Skip to contentSkip to conversation

buffer cache

DISCUSSION vadiraj c s 7 participants 15 messages Sep 13, 2003 – Sep 16, 2003 VFS

lore
Share & tools
lore
#0 lore raw

hello all,

This is third time i'm posting my request. I'm working on
filesystem, I need to compile my code. I included linux/fs.h header file, none of the function declared in it gets compiled, I mean I get an error saying Undefined reference, the functions are inline functions.

1.) Is there any specific compilation method for such functions? 2.) How do I test my code before I register to VFS?

vadiraj
deeprootlinux

___________________________________________________
Catering meets Camera; Tanya Weds Sahil. Rediff Matchmaker strikes another interesting match Visit http://matchmaker.rediff.com?1

#1 lore raw
Quoted 8 lines · vadiraj c s

hello all,

This is third time i'm posting my request. I'm working on
filesystem, I need to compile my code. I included linux/fs.h header file, none of the function declared in it gets compiled, I mean I get an error saying Undefined reference, the functions are inline functions.

Sanity-check: Do you compile with the -O2 option? Kernel stuff must be compiled with optimization due to this and many other reasons.

Quoted 11 lines

1.) Is there any specific compilation method for such functions? 2.) How do I test my code before I register to VFS?

vadiraj
deeprootlinux

___________________________________________________
Catering meets Camera; Tanya Weds Sahil. Rediff Matchmaker strikes another interesting match Visit http://matchmaker.rediff.com?1

Quoted 4 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#2 lore raw
Quoted 9 lines · Jan Hudec
Quoted 5 lines · vadiraj c s

This is third time i'm posting my request. I'm working on
filesystem, I need to compile my code. I included linux/fs.h header file, none of the function declared in it gets compiled, I mean I get an error saying Undefined reference, the functions are inline functions.

Sanity-check: Do you compile with the -O2 option? Kernel stuff must be compiled with optimization due to this and many other reasons.

he's trying to get it to compile in userspace. there's basically no way to do this; just compile it as a module.

Signature · 3 lines
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk
#3 lore raw
In reply to Jan Hudec
Quoted 8 lines
Quoted 6 lines

I get an error saying Undefined reference, the functions are inline functions.

Kernel stuff must be compiled with optimization due to this and ...

Are you sure? I compile a filesystem driver module with no optimization all the time. Without optimization, the functions that are supposed to be inline become out-of-line, but it still compiles. On older versions of Linux, I did have to use -O because there were some "extern inline" functions, but not now. This is a 2.4.20ish kernel; maybe there are extern inlines in newer kernel code?

But here, we're apparently talking about the link editor (ld) "undefined reference" error, which means it isn't a question of compiling kernel code at all - he's trying to create an executable. That still wouldn't cause a problem with inline functions, but I suspect the problem is really with other (external) functions with similar names that the inline functions call.

#4 lore raw
Quoted 16 lines · Bryan Henderson
Quoted 8 lines
Quoted 6 lines

I get an error saying Undefined reference, the functions are inline functions.

Kernel stuff must be compiled with optimization due to this and ...

Are you sure? I compile a filesystem driver module with no optimization all the time. Without optimization, the functions that are supposed to be inline become out-of-line, but it still compiles. On older versions of Linux, I did have to use -O because there were some "extern inline" functions, but not now. This is a 2.4.20ish kernel; maybe there are extern inlines in newer kernel code?

Quoted 6 lines

But here, we're apparently talking about the link editor (ld) "undefined reference" error, which means it isn't a question of compiling kernel code at all - he's trying to create an executable. That still wouldn't cause a problem with inline functions, but I suspect the problem is really with other (external) functions with similar names that the inline functions call.

... you are right. The error looks like he is trying to do something wrong (binary instead of relocable object).

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#5 lore raw
Quoted 2 lines · Jan Hudec

... you are right. The error looks like he is trying to do something wrong (binary instead of relocable object).

Probably as a result of hacking up his own broken makefiles instead of
make -C $KERNELDIR SUBDIRS=pwd modules

Signature · 1 line
dwmw2
#6 lore raw
Quoted 6 lines · David Woodhouse
Quoted 2 lines · Jan Hudec

... you are right. The error looks like he is trying to do something wrong (binary instead of relocable object).

Probably as a result of hacking up his own broken makefiles instead of
make -C $KERNELDIR SUBDIRS=pwd modules

Well, I wrote a module to compile off-tree. The correct command to link a module is:
ld -r -o <modname>.o <objects...>

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#7 lore raw

Please don't drop me from the recipients when replying; it's very rude.

Quoted 6 lines · Jan Hudec
Quoted 2 lines

Probably as a result of hacking up his own broken makefiles instead of
make -C $KERNELDIR SUBDIRS=pwd modules

Well, I wrote a module to compile off-tree. The correct command to link a module is:
ld -r -o <modname>.o <objects...>

No, that's not always correct. It's completely wrong for 2.6, of course -- and even for 2.4, if building modules for a 64-bit kernel, you may find your userspace is 32-bit by default and you need something like -melf64_sparc on the linker command line. The kernel makefiles get this right. Use them.

The kernel is also free to screw with its own internal ABI all it likes -- with cflags affecting global register usage, etc. You must do as it does in the kernel you happen to be building -- which basically means you must use the kernel build system.

The correct way to build modules out of the kernel tree is to use the kernel makefiles and override SUBDIRS to point at your own directory; it's been that way since 2.0 if not earlier.

Signature · 1 line
dwmw2
#8 lore raw
Quoted 16 lines · David Woodhouse

Please don't drop me from the recipients when replying; it's very rude.

Quoted 6 lines · Jan Hudec
Quoted 2 lines

Probably as a result of hacking up his own broken makefiles instead of
make -C $KERNELDIR SUBDIRS=pwd modules

Well, I wrote a module to compile off-tree. The correct command to link a module is:
ld -r -o <modname>.o <objects...>

No, that's not always correct. It's completely wrong for 2.6, of course -- and even for 2.4, if building modules for a 64-bit kernel, you may find your userspace is 32-bit by default and you need something like -melf64_sparc on the linker command line. The kernel makefiles get this right. Use them.

Quoted 3 lines

The kernel is also free to screw with its own internal ABI all it likes -- with cflags affecting global register usage, etc. You must do as it does in the kernel you happen to be building -- which basically means

Which I basicaly do becasue I ask kernel to give me the flags it uses.

Quoted 1 line

you must use the kernel build system.

That's what the script target is for.

Quoted 3 lines

The correct way to build modules out of the kernel tree is to use the kernel makefiles and override SUBDIRS to point at your own directory; it's been that way since 2.0 if not earlier.

Well... I can't imagine compiling a project with various objects spead all over the place (I have a driver, that has various pieces common with various other programs) using the kernel build system. So it reduces back to geting right flags from it.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#9 lore raw
In reply to David Woodhouse
Quoted 2 lines

The correct way to build modules out of the kernel tree is to use the kernel makefiles and override SUBDIRS to point at your own directory;

That philosophy seems to fly in the face of the very modularity that makes modules great. If you accept the idea that your module source code should be arranged the same way as Linux kernel source code and built the same way, you might as well just maintain your code as a patch to the Linux source tree.

But if you accept the idea that a module writer can write his own make file, then he is free to organize the source code in original ways, use a language other than C, and share code or structure with non-Linux applications (e.g. device drivers for the same device in other OSes).

I of course use the include/ directory from the Linux source tree to compile my out-of-tree modules, but I would need more convincing to use any other part of the tree.

I know there are things that can change in Linux that would make an independent module build no longer correct, but there has to be a better way to deal with that than by having Linux supply the make files.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#10 lore raw
Quoted 9 lines · Bryan Henderson
Quoted 2 lines

The correct way to build modules out of the kernel tree is to use the kernel makefiles and override SUBDIRS to point at your own directory;

That philosophy seems to fly in the face of the very modularity that makes modules great. If you accept the idea that your module source code should be arranged the same way as Linux kernel source code and built the same way, you might as well just maintain your code as a patch to the Linux source tree.

Quoted 4 lines

But if you accept the idea that a module writer can write his own make file, then he is free to organize the source code in original ways, use a language other than C, and share code or structure with non-Linux applications (e.g. device drivers for the same device in other OSes).

Um, I think the point is that no one does accept that idea. And if you try to write your own makefile, then you deserve any problems that you might have, as the kernel build developers have repeatedly told people how to do this properly so that things to not break.

greg k-h

#11 lore raw
Quoted 2 lines
Quoted 2 lines

But if you accept the idea that a module writer can write his own make file, then he is free to organize the source code in original ways, use

a

Quoted 4 lines
Quoted 2 lines

language other than C, and share code or structure with non-Linux applications (e.g. device drivers for the same device in other OSes).

Um, I think the point is that no one does accept that idea.

I think that's a bit of an overstatement. We've heard from two people today who accept that idea, and I've given reasons that others might intelligently do so. Probably the strongest statement you can make is that no kernel developers accept that idea. And I could believe that, considering there are several ideas on which kernel developers and maintainers of out-of-tree kernel code often don't see eye to eye. Like whether you should give users your source code and the importance of base kernel interfaces remaining the same from one release to the next.

Quoted 4 lines

And if you
try to write your own makefile, then you deserve any problems that you might have, as the kernel build developers have repeatedly told people how to do this properly so that things to not break.

I do agree with that. You take the good with the bad. Same goes for deciding whether to keep your code in its own directory or patch the kernel tree and whether to distribute your code separately or get it accepted into Linus' or some other kernel tree.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#12 lore raw
Quoted 8 lines · Bryan Henderson
Quoted 6 lines
Quoted 4 lines

But if you accept the idea that a module writer can write his own make file, then he is free to organize the source code in original ways, use a language other than C, and share code or structure with non-Linux applications (e.g. device drivers for the same device in other OSes).

Um, I think the point is that no one does accept that idea.

I think that's a bit of an overstatement.

I accept the idea. I also accept the idea that said module writer can also write all his own include files _too_, and avoid even having to have a kernel tree around at all.

I think he'd have to be on crack, but I do accept that he _can_ do that.

But I don't want him asking for support, and I don't want him advocating this practice to newbies.

Do what you like in the privacy of your own home; I really couldn't give a monkey's. Just don't talk about it in public :)

Signature · 1 line
dwmw2
#13 lore raw
Quoted 3 lines · David Woodhouse

I accept the idea. I also accept the idea that said module writer can also write all his own include files _too_, and avoid even having to have a kernel tree around at all.

I don't think you can entertain that idea, because...

Quoted 1 line

I think he'd have to be on crack, but I do accept that he _can_ do that.

...to write his own files which allow modules to work with the kernel would require duplicating the existing include files in great detail - perhaps enough to count as a derived work.

In other words, it's widely believed that he _can't_ do that.

Fwiw I don't have any problem with this.

-- Jamie

ps. It may be possible, after all people have written binary modules for other operating systems purely by reverse engineering the operating system, starting with no source. Perhaps that's what you're advocating ;)

#14 lore raw
Quoted 7 lines · Jamie Lokier
Quoted 1 line

I think he'd have to be on crack, but I do accept that he _can_ do that.

...to write his own files which allow modules to work with the kernel would require duplicating the existing include files in great detail - perhaps enough to count as a derived work.

In other words, it's widely believed that he _can't_ do that.

He _can_ do it. If he actually does it by a large amount of copying, then you are correct that he _may_ not distribute the result under a licence other than the GPL. But he _can_ do it for his own purposes.

Quoted 1 line

Fwiw I don't have any problem with this.

What consenting adults do in the privacy of their own home I have no problem with. I don't want to see it advocated in public, to people who know no better.

Signature · 1 line
dwmw2