Subject: | Test suite does not compile unless -fPIC is specified to the compiler |
In the course of adding GLib-GObject-Introspection 0.004 to Fedora
repositories, I found the test suite would not build.
If I hack Makefile.PL to remove the redirection to /dev/null, I can see
the test suite fails to compile due to missing -fPIC
$ perl Makefile.PL
Trying to build test libraries... /usr/bin/ld: /tmp/ccXbBACj.o:
relocation R_X86_64_32 against `.rodata' can not be used when making a
shared object; recompile with -fPIC
/tmp/ccXbBACj.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
not OK
Unrecognized argument in LIBS ignored: '-Wl,--export-dynamic'
Unrecognized argument in LIBS ignored: '-pthread'
Writing Makefile for Glib::Object::Introspection
I am attaching the patch we applied in Fedora to fix it
Subject: | Glib-Object-Introspection-0.004-fpic.patch |
diff -rup Glib-Object-Introspection-0.004.orig/Makefile.PL Glib-Object-Introspection-0.004.new/Makefile.PL
--- Glib-Object-Introspection-0.004.orig/Makefile.PL 2011-11-18 17:40:22.000000000 +0000
+++ Glib-Object-Introspection-0.004.new/Makefile.PL 2011-11-23 14:04:09.981141425 +0000
@@ -116,7 +116,7 @@ sub compile_test_libraries {
my %glib_flags = ExtUtils::PkgConfig->find ('glib-2.0');
# FIXME: Why is --no-as-needed necessary?
- !system (qq(gcc -shared -Wl,--no-as-needed -g \\
+ !system (qq(gcc -shared -fPIC -Wl,--no-as-needed -g \\
$cairo_flags{cflags} $cairo_flags{libs} \\
$gio_flags{cflags} $gio_flags{libs} \\
$testsdir/regress.c \\
@@ -132,7 +132,7 @@ sub compile_test_libraries {
1>/dev/null 2>/dev/null))
&& !system (qq(g-ir-compiler Regress-1.0.gir -o Regress-1.0.typelib \\
1>/dev/null 2>/dev/null))
- && !system (qq(gcc -shared -g \\
+ && !system (qq(gcc -shared -fPIC -g \\
$glib_flags{cflags} $glib_flags{libs} \\
$testsdir/gimarshallingtests.c \\
-o libgimarshallingtests.so 1>/dev/null 2>/dev/null))