Subject: | Improved -I flag ordering |
Date: | Sat, 2 Feb 2008 11:40:58 -0500 |
To: | bug-Glib [...] rt.cpan.org |
From: | Daniel Macks <dmacks [...] netspace.org> |
I got some weird compile failures while compiling Glib-1.164 on my OS
X 10.4 (perl-5.8.6) machine:
cc -c -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -I. -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -Os -DVERSION=\"1.164\" -DXS_VERSION=\"1.164\" -o Glib.o "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE" Glib.c
crashed with bad types and symbol declarations. The local issue was
that I had some .h on my system that had the same names as those in
the Glib distro but were not related to it (my fault, not Glib's). The
"real" problem however is that the -I. flag came too late in the
compiler call: local (source-distro) paths should always come before
global (installed stuff) ones in order to assure that source-distro
files are always found even if there are same-named global ones. The
bug is in Makefile.PL, specifically:
$glib->set_inc ($glibcfg{cflags} . $gthreadcfg{cflags} . ' -I. ');
which appends "-I." to the flag list. Should prepend it instead:
$glib->set_inc (' -I. ' . $glibcfg{cflags} . $gthreadcfg{cflags});
And now I get:
cc -c -I. -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include -Os -DVERSION=\"1.164\" -DXS_VERSION=\"1.164\" -o Glib.o "-I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE" Glib.c
and a successful package build.
dan
--
Daniel Macks
dmacks@netspace.org
http://www.netspace.org/~dmacks