{"id":21306992,"url":"https://github.com/perlalien/alien-role-dino","last_synced_at":"2026-02-02T18:03:08.539Z","repository":{"id":39580802,"uuid":"98215785","full_name":"PerlAlien/Alien-Role-Dino","owner":"PerlAlien","description":"Experimental support for dynamic share Alien install","archived":false,"fork":false,"pushed_at":"2024-12-22T21:51:45.000Z","size":417,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-22T09:11:52.579Z","etag":null,"topics":["alien","dynamic-library","perl"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerlAlien.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-24T17:18:24.000Z","updated_at":"2022-02-27T23:31:42.000Z","dependencies_parsed_at":"2022-09-04T09:42:19.293Z","dependency_job_id":null,"html_url":"https://github.com/PerlAlien/Alien-Role-Dino","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlAlien%2FAlien-Role-Dino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlAlien%2FAlien-Role-Dino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlAlien%2FAlien-Role-Dino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerlAlien%2FAlien-Role-Dino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerlAlien","download_url":"https://codeload.github.com/PerlAlien/Alien-Role-Dino/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243784103,"owners_count":20347409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alien","dynamic-library","perl"],"created_at":"2024-11-21T16:29:13.770Z","updated_at":"2026-02-02T18:03:03.488Z","avatar_url":"https://github.com/PerlAlien.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alien::Role::Dino ![linux](https://github.com/PerlAlien/Alien-Role-Dino/workflows/linux/badge.svg) ![static](https://github.com/PerlAlien/Alien-Role-Dino/workflows/static/badge.svg)\n\nExperimental support for dynamic share Alien install\n\n# SYNOPSIS\n\nIn your [alienfile](https://metacpan.org/pod/alienfile):\n\n```perl\nuse alienfile;\n\nshare {\n  ...\n  plugin 'Gather::Dino';\n}\n```\n\nApply [Alien::Role::Dino](https://metacpan.org/pod/Alien::Role::Dino) to your [Alien::Base](https://metacpan.org/pod/Alien::Base) subclass:\n\n```perl\npackage Alien::libfoo;\n\nuse base qw( Alien::Base );\nuse Role::Tiny::With qw( with );\n\nwith 'Alien::Role::Dino';\n\n1;\n```\n\nAnd finally from the .pm side of your XS module:\n\n```perl\npackage Foo::XS;\n\nuse Alien::libfoo;\n\nour $VERSION = '1.00';\n\n# Note caveat: your Alien is now a run-time\n# dependency of your XS module.\nAlien::libfoo-\u003exs_load(__PACKAGE__, $VERSION);\n\n1;\n```\n\n# DESCRIPTION\n\nEvery now and then someone will ask me why thus and such [Alien](https://metacpan.org/pod/Alien) thing \ndoesn't work with a dynamic library error.  My usual response is can you \nmake it work with static libraries?  The reason for this is that \n**building** dynamic libraries for an [Alien](https://metacpan.org/pod/Alien) **share** install introduce \na number of challenges, and honestly I don't see the point of using \nthem, if you can avoid it.  So far I haven't actually seen a situation \nwhere it couldn't be avoided.  Just to be clear: dynamic libraries are \nfine for Alien, and in fact desirable when you are using the system \nprovided libraries.  You get the patches and security fixes supplied by \nyour operating system.\n\nOkay, so why not build a dynamic library for a **share** install?\n\nFor this discussion, say you have an alienized library `Alien::libfoo` \nand an XS module that uses it called `Foo::XS` (as illustrated in the \nsynopsis above).\n\n- Your Alien becomes a run-time dependency.\n\n    When you link your `Foo::XS` module with a static library from \n    `Alien::libfoo` it gets added into the DLL or `.so` file that the Perl \n    toolchain produces.  That means when you later use it, it doesn't need \n    anything else.  When you try to do the same thing with a dynamic \n    library, you need that dynamic library, which is stored in a share \n    directory of `Alien::libfoo`.\n\n    For people who install out of CPAN this is probably not a big deal, but \n    for operating system vendors (the people who integrate Perl modules into \n    their operating system), it is a hassle because now you need this big \n    build tool [Alien::Build](https://metacpan.org/pod/Alien::Build) and the alien `Alien::libfoo` with extra \n    dependencies during runtime.  Normally you wouldn't need those packages \n    installed for end-user use.\n\n- Upgrades can and will break your XS module.\n\n    Again, when `Alien::libfoo` builds a static library and it gets linked \n    into a DLL or `.so` for `Foo::XS`, it doesn't need the original \n    library anymore.  If you are using a dynamic library and you do the same \n    thing it maybe works today, but say tomorrow you upgrade \n    `Alien::libfoo` and it replaces the DLL or `.so` file with an \n    incompatible API or ABI?  Now your `Foo::XS` module has stopped \n    working!\n\n- Dynamic libraries are not portable\n\n    Dynamic libraries are widely supported on most modern operating systems, \n    but each system provides a different interface.  For example, Linux, \n    Windows and OS X all have an environment variable that allows you to \n    alter the search path for finding dynamic libraries, but all three have \n    different extensions for dynamic libraries (OS X even has two!), the \n    environment variables are called something different, and WHEN you can \n    change them is different.\n\n    The Perl core has code for loading dynamic libraries as part of its XS \n    system on all platforms where you can build XS extensions dynamically. \n    Unfortunately that code isn't quite reusable for use by Alien.  Alien \n    developers have limited time and access to many platforms, which means \n    that many platforms will probably never get Alien support.\n\n    Static libraries on the other hand pretty much work the same on all \n    platforms.  Even on Windows which likes to be different, static \n    libraries are essentially the same as on Unix.\n\nSo all that said, why have I written this module, which provides support \nfor dynamic libraries?  Well, maybe I am wrong, maybe it isn't that \nhard.  Also, maybe you don't have a choice, maybe you have found a \nlibrary that can ONLY be built using a dynamic library.\n\nWhat about you?  Should you use this module?  It has the worked \n**Experimental** in the description.  The experimental aspect of this \nmodule should not worry you, because in the situation that your Alien \nfinds the library from the system, nothing is different from the core \n[Alien::Build](https://metacpan.org/pod/Alien::Build).  The only place it is different is if you have to do a \nshare install, and hopefully you are only using it because you really \ncan't build a static library.  Thus you haven't really lost anything in \nstability, and at worst your Alien may work in places where it wouldn't \notherwise.\n\nSo in summary, the experimental aspect shouldn't worry you, the caveats \nabove should!\n\n# HOW\n\nHow does it work?  Use the bundled [alienfile](https://metacpan.org/pod/alienfile) plugin \n[Alien::Build::Plugin::Gather::Dino](https://metacpan.org/pod/Alien::Build::Plugin::Gather::Dino).  That will find any dynamic \nlibrary paths in your share directory in case they are needed at \nruntime.  Then apply this role to you [Alien::Base](https://metacpan.org/pod/Alien::Base) subclass using\n[Role::Tiny::With](https://metacpan.org/pod/Role::Tiny::With).  Instead of using [XSLoader](https://metacpan.org/pod/XSLoader) or [DynaLoader](https://metacpan.org/pod/DynaLoader)\nto load your XS module, use the `xs_load` from your [Alien](https://metacpan.org/pod/Alien).\nHopefully the synopsis above makes it clear.\n\n# ETYMOLOGY\n\nThis module is named **Dino** being short for Dinosaur.  I really like \nDinosaurs (also friendly crocodiles and [platypuses](https://metacpan.org/pod/FFI::Platypus) in \ncase you hadn't noticed).  \"Dino\" also has a similar sound to \"Dyna\" \nwhich is frequently used as a short name or prefix meaning \"dynamic\".  I \ndidn't want to call it \"Dyna\" or \"Dynamic\" since it is only building a \ndynamic library for share installs.  I didn't want to call it DynaShare \nbecause that was getting a bit wordy.  So Dino.\n\n# METHODS\n\n## rpath\n\n```perl\nmy @dirs = $alien-\u003erpath;\n```\n\nReturns the list of directories that have non-system dynamic libraries\nin them.  On some systems this is needed at compile time, on others\nit is needed at run time.\n\n## xs\\_load\n\n```\n$alien-\u003exs_load($package, $version);\n$alien-\u003exs_load($package, $version, @other_dino_aliens);\n```\n\n# CAVEATS\n\nLots.  In summary:\n\n- Your Alien is a run-time dependency and you will annoy system integrators\n- Your XS can be broken by upgrades to your Alien\n- Your platform may not be supported\n\nAlso, this module should start with the caveat section and then go from \nthere.  Most modules I write are not like that.\n\nThese platforms seem to work: Linux, OS X, Windows, Cygwin, FreeBSD, \nNetBSD, OpenBSD, Debian kFreeBSD.\n\nCurrently has [Alien::Autotools](https://metacpan.org/pod/Alien::Autotools) as a prerequisite.  I hope to remove that prereq\nasap.\n\n# SEE ALSO\n\n- [alienfile](https://metacpan.org/pod/alienfile)\n- [Alien::Base](https://metacpan.org/pod/Alien::Base)\n- [Alien::Build](https://metacpan.org/pod/Alien::Build)\n- [Alien::Build::Plugin::Gather::Dino](https://metacpan.org/pod/Alien::Build::Plugin::Gather::Dino)\n\n# AUTHOR\n\nGraham Ollis \u003cplicease@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2017-2022 by Graham Ollis.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperlalien%2Falien-role-dino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperlalien%2Falien-role-dino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperlalien%2Falien-role-dino/lists"}