Skip Menu |

This queue is for tickets about the Glib-Object-Introspection CPAN distribution.

Report information
The Basics
Id: 106656
Status: resolved
Priority: 0/
Queue: Glib-Object-Introspection

People
Owner: Nobody in particular
Requestors: XAOC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Building of test libraries for G:O:I fails on OS X
tl;dr - Need to change the file extension of the G:O:I test libraries when compiling G:O:I on OS X This has been bothering me for a few years now, but I finally got the tuits to go after the problem. On OS X, the test libraries are being built as "libregress.bundle"/"libgimarshallingtests.bundle", using $Config{dlext} to set the file extension of the test library files. Unfortunately, a "bundle" on OS X (and NeXT, and possibly Solaris) is a different form of a library file from a "dynamically loaded shared library" (dylib) file, so the linker can't find the files when it goes to link them. The difference between .bundle and .dylib libraries on OS X is that .dylib libraries can be loaded with dlopen() (but won't be unloaded until the program exits), and .bundle files are loaded by first calling NSCreateObjectFileImageFromFile() (from <mach-o/dyld.h>), then loading library files from the bundle. Note that bundles can be unloaded while the program is running, unlike .dylib libraries. Bundle objects are similar to JAR files in Java, the libraries on OS X know enough to go inside a bundle file and pull out resources, such as icons/image files, as well as load any shared libraries inside the bundle into the program on request. If the test libraries are compiled as a dylib (gcc is passed the "-shared" argument), but the compiled library file is incorrectly given a .bundle extension (via the contents of $Config{dlext} in Makefile.PL) , then the linker won't find these test libraries when it comes time to link them, and all of the tests in the test suite that use it will be skipped (basically, the entire test suite). FWIW, you can change "-shared" to "-bundle" to create proper bundle files, but you still need to load the resulting bundle files via NSCreateObjectFileImageFromFile() in order to make use of them. On OS X, all Perl XS files by default are compiled as .bundles, and there's the correct magick in DynLoader to load the library from inside the .bundle file. You can see this in the Perl source, in the file ext/DynaLoader/dl_dyld.xs +111 Here's the output of the 'file' command on OS X for the test libraries in $src/build. Note that by default, the two *.bundle files below were created, one at a time (see below), and the *.dylib files are just the *.bundle files copied to the new name. $ file *.bundle *.dylib libgimarshallingtests.bundle: Mach-O 64-bit dynamically linked shared library x86_64 libregress.bundle: Mach-O 64-bit dynamically linked shared library x86_64 libgimarshallingtests.dylib: Mach-O 64-bit dynamically linked shared library x86_64 libregress.dylib: Mach-O 64-bit dynamically linked shared library x86_64 If the *.dylib files are present in the $src/build directory when 'perl Makefile.PL' is run, then the testing libraries will be built, and tests will pass on OS X. You can create the two shared libraries needed by running 'perl Makefile.PL` twice, building each testing library then renaming the library with a *.dylib extension after it has been built as a *.bundle file. The proposed change tells Makefile.PL and t/inc/setup.pl to use $Config{so} (dylib) when $^O =~ /Darwin/, so the testing dylib files get created with the correct filename extensions, and can then be found by the linker.
On Tue Aug 25 16:43:20 2015, XAOC wrote: Show quoted text
> The proposed change tells Makefile.PL and t/inc/setup.pl to use > $Config{so} (dylib) when $^O =~ /Darwin/, so the testing dylib files > get created with the correct filename extensions, and can then be > found by the linker.
Patch attached.
Subject: 0001-Makefile.PL-setup.pl-change-library-extensions-on-OS.patch
From 9f9241b138994831fa948816a4f282610fb8280f Mon Sep 17 00:00:00 2001 From: Brian Manning <bmanning@src.gnome.org> Date: Tue, 25 Aug 2015 13:36:05 -0700 Subject: [PATCH] Makefile.PL/setup.pl: change library extensions on OS X - On OS X, compile the G:O:I testing libraries with the extension given in $Config{so} instead of $Config{dlext}; see RT#106656 --- Makefile.PL | 10 ++++++++-- t/inc/setup.pl | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 43228bd..636b5a5 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -172,6 +172,12 @@ sub compile_test_libraries { print 'Trying to build test libraries... '; my $success = eval { + my $lib_ext; + if ( $^O =~ /darwin/ ) { + $lib_ext = $Config{so}; + } else { + $lib_ext = $Config{dlext}; + } my $gidatadir = ExtUtils::PkgConfig->variable ('gobject-introspection-1.0', 'gidatadir'); die 'Could not find gobject-introspection-1.0' unless defined $gidatadir; @@ -215,7 +221,7 @@ sub compile_test_libraries { $cairo_flags{cflags} $cairo_gobject_flags{cflags} $gio_flags{cflags} \\ $testsdir/regress.c \\ $cairo_flags{libs} $cairo_gobject_flags{libs} $gio_flags{libs} \\ - -o libregress.$Config{dlext} $pipe); + -o libregress.$lib_ext $pipe); push @commands, qq($gir_cmd \\ --include=cairo-1.0 --include=Gio-2.0 \\ @@ -233,7 +239,7 @@ sub compile_test_libraries { $gio_flags{cflags} \\ $testsdir/gimarshallingtests.c \\ $gio_flags{libs} \\ - -o libgimarshallingtests.$Config{dlext} $pipe); + -o libgimarshallingtests.$lib_ext $pipe); push @commands, qq($gir_cmd \\ --include=Gio-2.0 \\ diff --git a/t/inc/setup.pl b/t/inc/setup.pl index 3612776..754b489 100644 --- a/t/inc/setup.pl +++ b/t/inc/setup.pl @@ -2,8 +2,15 @@ use Config; use Glib::Object::Introspection; use Test::More; -unless (-e qq(build/libregress.$Config{dlext}) && - -e qq(build/libgimarshallingtests.$Config{dlext})) +my $lib_ext; +if ( $^O =~ /darwin/ ) { + $lib_ext = $Config{so}; +} else { + $lib_ext = $Config{dlext}; +} + +unless (-e qq(build/libregress.$lib_ext) && + -e qq(build/libgimarshallingtests.$lib_ext)) { plan skip_all => 'Need the test libraries'; } -- 2.4.5
Subject: Re: [rt.cpan.org #106656] Building of test libraries for G:O:I fails on OS X
Date: Tue, 1 Sep 2015 22:06:01 +0200
To: bug-Glib-Object-Introspection [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 25.08.2015 22:46, Brian Manning via RT wrote: Show quoted text
> Queue: Glib-Object-Introspection > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=106656 > > > On Tue Aug 25 16:43:20 2015, XAOC wrote:
>> The proposed change tells Makefile.PL and t/inc/setup.pl to use >> $Config{so} (dylib) when $^O =~ /Darwin/, so the testing dylib files >> get created with the correct filename extensions, and can then be >> found by the linker.
> > Patch attached.
Looks good to me. Please go ahead and commit. Thanks for the investigation and the report!
This was merged as 8bbd136dcf82857f0ff48bfa3268616fb791ecde in 2015. Marking ticket as "resolved"