New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MACOSX: Add dynamic plugin support to macOS bundles #3877
base: master
Are you sure you want to change the base?
MACOSX: Add dynamic plugin support to macOS bundles #3877
Conversation
…chivesToSearchSet()
Oh sweet. |
@raziel- Yeah of course, but I'm afraid I have no real knowledge in loading plugins on AmigaOS if that's your goal. Most of the hard work for Mac PPC and dynamic plugins on macOS was already there for a long time, here I'm just doing the final assembly ;) |
Heh, no problem. And I already read through your changes and will try the 'strip -x' approach to see if it fixes some shared build oddities for me. So, you already helped :-) |
@BeWorld2018 - Change plugin naming - Add using dl library for dynamic - Add "x" flag for strip to preserve global symbols with dynamic (honestly stolen from @dwatteau and scummvm#3877) ;-) I'd like to get your confirmation on this, since it also touches MorphOS. Otherwise i'll have to split targets. Conforming to many of the other platforms use of plugin naming and to distinguish between ScummVM's engine plugins and the OS' shared objects/libraries names.
Great! Adding support for dynamic plugins is I think the correct way to go to resurrect the PPC port due to the executable size limitations. That could maybe also be of interest for more recent macOS versions, even if not required. Something else that could have helped as well and that I wanted to look at is to use dynamic libraries rather than static ones for the bundles. I will need a bit more time to review the actual changes, but this seems to go in the right direction. |
Great work! I have suggested a couple of changes which I think would be good, but otherwise this is in good shape and ready to merge.
And a bit of nitpicking for the commit message prefixes:
ad6bf69
to
d62e268
Compare
…y on macOS Global symbols should be kept when building dylibs.
Otherwise, making a macOS bundle with plugins wouldn't load any of these plugins (i.e. -all_load is required).
As suggested by criezy, we don't need to use the C-bridge from Core Foundation now that the wrapper has been moved to an Objective-C file.
d62e268
to
e6bd6e8
Compare
@BeWorld2018 - Change plugin naming - Add using dl library for dynamic - Add "x" flag for strip to preserve global symbols with dynamic (honestly stolen from @dwatteau and #3877) ;-) I'd like to get your confirmation on this, since it also touches MorphOS. Otherwise i'll have to split targets. Conforming to many of the other platforms use of plugin naming and to distinguish between ScummVM's engine plugins and the OS' shared objects/libraries names.
This PR lets one build and run a macOS Bundle (=
ScummVM.app
) with dynamic plugins for the game engines.I'm doing this to resurrect the Mac PowerPC port, where the old PowerPC linker can't cope with a single static ScummVM binary with all engines anymore (and Mach-O doesn't offer as many flags as ELF to work around this).
This is split into several smaller commits:
OSystem_MacOSX::addSysArchivesToSearchSet()
so that we now have a separategetResourceAppBundlePathMacOSX()
wrapper (so that both the shader and plugin loading code can use it).addCustomDirectories()
(like the Nintendo DS port does), so that plugins can be loaded from the current macOS bundle if it exists.strip -x
to strip the main scummvm binary when building plugins, in order to keep global symbols (otherwise the plugins will fail loading).$(PRE_OBJS_FLAGS)
variable (i.e.-all_load
) when linkingscummvm-static
, otherwise it will fail loading its dynamic plugins, too.ports.mk
install plugins toContents/Resources/
in the bundle, when dynamic plugins are enabled.It should have no impact on default macOS Intel/ARM builds, which don't use dynamic plugins by default at the moment.
However, I don't have a lot of experience with macOS bundles and plugins, so I hope I'm not doing any big mistake here.
Tested on Tiger (which needs a couple of build fixes that I've put into PR #3878) and Monterey.