Use the -D_KERNEL option to indicate that this code defines a kernel module.
If you are compiling for a 64-bit SPARC architecture using Sun Studio 9, Sun Studio 10, or Sun Studio 11, use the -xarch=v9 option:
% cc -D_KERNEL -xarch=v9 -c mydriver.c % /usr/ccs/bin/ld -r -o mydriver mydriver.o |
If you are compiling for a 64-bit SPARC architecture using Sun Studio 12, use the -m64 option:
% cc -D_KERNEL -m64 -c mydriver.c % /usr/ccs/bin/ld -r -o mydriver mydriver.o |
If you are compiling for a 64-bit x86 architecture using Sun Studio 10 or Sun Studio 11, use both the -xarch=amd64 option and the -xmodel=kernel option:
% cc -D_KERNEL -xarch=amd64 -xmodel=kernel -c mydriver.c % /usr/ccs/bin/ld -r -o mydriver mydriver.o |
If you are compiling for a 64-bit x86 architecture using Sun Studio 12, use the -m64 option, the -xarch=sse2a option, and the -xmodel=kernel option:
% cc -D_KERNEL -m64 -xarch=sse2a -xmodel=kernel -c mydriver.c % /usr/ccs/bin/ld -r -o mydriver mydriver.o |
If you are compiling for a 32-bit architecture, use the following build commands:
% cc -D_KERNEL -c mydriver.c % /usr/ccs/bin/ld -r -o mydriver mydriver.o |
Sun Studio 9 does not support 64-bit x86 architectures. Use Sun Studio 10, Sun Studio 11, or Sun Studio 12 to compile and debug drivers for 64-bit x86 architectures.
For more information on compile and link options, see the Sun Studio Man Pages and the Sun Studio 12: C User’s Guide. See the Sun Studio Information Center in the Sun Studio 12 Collection for Sun Studio books about dbx, dmake, Performance Analyzer, and other software development topics. To read technical articles about Sun Studio, see Sun Studio Technical Articles. To download Sun Studio, go to http://developers.sun.com/sunstudio/.