dk / PDL-Drawing-Prima

Low-level PDL-threaded interface to the Prima drawing commands.
5 stars 4 forks source link

make linking work in "place with space" on Windows #42

Closed mohawk2 closed 1 year ago

mohawk2 commented 1 year ago

As realised in investigating https://github.com/PDLPorters/PDL-Graphics-Prima/pull/50, if Perl is installed in a "place with space" (a directory with a space in its name), this module doesn't work on Windows, because it doesn't quote-protect $Prima::Config::Config{libs}. This PR fixes that, and makes this module build successfully for my awkward setup.

It would probably be even better to make Prima-using libraries behave the same on Windows and Unix, possibly using a similar scheme to PDL (a $PDL::SHARE with a pointer to a C struct).

dk commented 1 year ago

Merged, thank you. About $PDL::SHARE - could you elaborate on that? I'm not quite happy with the way one defined INC/LIB/DEFINE for prima-dependent modules and am open for ideas

mohawk2 commented 1 year ago

PDL's Core.xs has a BOOT section that sets $PDL::SHARE: https://github.com/PDLPorters/pdl/blob/cfbcb08b540aa8a9f71e09ff9bc1314f6040f7be/Basic/Core/Core.xs#L428-L445

This is then accessed by various PDL XS modules, setting it to a C file-global called PDL (these days, after the "multi-C" change, it isn't a static variable called PDL anymore, it's a non-static variable whose name PDL gets #defined to - if you're operating a scheme of single-file Prima-using modules, don't worry): https://github.com/PDLPorters/pdl/blob/cfbcb08b540aa8a9f71e09ff9bc1314f6040f7be/Basic/Core/Dev.pm#L65-L85

This operates as a sort of SV-mediated dynamic linking scheme, to avoid dyn-linking the actual PDL-using libraries to the main PDL::Core one. That was in place before I ever heard of PDL, and I haven't changed it.

mohawk2 commented 1 year ago

PDL uses its PDL::Core::Dev::pdlpp_stdargs to make it easy to set various EUMM variables like INC, DEFINE etc by returning a hash. Prima might copy this with a Prima::Dev::prima_stdargs that does the same.