To get the GNU C Compiler, first install the Oracle Solaris 11 Express OS. The developer tools are available in a repository as packages. See the Oracle Solaris 11 Express Image Packaging System Guide and the Getting Started With Oracle Solaris 11 Express
Use the -D_KERNEL option to indicate that this code defines a kernel module. These examples show options that are required for correct functionality of the result.
If you are compiling for a 64-bit SPARC architecture, use the following build commands:
% gcc -D_KERNEL -m64 -mcpu=v9 -mcmodel=medlow -fno-pic -mno-fpu -ffreestanding -nodefaultlibs -c mydriver.c % ld -r -o mydriver mydriver.o |
You might also want to use the -mtune=ultrasparc option and the -O2 option.
If you are compiling for a 64-bit x86 architecture, use the following build commands:
% gcc -D_KERNEL -m64 -mcmodel=kernel -mno-red-zone -ffreestanding -nodefaultlibs -c mydriver.c % ld -r -o mydriver mydriver.o |
You might also want to use the -mtune=opteron option and the -O2 option.
If you are compiling for a 32-bit architecture, use the following build commands:
% gcc -D_KERNEL -ffreestanding -nodefaultlibs -c mydriver.c % ld -r -o mydriver mydriver.o |
For more information on these and other options, see the gcc(1) man page. See also the GCC web site at http://gcc.gnu.org/.