-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Building PhysX as multiple DLLs or a single DLL #4
Comments
Hi David, When do you think you will have the DLLs / DLL ready for consumption? Cheers, Ander |
Hello Ander! Apologies for the radio silence. I had meant to send a GitHub Sponsors update last month but time really got away from me in October. (If you check your email you should have just gotten one for November) I plan to get CI stood up on the PhysX bindings in the next week or so, and that will bring along with it binaries and eventually NuGet packages. If you just want to tinker, here's a fresh zip of the current Windows x64 binaries built from the current main for the sample, the unmanaged bindings, and the native runtime: Mochi.PhysX.Sample.zip
|
… built. * Updated to latest PhysX SDK * Removed the need to use a modified version of the SDK * Updated to latest Biohazrd * Started rebrand to Mochi.PhysX * We now primarily index through PxPhysicsAPI.h (which includes all of the public API surface with a few exceptions we manually account for -- The UnusedFiles.txt report can be used to find new exceptions as needed.) * We no longer attempt to index the "intrinsics" files from any platform. * Added build.cmd/build.sh for automatically configuring+building PhysX and regenerating the bindings * Moved bin/obj folders to a central location at the repository root * Added property for querying the build info (IE: PhysX SDK version, build variant) of the native runtime. * The native PhysX bits are now built down into a single Mochi.PhysX.Native.dll/libMochi.PhysX.Native.so without intrusive modifications to the PhysX build system. Fixes #1 Fixes #4
@AnderT, if you didn't already see I published v0.0.0-alpha0 to NuGet a few minutes ago. Apologies for the delay, let me know if you run into any issues! |
This issue is mostly to note my thoughts and reasoning behind how I ended up at the solution I'll eventually be pushing here.
Special compilation target for a single DLL
This is what the original prototype used. It worked by adding a special CMake target to PhysX its self which used CMake shenanigans to combine the various parts of PhysX into a single DLL. This modified
InfectedPhysX.Native.dll
also included the equivalent of the inline export helpers at the time.This approach had some major downsides:
INSTALL
target.)LinkImportsTransformation
InfectedPhysX.Native.dll
, but then we miss out on validation.Using individual DLLs like PhysX normally does
This feels the most natural and requires 0 modification to the PhysX repo. However it has a major downside of not handling the static components of PhysX very well:
PX_GENERATE_STATIC_LIBRARIES
is disabled.PX_GENERATE_STATIC_LIBRARIES
disabled by default.I worked around the static library issue on Windows by generating linker response files along these lines:
I also experimented with doing something similar (and much simpler) on Linux:
However, either way you cut it both of these are adding quite a bit of complexity. (Particularly with the Windows version since in the above form it needs paths to a bunch of system junk.)
There's also the question of whether or not unintentional static non-sharing is occurring like we had with libclang. This isn't really easy to validate and could easily be happening between the inline export helper and the converted static libraries since the inline export helper is going to end up linking in its own copy of the static libraries it depends on. There may be nothing like this (there honestly probably isn't), but it's a HUGE pain when it pops up.
In theory we could gain some peace of mind here by converting each static library into a DLL along with its corresponding inline export helpers but that's even more added complexity and would require we either build the inline export helpers directly in-generator, have the generator emit individual CMake project, or hard-code individual CMake projects for the individual static libraries within PhysX (and have to keep up if they ever add news ones -- which is probably rare but still a pain.)
Finally, we really need to look at what this gains us:
Common
and/orFoundation
which are required anyway.)This would also mean we need to split up the C# bindings into multiple assemblies. Not that difficult, but this runs into the same issues mentioned earlier relating to multiple CMake projects for each static library. (Although emitting a small C# file isn't very hard.)
Let's look at that main motivation: Making the build smaller through modularity.
Here's the sizes of the individual PhysX modules on Windows: (All DLLs below are the checked builds.)
(Minimum includes
InfectedPhysX.Native.dll
,PhysX_64.dll
,PhysXCommon_64.dll
, andPhysXFoundation_64.dll
since they are all absolutely mandatory.)I wanted to test the size a runtime where everything is combined* and it came out to...5.96 MB. So you'd be saving a whopping 1.82 MB if you went with the bare minimum PhysX distribution, and you'd actually be paying more if you included each module separately. Furthermore I suspect most of this is probably from PVD which isn't even present in release builds. (Well, that's what the documentation says, I built in release and still got a PVD lib.)
(*To make this runtime, I created a PhysX build preset which built Win64 as static libraries, used Biohazrd to make a list of
/EXPORT
directives for all symbols in all of those static libraires, and them built the inline export helper with those directives and linked it to the static libraries.)Building PhysX as static libraries normally and then combining them into one DLL
This is sort-of a hybrid of the above two options. We'll build PhysX with
PX_GENERATE_STATIC_LIBRARIES
enabled and combine the individual static libraries and the inline export helper into a single DLL using generated export directives (or maybe adef
file -- and the equivalent on Linux.)If it isn't obvious by now, this is the option I want to go with. IMO it's the right tradeoff between complexity and keeping our build similar to C++. It also probably gives a more natural progression towards static linking in NativeAOT scenarios. It also keeps the way we consume PhysX consistent between different platforms.
The downside of this is needing to get our presets into PhysX. I think we'll just provide a script that copies them into PhysX automagically. (Making our own preset isn't even considered non-standard, Nvidia specifically documents it as something you can do: https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/BuildingWithPhysX.html#customize-cmake-presets)
The text was updated successfully, but these errors were encountered: