Re: Building a 10.4 compatible CA driver on 10.6
Re: Building a 10.4 compatible CA driver on 10.6
- Subject: Re: Building a 10.4 compatible CA driver on 10.6
- From: "B.J. Buchalter" <email@hidden>
- Date: Fri, 3 Sep 2010 20:31:43 -0400
On Sep 2, 2010, at 5:55 PM, Jeff Moore wrote:
> Good questions. The only thing that springs to my mind is that perhaps there is some difference in the name mangling between the compilers on the two platforms. Of course, you'd expect a problem like that to show up for more than just one symbol, but it's the best I have =)
>
> At any rate, I wish I had more specific advice for you. You might try posing this question on one of the darwin or IOKit lists.
So I have gotten this working and I thought that I would summarize what I had to do in order to get this to work in the hopes that it will help anyone else dealing with this issue as a bunch of it is very specific to CoreAudio drivers due to the need to support floating point in the kernel.
So, here are the issues:
1) 10.4 Drivers must be compiled with GCC 4.0
2) 10.4 PPC Drivers must effectively be compiled against the 10.4 SDK
3) 10.4 PPC drivers must be compiled with -mlong-branch set
4) the 10.6 ld does not really like binaries compiled with -mlong-branch
5) CA drivers need to have the driver compiled and linked in kext mode, but they also need a library compiled without the kext mode set so that they can access floating point and altivec.
6) Setting kext mode automatically sets -mlong-branch and puts the linker in a mode that supports -mlong-branch
7) the non-kext mode library causes the driver to not load if compiled without -mlong-branch, and causes the link to fail if compiled with -mlong-branch and linked with the 10.6 ld without additional command line options.
So, you need to install the 10.4u SDK (which is an optional install)
You need to set up the 10.4 driver project with the 10.4u SDK as the SDK for the driver.
You need to set up the compiler as 4.0 for both the driver and library targets (this is done below)
For the Floating Library target you need to set the following build settings:
-----------------------------------------------------------------------------
OTHER_CFLAGS = -fapple-kext -fno-schedule-insns -fno-schedule-insns2 -static -findirect-virtual-calls
OTHER_CFLAGS[arch=ppc] = -DKPI_10_4_0_PPC_COMPAT -fapple-kext -fno-schedule-insns -fno-schedule-insns2 -static -findirect-virtual-calls
LIBRARY_STYLE = STATIC
GCC_ENABLE_BUILTIN_FUNCTIONS = NO
GCC_USE_INDIRECT_FUNCTION_CALLS = YES
GCC_CHECK_RETURN_VALUE_OF_OPERATOR_NEW = YES
GCC_ALTIVEC_EXTENSIONS = YES
GCC_ENABLE_CPP_EXCEPTIONS = NO
GCC_ENABLE_CPP_RTTI = NO
GCC_DYNAMIC_NO_PIC = NO
GCC_NO_COMMON_BLOCKS = YES
GCC_OPTIMIZATION_LEVEL = 3
OTHER_LDFLAGS = -Xlinker -no_uuid -Xlinker -classic_linker
GCC_VERSION = 4.0
SDKROOT = macosx10.4
GCC_ENABLE_KERNEL_DEVELOPMENT = NO
GCC_PREPROCESSOR_DEFINITIONS = KERNEL KERNEL_PRIVATE DRIVER_PRIVATE APPLE NeXT
For the Driver target you need to set the following build settings:
-----------------------------------------------------------------------------
SDKROOT = macosx10.4
OTHER_LDFLAGS = -Xlinker -no_uuid
OTHER_CFLAGS =
OTHER_CFLAGS[arch=ppc] = -DKPI_10_4_0_PPC_COMPAT
GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO
GCC_USE_INDIRECT_FUNCTION_CALLS = YES
GCC_ENABLE_KERNEL_DEVELOPMENT = YES
The points to note are that for PPC, OTHER_CFLAGS needs to have
-DKPI_10_4_0_PPC_COMPAT
In order for the 10.4u SDK to work (otherwise you will get the superclass mis-match issue).
GCC_USE_INDIRECT_FUNCTION_CALLS = YES
is necessary for the kernel linker to be able to relocate the driver
OTHER_LDFLAGS = -Xlinker -no_uuid
is necessary for the kernel linker to not barf on the mach-o created
and
OTHER_LDFLAGS = -Xlinker -no_uuid -Xlinker -classic_linker
for the float lib is required to get ld on 10.6 to not barf on the relocations created by GCC_USE_INDIRECT_FUNCTION_CALLS=YES
The other settings for the float lib are required to match the non-floating point environmental settings for the kernel environment and headers.
At the end of the day, YMMV, but those settings work for me to build a driver on 10.6 with the most recent version of XCode (3.2.3) that loads on everything from 10.4 - 10.6 on both PPC and Intel.
I hope that this helps anyone who is trying to get this to work.
Best regards,
B.J. Buchalter
Metric Halo
http://www.mhlabs.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden