Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 134650 - dev-lang/perl: cross-compile support
Summary: dev-lang/perl: cross-compile support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal with 1 vote (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
: 383241 559574 (view as bug list)
Depends on:
Blocks: 133882
  Show dependency tree
 
Reported: 2006-05-28 08:21 UTC by solar (RETIRED)
Modified: 2016-10-22 21:05 UTC (History)
18 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
sys-devel/libperl/libperl-5.8.8-r3.ebuild (libperl-5.8.8-r3.ebuild,13.62 KB, text/plain)
2010-02-03 02:26 UTC, Peter Levine
Details
dev-lang/perl/perl-5.8.8-r9.ebuild (perl-5.8.8-r9.ebuild,23.14 KB, text/plain)
2010-02-03 02:28 UTC, Peter Levine
Details
/files/native-perlinc.patch (for libperl and perl) (native-perlinc.patch,982 bytes, patch)
2010-02-03 02:31 UTC, Peter Levine
Details | Diff
/files/perl-dynloader.patch (for perl and libperl) (perl-dynloader.patch,1019 bytes, patch)
2010-02-03 02:32 UTC, Peter Levine
Details | Diff
/files/perl-configpm-switch.patch for (perl and libperl) (perl-configpm-switch.patch,1.19 KB, patch)
2010-02-03 02:34 UTC, Peter Levine
Details | Diff
/files/Makefile.SH.patch (for perl and libperl) (Makefile.SH.patch,8.29 KB, patch)
2010-02-03 02:35 UTC, Peter Levine
Details | Diff
/files/perl-moreconfig.patch (for perl and libperl) (perl-moreconfig.patch,568 bytes, patch)
2010-02-03 02:36 UTC, Peter Levine
Details | Diff
/files/letgcc-find-errno.patch (for perl and libperl) (letgcc-find-errno.patch,1.40 KB, patch)
2010-02-03 02:37 UTC, Peter Levine
Details | Diff
/files/config-bits (for perl and libperl) (config-bits,29.21 KB, patch)
2010-02-03 02:38 UTC, Peter Levine
Details | Diff
/files/config-bits (for perl and libperl) (config-bits,29.21 KB, text/plain)
2010-02-03 02:39 UTC, Peter Levine
Details
Diff for libperl-5.8.8-r2 to libperl-5.8.8-r3 (libperl-5.8.8-r2-to-r3.patch,2.98 KB, patch)
2010-02-03 02:42 UTC, Peter Levine
Details | Diff
Diff for perl-5.8.8-r8 to perl-5.8.8-r9 (perl-5.8.8-r8-to-r9.patch,6.02 KB, patch)
2010-02-03 02:43 UTC, Peter Levine
Details | Diff
Patch for perl-module.eclass to cross-compile perl modules with latest perl and libperl (perl-module.eclass.patch,1010 bytes, patch)
2010-02-03 02:55 UTC, Peter Levine
Details | Diff
new /files/config-bits (for perl and libperl) (config-bits,29.33 KB, patch)
2010-02-08 22:36 UTC, Peter Levine
Details | Diff
Diff between old and new config-bits (config-bits.patch,519 bytes, patch)
2010-02-08 22:40 UTC, Peter Levine
Details | Diff
dev-lang/perl/perl-5.8.8-r10.ebuild (perl-5.8.8-r10.ebuild,23.15 KB, text/plain)
2010-02-08 22:47 UTC, Peter Levine
Details
Diff for perl-5.8.8-r9 to perl-5.8.8-r10 (perl-5.8.8-r9_r10.patch,376 bytes, patch)
2010-02-08 22:48 UTC, Peter Levine
Details | Diff
New patch for perl-module.eclass (perl-module.eclass.patch,1.07 KB, patch)
2010-04-28 13:33 UTC, Peter Levine
Details | Diff
perl-5.16.3 cross-compile support (perl-5.16.3-cross.patch,2.32 KB, patch)
2013-05-06 02:48 UTC, SpanKY
Details | Diff
build.log (build.log,196.55 KB, text/x-log)
2013-06-22 19:32 UTC, Markos Chandras (RETIRED)
Details
Working perl-5.18.2-r1 cross patch (perl-cross.patch,2.86 KB, patch)
2014-08-21 20:44 UTC, James Le Cuirot
Details | Diff
Working perl-5.24.0-r1 cross patch (perl-cross.patch,4.90 KB, patch)
2016-09-25 22:01 UTC, James Le Cuirot
Details | Diff
Working perl-5.24.0-r1 cross patch (perl-cross.patch,5.10 KB, patch)
2016-10-20 14:38 UTC, James Le Cuirot
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description solar (RETIRED) gentoo-dev 2006-05-28 08:21:54 UTC
This bug should be used to document our struggles with cross compiling 
perl/libperl and a place to present options and attach patches. When we 
feel it is ready our perl team should review and commit it to the tree 
or give us permission to do so with the solution that we come up with.
Comment 1 Peter Levine 2010-02-03 02:24:32 UTC
After quite some time and frustration, I have finally been able to cross-compile perl on amd64 for armv4l.  These ebuilds should work for most embedded platforms and possibly more.  Please help test it.
Comment 2 Peter Levine 2010-02-03 02:26:24 UTC
Created attachment 218243 [details]
sys-devel/libperl/libperl-5.8.8-r3.ebuild
Comment 3 Peter Levine 2010-02-03 02:28:10 UTC
Created attachment 218245 [details]
dev-lang/perl/perl-5.8.8-r9.ebuild
Comment 4 Peter Levine 2010-02-03 02:31:13 UTC
Created attachment 218247 [details, diff]
/files/native-perlinc.patch (for libperl and perl)
Comment 5 Peter Levine 2010-02-03 02:32:41 UTC
Created attachment 218249 [details, diff]
/files/perl-dynloader.patch (for perl and libperl)
Comment 6 Peter Levine 2010-02-03 02:34:14 UTC
Created attachment 218251 [details, diff]
/files/perl-configpm-switch.patch for (perl and libperl)
Comment 7 Peter Levine 2010-02-03 02:35:22 UTC
Created attachment 218253 [details, diff]
/files/Makefile.SH.patch (for perl and libperl)
Comment 8 Peter Levine 2010-02-03 02:36:49 UTC
Created attachment 218255 [details, diff]
/files/perl-moreconfig.patch (for perl and libperl)
Comment 9 Peter Levine 2010-02-03 02:37:41 UTC
Created attachment 218257 [details, diff]
/files/letgcc-find-errno.patch (for perl and libperl)
Comment 10 Peter Levine 2010-02-03 02:38:48 UTC
Created attachment 218259 [details, diff]
/files/config-bits (for perl and libperl)
Comment 11 Peter Levine 2010-02-03 02:39:35 UTC
Created attachment 218261 [details]
/files/config-bits (for perl and libperl)
Comment 12 Peter Levine 2010-02-03 02:42:03 UTC
Created attachment 218263 [details, diff]
Diff for libperl-5.8.8-r2 to libperl-5.8.8-r3
Comment 13 Peter Levine 2010-02-03 02:43:39 UTC
Created attachment 218265 [details, diff]
Diff for perl-5.8.8-r8 to perl-5.8.8-r9
Comment 14 Peter Levine 2010-02-03 02:55:35 UTC
Created attachment 218267 [details, diff]
Patch for perl-module.eclass to cross-compile perl modules with latest perl and libperl
Comment 15 Maksim 'max_posedon' Melnikau 2010-02-08 08:37:26 UTC
thanks, perl now cross-compiles for me, which is great itself but during cross compilation I saw:


Looking for nanosleep()... testing... ./tmp20523: ./tmp20523: cannot execute binary file

*** The test run of './tmp20523' failed: status 32256
*** (the status means: errno = 126 or 'Required key not available')
*** DO NOT PANIC: this just means that *some* functionality will be missing.
NOT found.                                                                  
You cannot mix subsecond sleeps with signals.                               
(It would not be portable anyway.)                                          
Looking for clock_gettime()... ./tmp20523: ./tmp20523: cannot execute binary file

*** The test run of './tmp20523' failed: status 32256
*** (the status means: errno = 126 or 'Required key not available')
*** DO NOT PANIC: this just means that *some* functionality will be missing.
NOT found.                                                                  
Looking for clock_getres()... ./tmp20523: ./tmp20523: cannot execute binary file

*** The test run of './tmp20523' failed: status 32256
*** (the status means: errno = 126 or 'Required key not available')
*** DO NOT PANIC: this just means that *some* functionality will be missing.
NOT found.                                                                  
Looking for clock_nanosleep()... NOT found.                                 
Looking for clock()... ./tmp20523: ./tmp20523: cannot execute binary file   

*** The test run of './tmp20523' failed: status 32256
*** (the status means: errno = 126 or 'Required key not available')
*** DO NOT PANIC: this just means that *some* functionality will be missing.
Comment 16 Maksim 'max_posedon' Melnikau 2010-02-08 08:48:32 UTC
also, patches and ebuilds added to openmoko overlay
Comment 17 Peter Levine 2010-02-08 22:29:52 UTC
(In reply to comment #15)
> thanks, perl now cross-compiles for me, which is great itself but during cross
> compilation I saw:
> 
> 
> Looking for nanosleep()... testing... ./tmp20523: ./tmp20523: cannot execute
> binary file
> 
> *** The test run of './tmp20523' failed: status 32256
> *** (the status means: errno = 126 or 'Required key not available')
> *** DO NOT PANIC: this just means that *some* functionality will be missing.
> NOT found.                                                                  
> You cannot mix subsecond sleeps with signals.                               
> (It would not be portable anyway.)                                          
> Looking for clock_gettime()... ./tmp20523: ./tmp20523: cannot execute binary
> file
> 
> *** The test run of './tmp20523' failed: status 32256
> *** (the status means: errno = 126 or 'Required key not available')
> *** DO NOT PANIC: this just means that *some* functionality will be missing.
> NOT found.                                                                  
> Looking for clock_getres()... ./tmp20523: ./tmp20523: cannot execute binary
> file
> 
> *** The test run of './tmp20523' failed: status 32256
> *** (the status means: errno = 126 or 'Required key not available')
> *** DO NOT PANIC: this just means that *some* functionality will be missing.
> NOT found.                                                                  
> Looking for clock_nanosleep()... NOT found.                                 
> Looking for clock()... ./tmp20523: ./tmp20523: cannot execute binary file   
> 
> *** The test run of './tmp20523' failed: status 32256
> *** (the status means: errno = 126 or 'Required key not available')
> *** DO NOT PANIC: this just means that *some* functionality will be missing.
> 

Apparently, the configure script doesn't declare the associated vars by default and passes the job to ext/Time/HiRes/Makefile.PL which (if not pre-defined in config.sh) goes through a series of  "compile and run" tests.  However, clock, clock_getres, clock_gettime, clock_nanosleep, and nanosleep are all POSIX.1-2001 compliant functions defined in <time.h> in glibc and, to my knowledge, uclibc.  It should be safe to declare these in config.sh.  Already tested on armv4tl-softfloat-linux-gnueabi.  Will upload patch.
Comment 18 Peter Levine 2010-02-08 22:36:33 UTC
Created attachment 218941 [details, diff]
new /files/config-bits (for perl and libperl)

Defines clock, clock_getres, clock_gettime, clock_nanosleep, and nanosleep to avoid unnecessary and faulty checks.
Comment 19 Peter Levine 2010-02-08 22:40:45 UTC
Created attachment 218947 [details, diff]
Diff between old and new config-bits
Comment 20 Peter Levine 2010-02-08 22:47:32 UTC
Created attachment 218949 [details]
dev-lang/perl/perl-5.8.8-r10.ebuild

Restricts the test phase if cross-compiling. Can't use the native perl to test cross-compiled libs.
Comment 21 Peter Levine 2010-02-08 22:48:53 UTC
Created attachment 218953 [details, diff]
Diff for perl-5.8.8-r9 to perl-5.8.8-r10
Comment 22 Maksim 'max_posedon' Melnikau 2010-02-09 01:34:42 UTC
(In reply to comment #18)
> Created an attachment (id=218941) [details]
> new /files/config-bits (for perl and libperl)
> 
> Defines clock, clock_getres, clock_gettime, clock_nanosleep, and nanosleep to
> avoid unnecessary and faulty checks. 
> 
Thanks for update.

I confirm that this perl and libperl ebuilds cross compiles (for armv4tl) and compiles natively (x86) for me. 

May be somebody from gentoo team should respond his opinion.
Comment 23 solar (RETIRED) gentoo-dev 2010-02-09 02:07:45 UTC
(In reply to comment #22)
..
> May be somebody from gentoo team should respond his opinion.

I think it's great that we are starting to see activity on this bug.

Note that perl patches have existed in the past that could cross build perl. 
But just like in this case it's a metric sh*t ton of patches. More then our very small perl team was able to handle from release to release back then.
My concern there is that we might have to fork via a virtual our own perl @ gentoo if these or a refined set of patches are not accepted for longer term inclusion. Upstream would rule. But that is another uphill battle.

So my opinion is that we get more testing Q/A feedback reported on this bug. Things like giving USE=perl a go while cross-compiling. Getting the prefix guys to give it a try etc..

When we are all happy let's add perl@ to the CC: for review.
Comment 24 gent_bz 2010-02-18 05:20:34 UTC
These ebuilds worked for me.
CHOST=powerpc-unknown-linux-gnu
CBUILD=x86_64-pc-linux-gnu
Comment 25 Peter Levine 2010-04-28 13:33:12 UTC
Created attachment 229501 [details, diff]
New patch for perl-module.eclass

There was a problem with the perl-module.eclass when cross-compiling.  My mips cross platform didn't use perl threading but the main gentoo perl did.  When an ebuild inherited both autotools and perl-module, and called on eutoreconf, aclocal wouldn't work and would fail on a line pertaining to a check for perl threading.  This is because the native autotools perl scripts were using the cross-compiled perl modules.  The solution would be to set PERL_LIB, PERL_ARCHLIB, and PERL_INC from within an eclass function (in the latest perl-module.eclass,  perl_set_version) instead of globally.  This way, the native autotools would use native perl modules.  If there is a need to set cross-perl functionality earlier than src_configure, simply call on perl_set_version or perlinfo. This patch is for perl-module.eclass,v 1.124.
Comment 26 Leho Kraav (:macmaN @lkraav) 2010-11-19 14:56:17 UTC
well this patchbomb seems to have helped me xcompile for i686-gentoo-linux-uclibc, thank you very much sir.
Comment 27 Dmitry Baranov 2011-04-24 20:10:34 UTC
mv -f miniperl miniperl-target
ln -s /usr/bin/perl5.8.8 miniperl
./miniperl -Ilib configpm --heavy=lib/Config_heavy.pl lib/Config.pm
make: ./miniperl: Command not found
make: *** [lib/Config.pod] Error 127
emake failed

Failed to build for mipsel-unknown-linux-uclibc.
Comment 28 Dennis Schridde 2012-08-20 13:29:25 UTC
Is there a solution to this? I get the following when I try to build perl-5.12.4-r1:
/bin/sh: ./try: cannot execute binary file
Comment 29 Markos Chandras (RETIRED) gentoo-dev 2013-04-21 11:37:17 UTC
(In reply to comment #28)
> Is there a solution to this? I get the following when I try to build
> perl-5.12.4-r1:
> /bin/sh: ./try: cannot execute binary file

I've just hit this problem but please attach a full build.log
Comment 30 Markos Chandras (RETIRED) gentoo-dev 2013-04-21 16:47:06 UTC
It might be possible to use the Cross/ directory instructions to cross-compile or maybe this one http://perlcross.berlios.de/ that buildroot project uses as well.
Comment 31 Rafal Lalik 2013-04-29 22:16:43 UTC
Maybe not full log, but I attached the most interesting part. Problem is easy, probably upstream should change their way of checking proper compiler flags.

Other way to fix it is to check whether cross toolchain is used and then set 'n' as default when it is asking whether to abort configure or not (for now default is 'y'). The lines for this look like that in Configure (lines 5315-5317):

echo "The program compiled OK, but exited with status $?." >>try.msg
rp="You have a problem.  Shall I abort Configure"
dflt=y


With sed one can change to dflt=n


The output log is below.

Rafal


--- LOG STARTS HERE ---
Checking your choice of C compiler and flags for coherency...
I've tried to compile and run the following simple program:

#include <stdio.h>
int main() { printf("Ok\n"); return(0); }

I used the command:

        armv6zk-hardfloat-linux-gnueabi-gcc -o try -O2 -pipe -march=armv6zk -mfpu=vfp -mfloat-abi=hard -DOVR_DBL_DIG=14 -Wl,-O1 -Wl,--as-needed try.c -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
         ./try

and I got the following output:

/bin/sh: ./try: cannot execute binary file
The program compiled OK, but exited with status 126.
You have a problem.  Shall I abort Configure [y]  
Ok.  Stopping Configure.
 * ERROR: dev-lang/perl-5.16.3 failed (configure phase):
 *   Unable to configure
 * 
 * Call stack:
 *                       ebuild.sh, line   93:  Called src_configure
 *                     environment, line 2752:  Called eblit-run 'src_configure' 'v50160001'
 *                     environment, line  813:  Called eblit-perl-src_configure
 *   src_configure-v50160001.eblit, line  144:  Called die
 * The specific snippet of code:
 *      sh Configure \
 *              -des \
 *              -Duseshrplib \
 *              -Darchname="${myarch}" \
 *              -Dcc="$(tc-getCC)" \
 *              -Doptimize="${CFLAGS}" \
 *              -Dldflags="${LDFLAGS}" \
 *              -Dprefix="${EPREFIX}"'/usr' \
 *              -Dinstallprefix="${EPREFIX}"'/usr' \
 *              -Dsiteprefix="${EPREFIX}"'/usr/local' \
 *              -Dvendorprefix="${EPREFIX}"'/usr' \
 *              -Dscriptdir="${EPREFIX}"'/usr/bin' \
 *              -Dprivlib="${EPREFIX}${PRIV_LIB}" \
 *              -Darchlib="${EPREFIX}${ARCH_LIB}" \
 *              -Dsitelib="${EPREFIX}${SITE_LIB}" \
 *              -Dsitearch="${EPREFIX}${SITE_ARCH}" \
 *              -Dvendorlib="${EPREFIX}${VENDOR_LIB}" \
 *              -Dvendorarch="${EPREFIX}${VENDOR_ARCH}" \
 *              -Dman1dir="${EPREFIX}"/usr/share/man/man1 \
 *              -Dman3dir="${EPREFIX}"/usr/share/man/man3 \
 *              -Dsiteman1dir="${EPREFIX}"/usr/local/man/man1 \
 *              -Dsiteman3dir="${EPREFIX}"/usr/local/man/man3 \
 *              -Dvendorman1dir="${EPREFIX}"/usr/share/man/man1 \
 *              -Dvendorman3dir="${EPREFIX}"/usr/share/man/man3 \
 *              -Dman1ext='1' \
 *              -Dman3ext='3pm' \
 *              -Dlibperl="${LIBPERL}" \
 *              -Dlocincpth="${EPREFIX}"'/usr/include ' \
 *              -Dglibpth="${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir)"' ' \
 *              -Duselargefiles \
 *              -Dd_semctl_semun \
 *              -Dcf_by='Gentoo' \
 *              -Dmyhostname='localhost' \
 *              -Dperladmin='root@localhost' \
 *              -Dinstallusrbinperl='n' \
 *              -Ud_csh \
 *              -Uusenm \
 *              "${myconf[@]}" || die "Unable to configure"
 * 
 * If you need support, post the output of `emerge --info '=dev-lang/perl-5.16.3'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/perl-5.16.3'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/perl-5.16.3/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/perl-5.16.3/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/perl-5.16.3/work/perl-5.16.3'
 * S: '/var/tmp/portage/dev-lang/perl-5.16.3/work/perl-5.16.3'
Comment 32 SpanKY gentoo-dev 2013-05-02 03:53:04 UTC
(In reply to comment #30)

i half started my own port to make perl cross-compile, but i gave up long ago as i never was that interested -- it's not critical to bootstrapping a new port.  things like openssl are which is why i made that pos work.

(In reply to comment #31)

your naïveness is so adorable
Comment 33 SpanKY gentoo-dev 2013-05-06 02:48:40 UTC
Created attachment 347478 [details, diff]
perl-5.16.3 cross-compile support

this uses the code from http://perlcross.berlios.de/download.html.  it's a little flaky (seems like it has parallel build issues).  and you have to run `make` twice due to some issue with libperl.so symlink.

needs more investigation.
Comment 34 Markos Chandras (RETIRED) gentoo-dev 2013-05-24 12:38:03 UTC
(In reply to comment #33)
> Created attachment 347478 [details, diff] [details, diff]
> perl-5.16.3 cross-compile support
> 
> this uses the code from http://perlcross.berlios.de/download.html.  it's a
> little flaky (seems like it has parallel build issues).  and you have to run
> `make` twice due to some issue with libperl.so symlink.
> 
> needs more investigation.

thanks. I started working on perlcross as well but I haven't gone that far. I will try a cross-build on mips64.
Comment 35 Markos Chandras (RETIRED) gentoo-dev 2013-06-22 19:32:50 UTC
Created attachment 351666 [details]
build.log

Unfortunately it does not build to me as it is. I need to investigate further.
Comment 36 Anthony Basile gentoo-dev 2013-06-22 19:56:48 UTC
(In reply to Markos Chandras from comment #35)
> Created attachment 351666 [details]
> build.log
> 
> Unfortunately it does not build to me as it is. I need to investigate
> further.

do you have gdbm installed in sys-root?
Comment 37 Jeroen Roovers (RETIRED) gentoo-dev 2014-04-24 00:38:49 UTC
*** Bug 383241 has been marked as a duplicate of this bug. ***
Comment 38 Mikle Kolyada archtester Gentoo Infrastructure gentoo-dev Security 2014-05-20 16:42:56 UTC
*** Bug 506818 has been marked as a duplicate of this bug. ***
Comment 39 James Le Cuirot gentoo-dev 2014-05-20 17:09:40 UTC
For the record, I did get this working with a few changes and a little help from my cross-boss project. More info soon.
Comment 40 salamanderrake 2014-08-21 16:32:58 UTC
Anything new regarding this bug?
Comment 41 James Le Cuirot gentoo-dev 2014-08-21 17:02:47 UTC
(In reply to salamanderrake from comment #40)
> Anything new regarding this bug?

As it happens, I used cross-boss to build perl-5.18.2-r1 just today. The necessary changes can be seen at the following URL but the evil crap that cross-boss does to not tie these fixes to a specific version may confuse you.

https://github.com/chewi/cross-boss/blob/master/overlay/dev-lang/perl/ebuild.sh

Basically, it calls ./configure with all the same options as Configure except for -des, plus these extra ones.

--target=${CHOST}
-Dinstallprefix=''
-Dinstallusrbinperl='undef'
-Dusevendorprefix='define'

It needs a little help finding gdbm so this was added to src_prepare.

if use gdbm; then
  sed -i 's:INC => .*:INC => \"-I${EROOT}usr/include/gdbm\":g' ext/NDBM_File/Makefile.PL || die
fi

Finally, src_compile looks like this.

export BZIP2_INCLUDE=${EROOT}usr/include
export BZIP2_LIB=${EROOT}usr/$(get_libdir)
export ZLIB_INCLUDE=${EROOT}usr/include
export ZLIB_LIB=${EROOT}usr/$(get_libdir)
emake -j1

That might be all you need but I'm not sure how much of the extra magic provided by cross-boss is also helping to make it work. It might be none. I'm currently becoming a dev with a long term goal of requiring fewer hacks in cross-boss.
Comment 42 James Le Cuirot gentoo-dev 2014-08-21 17:07:27 UTC
Actually these two configure options were already in the old ebuild but I had to pass different values.

-Dinstallprefix=''
-Dinstallusrbinperl='undef'
Comment 43 Joakim Tjernlund 2014-08-21 18:26:49 UTC
(In reply to James Le Cuirot from comment #41)
> (In reply to salamanderrake from comment #40)
> > Anything new regarding this bug?
> 
> As it happens, I used cross-boss to build perl-5.18.2-r1 just today. The
> necessary changes can be seen at the following URL but the evil crap that
> cross-boss does to not tie these fixes to a specific version may confuse you.
> 
> https://github.com/chewi/cross-boss/blob/master/overlay/dev-lang/perl/ebuild.
> sh

Just looked at cross-boss, very impressive! Need to spend some more time with it though.

I noticed you too have found proot, very handy tool! I use it to solve the
--sysroot problem(passing --sysroot in CFLAGS etc.):
 proot -b ${ROOT}:/usr/${CHOST}/ emerge --root-deps=rdeps ....
That way all accesses to /usr/${CHOST}/ is remapped to ${ROOT} so
there is no need to pass --sysroot

Similarly you can use proot to map /etc to ${ROOT}/etc in enewgroup and friends:
proot -0 --bind=${ROOT}/etc:/etc /usr/sbin/groupadd -r ${opts} "${egroup}" || die

see bug https://bugs.gentoo.org/show_bug.cgi?id=517712
Comment 44 James Le Cuirot gentoo-dev 2014-08-21 19:42:27 UTC
(In reply to Joakim Tjernlund from comment #43)
> I noticed you too have found proot, very handy tool! I use it to solve the
> --sysroot problem(passing --sysroot in CFLAGS etc.):
>  proot -b ${ROOT}:/usr/${CHOST}/ emerge --root-deps=rdeps ....
> That way all accesses to /usr/${CHOST}/ is remapped to ${ROOT} so
> there is no need to pass --sysroot

The problem with that is that it hides your cross toolchain so you can't use it to start from scratch, which is what I really wanted to do. My initial approach was to use mount --bind but I gave up on that for this reason.

> Similarly you can use proot to map /etc to ${ROOT}/etc in enewgroup and
> friends:
> proot -0 --bind=${ROOT}/etc:/etc /usr/sbin/groupadd -r ${opts} "${egroup}"
> || die
> 
> see bug https://bugs.gentoo.org/show_bug.cgi?id=517712

Unless you map /etc/passwd and /etc/shadow (proot can map individual files) during the whole emerge process then you will get problems when / and ROOT inevitably go out of sync. I'd like a smarter solution.

Thanks for the feedback though. I don't want to noise up this bug any further so if you wish to discuss cross-boss, please contact me by e-mail or IRC.

I'm now going to try and build Perl without cross-boss and I'll post up the resulting ebuild patch.
Comment 45 James Le Cuirot gentoo-dev 2014-08-21 20:44:17 UTC
Created attachment 383286 [details, diff]
Working perl-5.18.2-r1 cross patch

It works without cross-boss! Tested against armv7a-hardfloat-linux-gnueabi. Also tested a native build. Here's the patch. I've noticed that src_prepare-v50180002.eblit is present but not actually used.
Comment 46 James Le Cuirot gentoo-dev 2014-08-23 10:58:19 UTC
One more thing, I'd forgotten that I'd previously taken additional patches from https://github.com/moben/perlcross. Unfortunately I still can't remember the details. It builds okay without them but maybe they were needed to prevent odd behaviour afterwards.
Comment 47 James Le Cuirot gentoo-dev 2014-08-24 11:32:51 UTC
On closer inspection, these patches were already merged upstream so no worries there. I had submitted a couple more to fix the soname. We already patch Perl to fix this but it isn't effective for perl-cross.

https://github.com/arsv/perl-cross/pull/6
Comment 48 SpanKY gentoo-dev 2015-09-07 23:44:18 UTC
*** Bug 559574 has been marked as a duplicate of this bug. ***
Comment 49 Xavier Miller (RETIRED) gentoo-dev 2016-09-22 07:24:41 UTC
Hi!,

Is there a patch for perl 5.24.0-r1 ?
Comment 50 James Le Cuirot gentoo-dev 2016-09-22 07:31:33 UTC
(In reply to Xavier Miller from comment #49)
> Hi!,
> 
> Is there a patch for perl 5.24.0-r1 ?

If you mean my ebuild patch then no but it probably hasn't changed much. Feel free to have a crack at it. Upstream perlcross supports 5.24.0.
Comment 51 Xavier Miller (RETIRED) gentoo-dev 2016-09-22 08:04:11 UTC
I adapted attachment 383286 [details, diff] for perl 5.24.0-r1
(CROSS_VER=1.0.3)

But I have the following error message during the configure phase:

Any additional ld flags (NOT including libraries)? [-Wl,-O1 -Wl,--as-needed]
Checking your choice of C compiler and flags for coherency...
I've tried to compile and run the following simple program:

#include <stdio.h>
int main() { printf("Ok\n"); return(0); }

I used the command:

        armv6j-hardfloat-linux-gnueabi-gcc -o try -O2 -pipe -march=armv6j -mfpu=vfp -mfloat-abi=hard -fomit-frame-pointer -DOVR_DBL_DIG=14 -Wl,-O1 -Wl,--as-needed try.c -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
         ./try

and I got the following output:

/bin/sh: ./try: cannot execute binary file: Exec format error
The program compiled OK, but exited with status 126.
You have a problem.  Shall I abort Configure [y]
Ok.  Stopping Configure.
Comment 52 James Le Cuirot gentoo-dev 2016-09-22 09:51:12 UTC
You didn't update the CROSS_VER variable. It should be 1.1.0 now. See this page.

http://arsv.github.io/perl-cross/download.html
Comment 53 Xavier Miller (RETIRED) gentoo-dev 2016-09-22 09:52:23 UTC
If I also patch src_configure() in the ebuild like the patch in the eblit, I can configure, but not compile perl-5.24.0-r1:
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0 ...
make -j5 -l2 -j1
patch -p1 -i cnf/diffs/test-checkcase.patch && touch cnf/diffs/test-checkcase.applied
patching file t/porting/checkcase.t
patch -p1 -i cnf/diffs/makemaker.patch && touch cnf/diffs/makemaker.applied
patching file cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm
patch -p1 -i cnf/diffs/posix-makefile.patch && touch cnf/diffs/posix-makefile.applied
patching file ext/POSIX/Makefile.PL
patch -p1 -i cnf/diffs/installscripts.patch && touch cnf/diffs/installscripts.applied
patching file installman
patching file installperl
patch -p1 -i cnf/diffs/liblist.patch && touch cnf/diffs/liblist.applied
patching file cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist/Kid.pm
patching file t/porting/customized.dat
Hunk #1 FAILED at 3.
1 out of 1 hunk FAILED -- saving rejects to file t/porting/customized.dat.rej
make: *** [Makefile:60: cnf/diffs/liblist.applied] Error 1
 * ERROR: dev-lang/perl-5.24.0-r1::local failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=dev-lang/perl-5.24.0-r1::local'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/perl-5.24.0-r1::local'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'
 * S: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'

>>> Failed to emerge dev-lang/perl-5.24.0-r1 for /usr/armv6j-hardfloat-linux-gnueabi/, Log file:

>>>  '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/build.log'

 * Messages for package dev-lang/perl-5.24.0-r1 merged to /usr/armv6j-hardfloat-linux-gnueabi/:

 * ERROR: dev-lang/perl-5.24.0-r1::local failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=dev-lang/perl-5.24.0-r1::local'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/perl-5.24.0-r1::local'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'
 * S: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'
Comment 54 Xavier Miller (RETIRED) gentoo-dev 2016-09-22 09:59:20 UTC
It doesn't work with perl-cross 1.1.0:

>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0 ...
./configure --target=armv6j-hardfloat-linux-gnueabi -Dinstallprefix= -Dinstallusrbinperl=undef -Dusevendorprefix=define -Duseshrplib -Darchname=armv6j-linux -Dcc=armv6j-hardfloat-linux-gnueabi-gcc -Doptimize=-O2\ -pipe\ -march=armv6j\ -mfpu=vfp\ -mfloat-abi=hard\ -fomit-frame-pointer -Dldflags=-Wl\,-O1\ -Wl\,--as-needed -Dprefix=/usr -Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib/perl5/5.24.0 -Darchlib=/usr/lib/perl5/5.24.0/armv6j-linux -Dsitelib=/usr/local/lib/perl5/5.24.0 -Dsitearch=/usr/local/lib/perl5/5.24.0/armv6j-linux -Dvendorlib=/usr/lib/perl5/vendor_perl/5.24.0 -Dvendorarch=/usr/lib/perl5/vendor_perl/5.24.0/armv6j-linux -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.24.0 -Dlocincpth=/usr/include\  -Dglibpth=/lib\ /usr/lib\  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Ud_csh -Dsh=/bin/sh -Dtargetsh=/bin/sh -Uusenm -Ui_ndbm -Ui_gdbm -Ui_db -DDEBUGGING=none -Dnoextensions=ODBM_File\ GDBM_File\ NDBM_File
/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/environment: line 2731: ./configure: No such file or directory
 * ERROR: dev-lang/perl-5.24.0-r1::local failed (configure phase):
 *   Unable to configure
 *
 * Call stack:
 *     ebuild.sh, line 115:  Called src_configure
 *   environment, line 2731:  Called die
 * The specific snippet of code:
 *       "${@}" || die "Unable to configure"
 *
 * If you need support, post the output of `emerge --info '=dev-lang/perl-5.24.0-r1::local'`,
 * the complete build log and the output of `emerge -pqv '=dev-lang/perl-5.24.0-r1::local'`.
 * The complete build log is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-lang/perl-5.24.0-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'
 * S: '/var/tmp/portage/dev-lang/perl-5.24.0-r1/work/perl-5.24.0'
Comment 55 James Le Cuirot gentoo-dev 2016-09-25 13:51:41 UTC
Just picked this up again after a long time. The tarball structure has changed. If you copy/move the files from the perl-cross-1.1.0 directory then configure starts. It then fails with the same patch issue you had with the earlier version. This is because one of their patches collide with one of ours but the workaround is simple enough.

sed -i 's/MakeMaker\.pm 830acdc810e2974d7fd4ec408ea1bfa825c75b69/MakeMaker.pm effd272b3c9224af6fd0f6cae7183f33ec4b1106/' cnf/diffs/perl5-5.24.0/liblist.patch || die

After that, it gets quite far but eventually fails with the following. Don't know why yet.

./miniperl_top make_ext_Makefile.pl cpan/CPANPLUS/Makefile.PL
cpan/CPANPLUS: can't find module source
Comment 56 James Le Cuirot gentoo-dev 2016-09-25 22:01:16 UTC
Created attachment 447926 [details, diff]
Working perl-5.24.0-r1 cross patch

I got it to work. The CPANPLUS thing was due to something we had patched in. perl-cross was looking for a CPANPLUS.pm file that we had omitted but simply creating an empty file was enough to fool it.

touch cpan/CPANPLUS/lib/CPANPLUS.pm

Attached is a working patch against 5.24.0-r1. make -j1 is no longer needed, which is nice. I'm less sure about the EROOT stuff since discussions about SYSROOT but that hasn't been cemented yet so I've left it as EROOT for now. I tried using the new -Dusesoname option but that broke it. I probably need an extra option but I haven't had time to experiment with that.
Comment 57 Xavier Miller (RETIRED) gentoo-dev 2016-09-26 18:46:51 UTC
Hi!

I have one other issue: perl modules that I cross-emerge are installed in /usr/lib64 in place in the right lib directory (e.g /usr/lib for arm, i686).

Do I need to open a new bug ?
Comment 58 Xavier Miller (RETIRED) gentoo-dev 2016-09-26 18:49:43 UTC
same issue for python modules
Comment 59 James Le Cuirot gentoo-dev 2016-09-26 19:37:27 UTC
(In reply to Xavier Miller from comment #57)
> Hi!
> 
> I have one other issue: perl modules that I cross-emerge are installed in
> /usr/lib64 in place in the right lib directory (e.g /usr/lib for arm, i686).

I never said other Perl packages would work. ;) I cooked up a nasty hack for cross-boss that has never failed as far as I recall. The configure phase typically invokes perl and if you do this via proot+qemu then the rest of the ebuild succeeds with the help of these additional overrides passed to emake.

"PERL_ARCHLIB=${ROOT%/}${ARCH_LIB}"
"PERL_ARCHLIBDEP=${ROOT%/}${ARCH_LIB}"
"PERL_INC=${ROOT%/}${ARCH_LIB}/CORE"
"PERL_INCDEP=${ROOT%/}${ARCH_LIB}/CORE"
"XSUBPPDIR=${ROOT%/}${SITE_LIB/\/local}/ExtUtils"
"XSUBPPDEPS=\$(XSUBPPDIR)/typemap \$(XSUBPP)"
"XSUBPPARGS=-typemap \$(XSUBPPDIR)/typemap"

These overrides could be added to perl-module.eclass easily enough but the proot+qemu stuff is probably a step too far.
Comment 60 James Le Cuirot gentoo-dev 2016-10-20 11:26:41 UTC
There's a glitch in perl-cross somewhere as installsitelib and installsitehtml1dir end up with a trailing space. This screws with installation of modules later. I shall investigate.
Comment 61 James Le Cuirot gentoo-dev 2016-10-20 14:38:33 UTC
Created attachment 450836 [details, diff]
Working perl-5.24.0-r1 cross patch

The issue has gone in perl-cross 1.1.1 but a new patch is needed.
Comment 62 Andreas K. Hüttel archtester gentoo-dev 2016-10-22 20:33:55 UTC
(In reply to James Le Cuirot from comment #61)
> Created attachment 450836 [details, diff] [details, diff]
> Working perl-5.24.0-r1 cross patch
> 
> The issue has gone in perl-cross 1.1.1 but a new patch is needed.

Thanks a lot, applied in 5.24.0-r2. 

Would be grateful for any help keeping it uptodate. :)
Comment 63 James Le Cuirot gentoo-dev 2016-10-22 21:05:48 UTC
As said on IRC, didn't expect this to get merged any time soon so thanks! For anyone following along, here is my updated snippet of the above for building modules.

"PERL_ARCHLIB=${ROOT%/}${ARCH_LIB}"
"PERL_ARCHLIBDEP=${ROOT%/}${ARCH_LIB}"
"PERL_INC=${ROOT%/}${ARCH_LIB}/CORE"
"PERL_INCDEP=${ROOT%/}${ARCH_LIB}/CORE"
"XSUBPPDIR=${ROOT%/}${SITE_LIB/\/local}/ExtUtils"
"XSUBPPDEPS=\$(XSUBPPDIR)/typemap \$(XSUBPPDIR)/xsubpp"
"XSUBPPARGS=-typemap \$(XSUBPPDIR)/typemap"

I've already forgotten why but using $(XSUBPP) doesn't always work.