Bug 6890

Summary: Perl fails when using non-standard installation directory
Product: [Runtime] General Runtime Reporter: Wolfgang Denk <wd>
Component: General RuntimeAssignee: Aníbal Limón <anibal.limon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: richard.purdie, sgw
Version: 1.7   
Target Milestone: 1.7.1   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Wolfgang Denk 2014-10-27 08:03:42 UTC
The perl binary contains built-in path names pointing to the standard
installation directory.  When installing into a different directory,
perl is broken, as it cannot find it's modules.

Example (using poky-glibc-x86_64-core-image-sato-ppc7400-toolchain-1.7.sh
rc5 build):

-> mkdir -p /work/wd/my/special/directory
-> sh /tmp/poky-glibc-x86_64-core-image-sato-ppc7400-toolchain-1.7.sh
Enter target directory for SDK (default: /opt/poky/1.7): /work/wd/my/special/directory
You are about to install the SDK to "/work/wd/my/special/directory". Proceed[Y/n]?y
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.
-> . /work/wd/my/special/directory/environment-setup-ppc7400-poky-linux 
-> which perl
/work/wd/my/special/directory/sysroots/x86_64-pokysdk-linux/usr/bin/perl
-> perl -e "print qq(@INC)"
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_COLLATE = "C",
        LANG = "en_US.utf8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
/work/wd/my/special/directory/sysroots/x86_64-pokysdk-linux//usr/lib/perl/5.20.0 /work/wd/my/special/directory/sysroots/x86_64-pokysdk-linux//usr/lib/perl /work/wd/my/special/directory/sysroots/x86_64-pokysdk-linux//usr/lib/perl/5.20.0 /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/site_perl/5.20.0/ /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/site_perl/5.20.0 /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/vendor_perl/5.20.0/ /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/vendor_perl/5.20.0 /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/5.20.0/ /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/5.20.0 /opt/poky/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/perl/5.20.0 .-> 

As you can see, even though we installed the tool chain into the
/work/wd/my/special/directory , the provided perl searches it's 
modules in the (non-existing) /opt/poky/1.7/... directory.

Should we not add a line like:

export PERL5LIB="${OECORE_NATIVE_SYSROOT}/usr/lib/perl/5.14.3 ${OECORE_NATIVE_SYSROOT}/usr/lib/perl ${OECORE_NATIVE_SYSROOT}/usr/lib/perl/5.14.3 ${OECORE_NATIVE_SYSROOT}/usr/lib/perl/site_perl/5.14.3 ${OECORE_NATIVE_SYSROOT}/usr/lib/perl/vendor_perl/5.14.3 ${OECORE_NATIVE_SYSROOT}/usr/lib/perl/5.14.3 ."

to the environment-setup-* script, similar to what get's done for
PYTHONHOME ?
Comment 1 Saul Wold 2014-10-30 15:17:16 UTC
The changes may be needed in the wrapper scripts to perl for the nativesdk case, not the environment setup.
Comment 2 Richard Purdie 2014-10-30 15:18:34 UTC
The perl recipe has calls to create_wrapper() which should set this up correctly. We need to figure out if thsoe are working correctly and if not, why not. There shouldn't be a need to set this in the core environment file since perl may or may not be present in the particular sdk setup.
Comment 3 Wolfgang Denk 2014-10-30 16:37:20 UTC
(In reply to comment #2)
> The perl recipe has calls to create_wrapper() which should set this up
> correctly. We need to figure out if thsoe are working correctly and if not,
> why not. There shouldn't be a need to set this in the core environment file
> since perl may or may not be present in the particular sdk setup.

I didn't realize that ${OECORE_NATIVE_SYSROOT}/usr/bin/perl is just a
wrapper script, sorry.

So yes, the setup of the PERL5LIB environment variable should be done
there.  As is, the script appends

	$OECORE_NATIVE_SYSROOT//usr/lib/perl
and
	OECORE_NATIVE_SYSROOT//usr/lib/perl/<version>

[Note: the double slashes should be cleaned up.]

Should the script not also append

	${OECORE_NATIVE_SYSROOT}/usr/lib/perl/site_perl/<version>
and
	${OECORE_NATIVE_SYSROOT}/usr/lib/perl/vendor_perl/<version>

?
Comment 4 Wolfgang Denk 2014-11-05 19:26:03 UTC
While we are at it:  is there a specific reason why
meta/recipes-devtools/perl/perl_5.14.3.bb
places "perl" before "perl/${PV}", while
meta/recipes-devtools/perl/perl-native_5.14.3.bb
places "perl/${PV}" before "perl"?

I cannot see why such an inconsistency should be needed.
Am I missing something?
Comment 5 Aníbal Limón 2014-11-05 20:53:37 UTC
(In reply to comment #4)
> While we are at it:  is there a specific reason why
> meta/recipes-devtools/perl/perl_5.14.3.bb
> places "perl" before "perl/${PV}", while
> meta/recipes-devtools/perl/perl-native_5.14.3.bb
> places "perl/${PV}" before "perl"?
> 
> I cannot see why such an inconsistency should be needed.
> Am I missing something?

In what part of the recipes you see it?

I already sent a patch that adds missing directories in do_install_append_class-nativesdk for perl recipe (not native one) it should be enough.
Comment 6 Wolfgang Denk 2014-11-06 09:53:23 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > While we are at it:  is there a specific reason why
> > meta/recipes-devtools/perl/perl_5.14.3.bb
> > places "perl" before "perl/${PV}", while
> > meta/recipes-devtools/perl/perl-native_5.14.3.bb
> > places "perl/${PV}" before "perl"?
> > 
> > I cannot see why such an inconsistency should be needed.
> > Am I missing something?
> 
> In what part of the recipes you see it?

In meta/recipes-devtools/perl/perl_5.14.3.bb :

216 do_install_append_class-nativesdk () {
217         create_wrapper ${D}${bindir}/perl \
218             PERL5LIB='$PERL5LIB:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl:$OECORE_NATIVE_SYSROOT/${libdir_nativesdk}/perl/${PV}'

i. e. we have first .../perl, followed by .../perl/${PV}

In meta/recipes-devtools/perl/perl-native_5.14.3.bb :

103
104         create_wrapper ${D}${bindir}/perl PERL5LIB='$PERL5LIB:${STAGING_LIBDIR}/perl/${PV}:${STAGING_LIBDIR}/perl/' 
105         create_wrapper ${D}${bindir}/perl${PV} PERL5LIB='$PERL5LIB:${STAGING_LIBDIR}/perl/${PV}:${STAGING_LIBDIR}/perl/'

i. e. we have first .../perl/${PV}, then .../perl/

Note - the trailing slash after the "perl/" should be removed, too.

> I already sent a patch that adds missing directories in
> do_install_append_class-nativesdk for perl recipe (not native one) it should
> be enough.

Do you have a link to that posting?  I can't find it.

Thanks.