Skip to content
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

MUSL support #141

Open
repi opened this issue Oct 10, 2021 · 2 comments
Open

MUSL support #141

repi opened this issue Oct 10, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@repi
Copy link
Contributor

repi commented Oct 10, 2021

Would be nice to be able to support building for and running on x86_64-unknown-linux-musl to use PhysX more easily across linux distributions.

Did a quick test compile and ran into this linking error:

  = note: /usr/bin/ld: /workspaces/ark/target/x86_64-unknown-linux-musl/release/deps/libphysx_sys-6a6d040663f16ba9.rlib(PsUnixFPU.o): undefined reference to symbol 'feenableexcept@@GLIBC_2.2.5'

looks like the fenv.h that physx is using in physx-sys/PhysX/physx/source/foundation/src/unix/PsUnixFPU.cpp uses a couple of GCC-specific extensions to the POSIX fenv.h that does not exist on MUSL:

PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions()
{
#if PX_LINUX && !defined(__EMSCRIPTEN__)
	feclearexcept(FE_ALL_EXCEPT);
	feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
#elif PX_OSX

Should be able to disable those fp exception functions similar to how it is disabled on Emscripten, but requires further patching the PhysX code. Don't think MUSL has a global preprocessor define enabled (or does it?) but we could provide one when building for x86_64-unknown-linux-musl target in build.rs

cc @Jake-Shadle

@repi repi added the enhancement New feature or request label Oct 10, 2021
@repi
Copy link
Contributor Author

repi commented Oct 10, 2021

Commenting out the FP exception functions and running our small ball_physx example results in a crash so more work would be need to investigate that.

(lldb) thread backtrace
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
* thread #1, name = 'ball_physx', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x00007ffff799e81f ball_physx`create_simulation_event_callbacks + 15
    frame #2: 0x00007ffff79994e2 ball_physx`physx::simulation_event_callback::PxSimulationEventCallback$LT$L$C$S$C$D$C$OC$C$OT$C$OCB$C$OWS$C$OA$GT$::new::h4637e7f3d90d3ca9(on_collide=None, on_trigger=None, on_constraint_break=None, on_wake_sleep=None, on_advance=Some) at simulation_event_callback.rs:99:17
    frame #3: 0x00007ffff79860c0 ball_physx`_$LT$physx..traits..descriptor..SceneDescriptor$LT$U$C$L$C$S$C$D$C$T$C$C$C$OC$C$OT$C$OCB$C$OWS$C$OA$GT$$u20$as$u20$physx..traits..descriptor..Descriptor$LT$P$GT$$GT$::create::hb169d9199454bdec(self=SceneDescriptor<(), physx::articulation_link::PxArticulationLink<(), physx::shape::PxShape<(), physx::material::PxMaterial<()>>>, physx::rigid_static::PxRigidStatic<(), physx::shape::PxShape<(), physx::material::PxMaterial<()>>>, physx::rigid_dynamic::PxRigidDynamic<(), physx::shape::PxShape<(), physx::material::PxMaterial<()>>>, physx::articulation::PxArticulation<(), physx::articulation_link::PxArticulationLink<(), physx::shape::PxShape<(), physx::material::PxMaterial<()>>>>, physx::articulation_reduced_coordinate::PxArticulationReducedCoordinate<(), physx::articulation_link::PxArticulationLink<(), physx::shape::PxShape<(), physx::material::PxMaterial<()>>>>, ball_physx::OnCollision, ball_physx::OnTrigger, ball_physx::OnConstraintBreak, ball_physx::OnWakeSleep, ball_physx::OnAdvance> @ 0x00007fffffffbe58, creator=0x00007fffffffc028) at descriptor.rs:209:42
    frame #4: 0x00007ffff7987962 ball_physx`physx::physics::Physics::create::h5439a1448557181d(self=0x00007fffffffc028, desc=<unavailable>) at physics.rs:246:9
    frame #5: 0x00007ffff7997a50 ball_physx`ball_physx::main::hf867c05f1057308f at ball_physx.rs:87:37
    frame #6: 0x00007ffff7983e4b ball_physx`core::ops::function::FnOnce::call_once::h4c21a1faa1ee8321((null)=(ball_physx`ball_physx::main::hf867c05f1057308f at ball_physx.rs:79), (null)=<unavailable>) at function.rs:227:5
    frame #7: 0x00007ffff798b47e ball_physx`std::sys_common::backtrace::__rust_begin_short_backtrace::h2f749092f39794ea(f=(ball_physx`ball_physx::main::hf867c05f1057308f at ball_physx.rs:79)) at backtrace.rs:125:18
    frame #8: 0x00007ffff7988c01 ball_physx`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h064f6c6770b34b01 at rt.rs:63:18
    frame #9: 0x00007ffff7e4b760 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h5edb75ac3af12064 at function.rs:259:13
    frame #10: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panicking::try::do_call::h4398f4e6da05592f at panicking.rs:401
    frame #11: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panicking::try::h3fe03463ab3f9a9d at panicking.rs:365
    frame #12: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panic::catch_unwind::h3f31a496b3e5f0e5 at panic.rs:434
    frame #13: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h24e3f631c8bb6bd5 at rt.rs:45
    frame #14: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panicking::try::do_call::h9268f45ee0925288 at panicking.rs:401
    frame #15: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panicking::try::he93fcdbaacc3daf7 at panicking.rs:365
    frame #16: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b [inlined] std::panic::catch_unwind::hca9f2323bf3773b4 at panic.rs:434
    frame #17: 0x00007ffff7e4b755 ball_physx`std::rt::lang_start_internal::hfee0032b3594c35b at rt.rs:45
    frame #18: 0x00007ffff7988bd0 ball_physx`std::rt::lang_start::hbcaa456adb732f31(main=(ball_physx`ball_physx::main::hf867c05f1057308f at ball_physx.rs:79), argc=1, argv=0x00007fffffffc5c8) at rt.rs:62:5
    frame #19: 0x00007ffff799806c ball_physx`main + 28
    frame #20: 0x00007ffff7e6efe8 ball_physx`libc_start_main_stage2 + 39
    frame #21: 0x00007ffff7982801 ball_physx`_start + 22

@Jake-Shadle
Copy link
Member

No, musl does not have any default preprocessor definitions for detection, so yes the easiest would just be to add a musl preprocessor definition if targeting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants