What other parameters do I need to add to the following in order to ignore built in functions - I'm moving along with my OS, slowly but surely, and now when I try to compile my kernel, I get errors of something like 'Parameter type mismatch with built in function setmem()' when I include my system.h with the reference to my setmem functions.
This is using the cross compiler using precisely the same version of binutils and gcc as specified in the Wiki, compiled under Fedora Core 3, with I believe GCC 3.4.2.
/usr/cross/bin/i586-elf-gcc-3.4.0 -std=c99 -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs -I./
Exclude built in functions?
Re:Exclude built in functions?
These are the parameters I use for my kernel compile:
-nostartfiles -nostdlib -nodefaultlibs -nostdinc
-fno-builtin -fvolatile -fvolatile-global -fvolatile-static
Seems to work....
-nostartfiles -nostdlib -nodefaultlibs -nostdinc
-fno-builtin -fvolatile -fvolatile-global -fvolatile-static
Seems to work....
Re:Exclude built in functions?
i use:
-fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin
Re:Exclude built in functions?
Well, my set of flags is more or less:
Both variables are given to compiler. They are separated mainly make the Makefile more manageable.
-pipe just makes gcc use pipes instead of temporary files
-march=i486 says it's ok to use 486-only stuff (this could probably be higher.. but)
-O3 is maximum optimization level (4-6 don't add anything)
-fno-omit-frame-pointer tells gcc to leave frame pointers alone, so I can dump stack on panic. Could be omitted for production compiles. This is explicitly there because -O3 turns enables the optimization otherwise.
-mpreferred-stack-boundary=2 aligns stack boundaries to 2^2 = 4 bytes. That's minimum correct alignment for ia-32. The default would be 4 (=2^4=16 bytes), but I prefer not to waste stack space (so I can have smaller kernel stacks) and don't need bigger alignment for anything.
-fno-strict-aliasing is needed because I do some fancy stuff with pointers and integers, and generally violate all kinds of aliasing rules.
-nostdinc disable standard includes
-nostdlib disables standard libraries (libC etc.)
-fno-builtin tells gcc not to expect it's "builtins" to work
-ffreestanding isn't really needed on Linux I believe, but..
-fno-common is really just there as a sanity check, so I don't accidentally share a variable unintentionally between to units
I also use:
First one gives us a new include path (the standard was disabled), and the second causes tons of warnings to be emitted, and made fatal, mainly to sanitycheck that everything is really what it looks like.
Btw: -fvolatile* might not be good idea. This can cause quite a dramatic speed hit in places where it's not really needed. Personally I prefer to declare any volatile stuff explicitly as volatile. I find the flag useful mainly when a bug looks like it might be caused by a missing 'volatile'-qualifier (if it's fixed by the flag, then something isn't declared properly).
Code: Select all
CODEGEN = -pipe -march=i486 -O3 -fno-omit-frame-pointer \
-mpreferred-stack-boundary=2 -fno-strict-aliasing
NOLIBS = -nostdinc -nostdlib -fno-builtin -ffreestanding -fno-common
-pipe just makes gcc use pipes instead of temporary files
-march=i486 says it's ok to use 486-only stuff (this could probably be higher.. but)
-O3 is maximum optimization level (4-6 don't add anything)
-fno-omit-frame-pointer tells gcc to leave frame pointers alone, so I can dump stack on panic. Could be omitted for production compiles. This is explicitly there because -O3 turns enables the optimization otherwise.
-mpreferred-stack-boundary=2 aligns stack boundaries to 2^2 = 4 bytes. That's minimum correct alignment for ia-32. The default would be 4 (=2^4=16 bytes), but I prefer not to waste stack space (so I can have smaller kernel stacks) and don't need bigger alignment for anything.
-fno-strict-aliasing is needed because I do some fancy stuff with pointers and integers, and generally violate all kinds of aliasing rules.
-nostdinc disable standard includes
-nostdlib disables standard libraries (libC etc.)
-fno-builtin tells gcc not to expect it's "builtins" to work
-ffreestanding isn't really needed on Linux I believe, but..
-fno-common is really just there as a sanity check, so I don't accidentally share a variable unintentionally between to units
I also use:
Code: Select all
INCLUDES = -I. -Iinclude
WARNINGS = -Werror -Wall -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wcast-qual
Btw: -fvolatile* might not be good idea. This can cause quite a dramatic speed hit in places where it's not really needed. Personally I prefer to declare any volatile stuff explicitly as volatile. I find the flag useful mainly when a bug looks like it might be caused by a missing 'volatile'-qualifier (if it's fixed by the flag, then something isn't declared properly).
Re:Exclude built in functions?
Thanks. I'll remove the volatile stuff and be specific in the source about which variables are... All my stuff is locked, so it shouldn't cause any problems.
Re:Exclude built in functions?
Just add
-fno-builtin
to Your compile command, shall be ok.
P.S. Even after that You can use built-in functions :
instead of writing your ones.
-fno-builtin
to Your compile command, shall be ok.
P.S. Even after that You can use built-in functions :
Code: Select all
__builtin_memset();
__builtin_memcpy();
Re:Exclude built in functions?
Actually, -ffreestanding should also do the trick.
It tells gcc that no environnment of any kind is to be expected when compiling (and this flag implies -fno-builtin).
According to gcc man page, it's particularly useful for... kernel programming
It tells gcc that no environnment of any kind is to be expected when compiling (and this flag implies -fno-builtin).
According to gcc man page, it's particularly useful for... kernel programming
Re:Exclude built in functions?
A good variety of information and answers here. Thanks, I'll try this out tomorrow.