petdance/scratch — Issue #150: dynext - dll versioning
Author: petdance
Created: 2011-11-14 05:55:04+00:00
State: open
Labels: Pri-normal, Sev-medium, todo

Thanks to the Windows DLL Hell L
and the impossibility of file hardlinks, windows dll names are hopefully
versioned, so either the loadlib function or the various pir's needs
more logic for maintainance convenience.

Keep the lib_paths and share_ext search, add more name munging for
special platforms.

Either
1) add the version to each loadlib call, and stem the version from
POSIX versions within get_path().

loadlib lib, 'libSDL-1.2.so.0'

=> try: libSDL-1.2.so.0, libSDL-1.2.so

stemmed: libSDL.so
on WIN32: SDL-1.2.dll, SDL.dll
on cygwin: cygSDL-1.2.dll, cygSDL.dll

Maybe also detect the "-1.2.so.0" and convert it to "-1.2.0.dll"

2) add an optional version argument to loadlib. (preferred)

loadlib lib, 'SDL', '1.2.0'

=> Try: first always prefix with "lib"
libSDL-1.2.0.so, libSDL-1.2.so.0, libSDL-1.2.so, libSDL.so
other rules stay as they are. (lib_paths + share_ext)
on WIN32: no lib prefix and try versions.
SDL-1-2-0.dll, SDL-1-2.dll, SDL-1.2.0.dll, SDL-1.2.dll, SDL.dll
on cygwin: cyg prefix and try versions with '.' and '-'.
cygSDL-1.2.dll, cygSDL-1.2.0.dll, cygSDL-1-2-0.dll, cygSDL-1-2.dll

All the pir's for the latest packaged libraries are fixed with RT#51328.

RT#51328 also applies the addional lib => cyg dll logic, but does not
help with versioned dll's, as for ncurses and SDL most prominently.

Examples what we want to avoid:

loadlib $P1, 'libform'
+if $P1 goto has_lib
+loadlib $P1, 'cygform-8'
+has_lib:

loadlib $P1, 'libncurses'
+if $P1 goto has_lib1
+loadlib $P1, 'cygncurses-8'
+has_lib1:

# third try
loadlib libsdl, 'libSDL-1.2.so.0'

+ loadlib libsdl, 'cygSDL-1-2-0'
+ $I0 = typeof libsdl
+ if $I0 != .Undef goto OK

loadlib image_lib, 'libSDL_image-1.2.so.0'
$I0 = typeof image_lib
if $I0 != .Undef goto OK_HINT2

+ loadlib image_lib, 'cygSDL_image-1-2-0'
+ $I0 = typeof image_lib
+ if $I0 != .Undef goto OK
+

See also other ffi's, such as cffi, how they do deal or not with this
problem. Years ago I wrote an overview at
http://autocad.xarch.at/lisp/ffis.html
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/
http://helsinki.at/ http://spacemovie.mur.at/

Originally http://trac.parrot.org/parrot/ticket/1155