Ticket #478 (new defect)

Opened 18 months ago

Last modified 12 months ago

Fixes for build and run time problems under Mac OS X

Reported by: Tron Owned by: lennart
Milestone: Component: core
Keywords: Cc:

Description

"pulseaudio" doesn't build and work under Mac OS X:

1.) "core-util.c" requires an extra include file to build. I'll provide a patch

for that problem.

2.) "proplist-util.c" uses "extern char **environ" to get to the list of environment

variables which doesn't work under Mac OS X. This doesn't break the build but applications linked against the "pulse" library cannot be started. I'll provide a patch for that problem as well.

3.) The build uses various ELF specific linker options that Mac OS X doesn't

understand. The options are:

--gc-sections -version-script=./map-file -no-undefined -z nodelete

Somebody should probably write configure tests to check whether these options are actually supported. NetBSD e.g. also doesn't understand "--gc-sections".

Attachments

core-util.c.patch (300 bytes) - added by Tron 18 months ago.
Build fix for "src/pulsecore/core-util.c"
proplist-util.c.patch (464 bytes) - added by Tron 18 months ago.
Run time fix for "src/pulsecore/proplist-util.c"

Change History

Changed 18 months ago by Tron

Build fix for "src/pulsecore/core-util.c"

Changed 18 months ago by Tron

Run time fix for "src/pulsecore/proplist-util.c"

Changed 18 months ago by lennart

Thanks for the patches.

--gc-sections should probably be dropped anyway.

The version script stuff is not that important, the same is true for -no-undefined. But -z nodelete *is* important. That flag controls whether libpulse is ever unloaded from a process' memory. I hope MacOS provides similar functionality by some other means.

Changed 18 months ago by lennart

Uh, --gc-sections actually has been removed quite some time ago. Same is true for -no-undefined.

Your patches are against which version of PA?

Changed 18 months ago by Tron

My patches are for version 0.9.14, the latest release. And that version definitely uses these options.

Changed 18 months ago by lennart

hmm, indeed, i didn't backport the removals of those options to .14 when i did that release.

Changed 18 months ago by lennart

I commited those two patches in r04c3c67.

Current git is a relatively big step forward and includes quite a few changes that might need porting. I'd recommend basing any porting work on current git master which will become .15 later next week.

Not closing this bug, since there still needs to be found a way to replace -z nodelete sensibly on MacOS.

Changed 18 months ago by Tron

There is no equivalent of "-z nodelete" under Mac OS X. Please remember that it doesn't use the ELF binary format.

And to be honest after reading what "-z nodelete" does I'm not convinced that using this option is a good idea in general. I would make more sense to use a destructor function that will make unloading the shared library or shared object safe.

BTW: any problems with the patches for the C sources?

Changed 18 months ago by lennart

Sure, I know it's not ELF. That doesn't mean there is no equivalent for -z nodelete.

Destructor functions unbfortunately are no option. We used them in the past and they are still used if you set $VALGRIND=1. The reason why they are not useful to us is that we have to deal with the case that a process exits while background threads that access pa structures are still running. The destructor functions will be called by the thread that calls exit() -- while the oher threads might still be running. Hence we cannot free all data structures they might still access. Except if we'd add a horrible and fragile and unportable locking logic just for this. This problem was exposed in the past in libcanberra which may dynamically load/unload libpulse. The main program may call exit() at any time while a libcanberra thread might still be running. So using destructors resulted in segfaults in some cases. (Oh, and believe me this was hard to debug). The alternative, not using destructors is only viable if we have -z nodelete since otherwise we will leak memory each time we are pulled in via dlopen(). Which became very visible with libcanberra, too.

So, I see no other option than having -z nodelete or some other similar option.

Maybe it is possible to hack something based on dlopen(RTLD_NODELETE) for Macosx?

Changed 18 months ago by Tron

The manual page of dlopen(3) mentions that open:

RTLD_NODELETE The specified image is tagged so that will never be

removed from the address space, even after all clients have released it via dlclose()

So it might be possible to use it.

Changed 12 months ago by lennart

PA in git now checks for support of Wl,-z,nodelete. And uses it only when it exists. This half-way fixes this, but ideally on MacOS we had something that makes sure that the .sos are not unloaded either.

Note: See TracTickets for help on using tickets.