In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/39d6ec9c0d20d3d03ac0955f489d90a12a2cc0cc?hp=88c342510b9c95c4cb80bbda6821c61591e48c37>
- Log ----------------------------------------------------------------- commit 39d6ec9c0d20d3d03ac0955f489d90a12a2cc0cc Author: Brian Fraser <frase...@gmail.com> Date: Tue Jan 14 00:19:08 2014 -0300 perldelta for -Dsysroot M pod/perldelta.pod commit 3ea734f88d1b94acf863a54bbbe478ed0a1d00ad Author: Brian Fraser <frase...@gmail.com> Date: Fri Jan 3 01:32:09 2014 -0300 Configure, sysroot: failing to guess usrinc needn't be fatal Previously, if we failed to guess usrinc, incpth, or libpth and were cross-compiling, Configure would've bailed out immediately. This commit makes it more lenient if using -Dsysroot; in case of failure it will now warn, but Configure will continue as usual; this is because the defaults for those variables will now use sysroot, so they have a higher chance of being accurate. M Configure commit 6488598c75e86a843b3bf444ccc3433d79098816 Author: Brian Fraser <frase...@gmail.com> Date: Thu Jan 2 00:17:17 2014 -0300 Configure, sysroot: Update defaults to use $sysroot M Configure commit 24e2d532182eb0c566d5c21c140f82b46e22a527 Author: Brian Fraser <frase...@gmail.com> Date: Mon Dec 30 02:33:05 2013 -0300 Configure, sysroot: add --sysroot to cppflags M Configure commit 98b12e44bdf730698c03a5a4d8fc93c41d931637 Author: Jess Robinson <casta...@desert-island.me.uk> Date: Fri Oct 19 19:05:25 2012 +0100 Introduce sysroot variable to Configure This is borrowed from gcc and allows us to indicate the logical root directory for headers and libraries, under which all -I and -L are searched for. This patch adjusts Configure to search under $sysroot (if supplied) for headers and libraries, instead of /. --sysroot is added to ccflags and friends so that make in ExtUtils::MakeMaker, and other extensions, will use it. Currently this is only done if compiling with some variant of gcc or g++. M Configure M ext/Errno/Errno_pm.PL commit c6fe3211fa33aa68aae52c93ae02166eb9df3057 Author: Brian Fraser <frase...@gmail.com> Date: Sat Jan 11 02:50:47 2014 -0300 Configure: use incpth, not usrinc, to search for headers. incpth is all the paths that will eventually be used by the compiler to search for headers; usrinc is the first of those paths to have all three of errno.h, stdio.h, and time.h inside. M Configure ----------------------------------------------------------------------- Summary of changes: Configure | 330 +++++++++++++++++++++++++++++++++----------------- ext/Errno/Errno_pm.PL | 6 +- pod/perldelta.pod | 10 ++ 3 files changed, 234 insertions(+), 112 deletions(-) diff --git a/Configure b/Configure index 5cc5f64..8350ba2 100755 --- a/Configure +++ b/Configure @@ -209,6 +209,7 @@ from='' run='' targetarch='' to='' +sysroot='' usecrosscompile='' extern_C='' mistrustnm='' @@ -1952,6 +1953,44 @@ true) ;; esac +: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc +: This is primarily meant for cross-compile environments, and may fail to be useful in other cases + +if test "X$sysroot" != X; then + case "$cc" in + *gcc*|*g++*) + echo "Using $sysroot to find your headers and libraries, adding to ccflags" + case "$ccflags" in + *sysroot*) ;; + 'undef'|*) + ccflags="$ccflags --sysroot=$sysroot" + esac + case "$ldflags" in + *sysroot*) ;; + 'undef'|*) + ldflags="$ldflags --sysroot=$sysroot" + esac + case "$cppflags" in + *sysroot*) ;; + 'undef'|*) + cppflags="$cppflags --sysroot=$sysroot" + esac + # lddlflags updated below in lddlflags section; + # same with cccdlflags + ;; + esac + + # Adjust some defaults to also use $sysroot + for var in xlibpth loclibpth locincpth glibpth; do + eval xxx=\$$var + eval $var='' + for path in $xxx; do + eval $var=\"\$$var $sysroot$path\" + done + done + +fi + : Eunice requires " " instead of "", can you believe it echo " " : Here we go... @@ -2389,7 +2428,7 @@ uname zip " pth=`echo $PATH | sed -e "s/$p_/ /g"` -pth="$pth /lib /usr/lib" +pth="$pth $sysroot/lib $sysroot/usr/lib" for file in $loclist; do eval xxx=\$$file case "$xxx" in @@ -2792,51 +2831,12 @@ $define|true|[yY]*) # leave out ld, choosing it is more complex nm=$targetarch-nm ranlib=$targetarch-ranlib - $echo 'extern int foo;' > try.c - set X `$cc -v -E try.c 2>&1 | $awk '/^#include </,/^End of search /'|$grep '/include'` - shift - if $test $# -gt 0; then - incpth="$incpth $*" - incpth="`$echo $incpth|$sed 's/^ //'`" - echo "Guessing incpth '$incpth'." >&4 - for i in $*; do - j="`$echo $i|$sed 's,/include$,/lib,'`" - if $test -d $j; then - libpth="$libpth $j" - fi - done - libpth="`$echo $libpth|$sed 's/^ //'`" - echo "Guessing libpth '$libpth'." >&4 - fi - $rm -f try.c ;; esac case "$targetarch" in '') echo "Targetarch not defined." >&4; croak=y ;; *) echo "Using targetarch $targetarch." >&4 ;; esac - case "$incpth" in - '') echo "Incpth not defined." >&4; croak=y ;; - *) echo "Using incpth '$incpth'." >&4 ;; - esac - case "$libpth" in - '') echo "Libpth not defined." >&4; croak=y ;; - *) echo "Using libpth '$libpth'." >&4 ;; - esac - case "$usrinc" in - '') for i in $incpth; do - if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then - usrinc=$i - echo "Guessing usrinc $usrinc." >&4 - break - fi - done - case "$usrinc" in - '') echo "Usrinc not defined." >&4; croak=y ;; - esac - ;; - *) echo "Using usrinc $usrinc." >&4 ;; - esac case "$targethost" in '') echo "Targethost not defined." >&4; croak=y ;; *) echo "Using targethost $targethost." >&4 @@ -4336,8 +4336,8 @@ echo exit 1 >xenix echo exit 1 >venix echo exit 1 >os2 d_bsd="$undef" -$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null -if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1 +$cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null +if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1 then echo "Looks kind of like an OSF/1 system, but we'll see..." echo exit 0 >osf1 @@ -4508,52 +4508,6 @@ case "$gccversion" in $rm -f try try.* esac -: What should the include directory be ? -echo " " -$echo $n "Hmm... $c" -dflt='/usr/include' -incpath='' -mips_type='' -if $test -f /bin/mips && /bin/mips; then - echo "Looks like a MIPS system..." - $cat >usr.c <<'EOCP' -#ifdef SYSTYPE_BSD43 -/bsd43 -#endif -EOCP - if cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then - dflt='/bsd43/usr/include' - incpath='/bsd43' - mips_type='BSD 4.3' - else - mips_type='System V' - fi - $rm -f usr.c usr.out - echo "and you're compiling with the $mips_type compiler and libraries." - xxx_prompt=y - echo "exit 0" >mips -else - echo "Doesn't look like a MIPS system." - xxx_prompt=n - echo "exit 1" >mips -fi -chmod +x mips -$eunicefix mips -case "$usrinc" in -'') ;; -*) dflt="$usrinc";; -esac -case "$xxx_prompt" in -y) fn=d/ - echo " " - rp='Where are the include files you want to use?' - . ./getfile - usrinc="$ans" - ;; -*) usrinc="$dflt" - ;; -esac - : see how we invoke the C preprocessor echo " " echo "Now, how can we feed standard input to your C preprocessor..." >&4 @@ -4569,7 +4523,7 @@ if test ! -f cppstdin; then # locations but we'll cheat by using the -M flag. echo 'cat >.$$.c; rm -f .$$.u; '"$cc"' ${1+"$@"} -M -c .$$.c 2>/dev/null; test -s .$$.u && awk '"'"'$2 ~ /\.h$/ { print "# 0 \""$2"\"" }'"'"' .$$.u; rm -f .$$.o .$$.u; '"$cc"' -E ${1+"$@"} .$$.c; r ... [19 chars truncated] else - echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin + echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin fi else echo "Keeping your $hint cppstdin wrapper." @@ -4612,37 +4566,37 @@ elif echo 'Maybe "'"$cc"' -E" will work...'; \ $cc -E <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "Yup, it does." - x_cpp="$cc -E" + x_cpp="$cc $cppflags -E" x_minus=''; elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \ $cc -E - <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "Yup, it does." - x_cpp="$cc -E" + x_cpp="$cc $cppflags -E" x_minus='-'; elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \ $cc -P <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "Yipee, that works!" - x_cpp="$cc -P" + x_cpp="$cc $cppflags -P" x_minus=''; elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \ $cc -P - <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "At long last!" - x_cpp="$cc -P" + x_cpp="$cc $cppflags -P" x_minus='-'; elif echo 'No such luck, maybe "'$cpp'" will work...'; \ $cpp <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "It works!" - x_cpp="$cpp" + x_cpp="$cpp $cppflags" x_minus=''; elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \ $cpp - <testcpp.c >testcpp.out 2>&1; \ $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then echo "Hooray, it works! I was beginning to wonder." - x_cpp="$cpp" + x_cpp="$cpp $cppflags" x_minus='-'; elif echo 'Uh-uh. Time to get fancy. Trying a wrapper...'; \ $wrapper <testcpp.c >testcpp.out 2>&1; \ @@ -4702,10 +4656,129 @@ case "$cppstdin" in esac $rm -f testcpp.c testcpp.out +case "$osname" in +vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is > +os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \ +*) cppfilter='' ;; +esac + +# If using gcc or clang, we can get better values for libpth, incpth +# and usrinc directly from the compiler. +# Note that ccname for clang is also gcc. +case "$ccname" in + gcc) + $echo 'extern int foo;' > try.c + set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'` + shift + if $test $# -gt 0; then + incpth="$incpth $*" + incpth="`$echo $incpth|$sed 's/^ //'`" + for i in $*; do + j="`$echo $i|$sed 's,/include$,/lib,'`" + if $test -d $j; then + libpth="$libpth $j" + fi + done + libpth="`$echo $libpth|$sed 's/^ //'`" + for xxx in $libpth $loclibpth $plibpth $glibpth; do + if $test -d $xxx; then + case " $libpth " in + *" $xxx "*) ;; + *) libpth="$libpth $xxx";; + esac + fi + done + fi + $rm -f try.c + case "$usrinc" in + '') for i in $incpth; do + if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then + usrinc="$i" + break + fi + done + ;; + esac + + case "$usecrosscompile" in + $define|true|[yY]*) + case "$incpth" in + '') echo "Incpth not defined." >&4; croak=y ;; + *) echo "Using incpth '$incpth'." >&4 ;; + esac + case "$libpth" in + '') echo "Libpth not defined." >&4; croak=y ;; + *) echo "Using libpth '$libpth'." >&4 ;; + esac + case "$usrinc" in + '') echo "Usrinc not defined." >&4; croak=y ;; + *) echo "Using usrinc $usrinc." >&4 ;; + esac + case "$croak" in + y) + if test "X$sysroot" = X; then + echo "Cannot continue, aborting." >&4; exit 1 + else + echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4 + fi + ;; + esac + ;; + esac + ;; +esac + +: What should the include directory be ? +: Use sysroot if set, so findhdr looks in the right place. +echo " " +$echo $n "Hmm... $c" +dflt="$sysroot/usr/include" +incpath='' +mips_type='' +if $test -f /bin/mips && /bin/mips; then + echo "Looks like a MIPS system..." + $cat >usr.c <<'EOCP' +#ifdef SYSTYPE_BSD43 +/bsd43 +#endif +EOCP + if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then + dflt='/bsd43/usr/include' + incpath='/bsd43' + mips_type='BSD 4.3' + else + mips_type='System V' + fi + $rm -f usr.c usr.out + echo "and you're compiling with the $mips_type compiler and libraries." + xxx_prompt=y + echo "exit 0" >mips +else + echo "Doesn't look like a MIPS system." + xxx_prompt=n + echo "exit 1" >mips +fi +chmod +x mips +$eunicefix mips +case "$usrinc" in +'') ;; +*) dflt="$usrinc";; +esac +case "$xxx_prompt" in +y) fn=d/ + echo " " + rp='Where are the include files you want to use?' + . ./getfile + usrinc="$ans" + ;; +*) usrinc="$dflt" + ;; +esac + : Set private lib path case "$plibpth" in '') if ./mips; then - plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib" + plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib" fi;; esac case "$libpth" in @@ -4715,7 +4788,6 @@ case "$libpth" in esac : Now check and see which directories actually exist, avoiding duplicates -libpth='' for xxx in $dlist do if $test -d $xxx; then @@ -4733,6 +4805,14 @@ know not to be holding relevant libraries, and add any that are needed. Say "none" for none. EOM + +if test "X$sysroot" != X; then + $cat <<EOM +You have set sysroot to $sysroot, please supply the directories excluding sysroot + +EOM +fi + case "$libpth" in '') dflt='none';; *) @@ -5435,17 +5515,12 @@ case $fieldn in esac echo "Your cpp writes the filename in the $pos field of the line." -case "$osname" in -vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is > -os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \ -*) cppfilter='' ;; -esac : locate header file $cat >findhdr <<EOF $startsh wanted=\$1 name='' -for usrincdir in $usrinc +for usrincdir in $incpth do if test -f \$usrincdir/\$wanted; then echo "\$usrincdir/\$wanted" @@ -7486,8 +7561,8 @@ unknown) $sort | $sed -e 's/^.* //'` eval set \$$# done - $test -r $1 || set /usr/ccs/lib/libc.$so - $test -r $1 || set /lib/libsys_s$_a + $test -r $1 || set $sysroot/usr/ccs/lib/libc.$so + $test -r $1 || set $sysroot/lib/libsys_s$_a ;; *) set blurfl @@ -7906,6 +7981,29 @@ EOM ' ') dflt='none' ;; *) dflt="$cccdlflags" ;; esac + + case "$dflt" in + none) dflt='' ;; + esac + + # If -Dsysroot was specified, now's the time to add it + # to cccdlflags + if test "X$sysroot" != X; then + case "$gccversion" in + '') ;; + *) case "$dflt" in + *sysroot*) ;; + 'undef'|*) + dflt="$dflt --sysroot=$sysroot" ;; + esac + ;; + esac + fi + + case "$dflt" in + '') dflt='none';; + esac + rp="Any special flags to pass to $cc -c to compile shared library modules?" . ./myread case "$ans" in @@ -8009,6 +8107,17 @@ EOM *) dflt="$lddlflags" ;; esac + : Only do this for gcc, since, for example, qcc has no concept + : of --sysroot. + if $test "X$sysroot" != X; then + case "$gccversion" in + '') ;; + *) + dflt="$dflt --sysroot $sysroot" + ;; + esac + fi + : Try to guess additional flags to pick up local libraries. : Be careful not to append to a plain 'none' case "$dflt" in @@ -11283,16 +11392,16 @@ else else for net in net socket do - if test -f /usr/lib/lib$net$_a; then - ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) || \ - $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list + if test -f $sysroot/usr/lib/lib$net$_a; then + ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) || \ + $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list if $contains socket libc.list >/dev/null 2>&1; then d_socket="$define" socketlib="-l$net" case "$net" in net) echo "...but the Wollongong group seems to have hacked it in." >&4 - sockethdr="-I/usr/netinclude" + sockethdr="-I$sysroot/usr/netinclude" ;; esac echo "Found Berkeley sockets interface in lib$net." >&4 @@ -20700,7 +20809,7 @@ esac : Trace out the files included by signal.h, then look for SIGxxx names. if [ "X$fieldn" = X ]; then : Just make some guesses. We check them later. - xxx='/usr/include/signal.h /usr/include/sys/signal.h' + xxx="$sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h" else xxx=`echo '#include <signal.h>' | $cppstdin $cppminus $cppflags 2>/dev/null | @@ -23609,6 +23718,7 @@ strings='$strings' submit='$submit' subversion='$subversion' sysman='$sysman' +sysroot='$sysroot' tail='$tail' tar='$tar' targetarch='$targetarch' diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 5d6bee5..db8ada7 100644 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -2,7 +2,7 @@ use ExtUtils::MakeMaker; use Config; use strict; -our $VERSION = "1.20_01"; +our $VERSION = "1.20_02"; my %err = (); @@ -131,10 +131,12 @@ sub get_files { $Config{gccversion} !~ /intel/i # might be using, say, Intel's icc ) { + # When cross-compiling we may store a path for gcc's "sysroot" option: + my $sysroot = $Config{sysroot} || ''; # Some Linuxes have weird errno.hs which generate # no #file or #line directives my ($linux_errno_h) = grep { -e $_ } map { "$_/errno.h" } - "/usr/include", "/usr/local/include", + "$sysroot/usr/include", "$sysroot/usr/local/include", split / / => $Config{locincpth} or die "Cannot find errno.h"; $file{$linux_errno_h} = 1; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index db0692c..aff4c74 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -295,6 +295,16 @@ named something "unique" -- for example, Hash/Util/Util.so becomes Hash/Util/PL_Hash__Util.so. This behavior is similar to what currently happens on VMS, and serves as groundwork for the Android port. +=item * + +C<sysroot> option to indicate the logical root directory under gcc and clang. + +When building with this option set, both Configure and the compilers search +for all headers and libraries under this new sysroot, instead of /. + +This is a huge time saver if cross-compiling, but can also help +on native builds if your toolchain's files have non-standard locations. + =back =head1 Testing -- Perl5 Master Repository