Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure: add support of qemu #12387

Closed
p5pRT opened this issue Sep 9, 2012 · 15 comments
Closed

Configure: add support of qemu #12387

p5pRT opened this issue Sep 9, 2012 · 15 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Sep 9, 2012

Migrated from rt.perl.org#114798 (status was 'resolved')

Searchable as RT114798$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 9, 2012

From @fperrad

Created by @fperrad

my goal is the cross-compiling of Perl with Buildroot,
see http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/msg191592.html
my last patch against Buildroot is http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-ppc, qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

Inline Patch
diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@@ -2911,6 +2911,14 @@ fi
 $targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@"
 EOF
 	    ;;
+	qemu*)
+	    to=:
+	    from=:
+	    cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@"
+EOF
+	    ;;
 	*)  echo "Unknown targetrun '$targetrun'" >&4
 	    exit 1
 	    ;;
-- 
1.7.9.5

From f686dacad60a327728141efa38dee1614a875368 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:27​:48 +0200
Subject​: [PATCH 2/3] fix when cross-devel

$run must be used

Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Inline Patch
diff --git a/Configure b/Configure
index c78cf77..6cc87af 100755
--- a/Configure
+++ b/Configure
@@ -5059,7 +5059,7 @@ checkccflag='check=$1; flag=$2; callback=$3;
 echo " ";
 echo "Checking if your compiler accepts $flag" 2>&1;
 echo "int main(void) { return 0; }" > gcctest.c;
-if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
+if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
     echo "Yes, it does." 2>&1;
     if $test -s gcctest.out ; then
         echo "But your platform does not like it:";
-- 
1.7.9.5

From fc0278276b992191dd4d81a55a64f5b3b6922812 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:45​:30 +0200
Subject​: [PATCH 3/3] add a default for targethost when qemu

targethost is mandatory with a ssh connection, but useless with qemu

Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 3 +++
1 file changed, 3 insertions(+)

Inline Patch
diff --git a/Configure b/Configure
index 6cc87af..ff81233 100755
--- a/Configure
+++ b/Configure
@@ -2840,6 +2840,9 @@ $define|true|[yY]*)
             ;;
         *)  echo "Using usrinc $usrinc." >&4 ;;
 	esac
+	case "$targetrun" in
+	qemu*) targethost=dummy ;;
+	esac
 	case "$targethost" in
 	'') echo "Targethost not defined." >&4; croak=y ;;
         *)  echo "Using targethost $targethost." >&4
-- 
1.7.9.5
Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.14.2:

Configured by Debian Project at Fri Aug 10 21:43:39 UTC 2012.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

  Platform:
    osname=linux, osvers=2.6.42-26-generic,
archname=i686-linux-gnu-thread-multi-64int
    uname='linux roseapple 2.6.42-26-generic #41-ubuntu smp thu jun 14
17:49:24 utc 2012 i686 i686 i386 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=i686-linux-gnu -Dprefix=/usr
-Dprivlib=/usr/share/perl/5.14 -Darchlib=/usr/lib/perl/5.14
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
-Dsitelib=/usr/local/share/perl/5.14.2
-Dsitearch=/usr/local/lib/perl/5.14.2 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1
-Dsiteman3dir=/usr/local/man/man3 -Duse64bitint -Dman1ext=1
-Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh
-Ud_ualarm -Uusesfio -Uusenm -Ui_libutil -DDEBUGGING=-g -Doptimize=-O2
-Duseshrplib -Dlibperl=libperl.so.5.14.2 -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/i386-linux-gnu /lib/../lib
/usr/lib/i386-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=, so=so, useshrplib=true, libperl=libperl.so.5.14.2
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib
-fstack-protector'

Locally applied patches:



@INC for perl 5.14.2:
    /etc/perl
    /usr/local/lib/perl/5.14.2
    /usr/local/share/perl/5.14.2
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.14
    /usr/share/perl/5.14
    /usr/local/lib/site_perl
    .


Environment for perl 5.14.2:
    HOME=/home/user
    LANG=en_US.UTF-8
    LANGUAGE=en_US:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 10, 2012

From @Tux

On Sat, 08 Sep 2012 23​:51​:50 -0700, Francois PERRAD (via RT)
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Francois PERRAD
# Please include the string​: [perl #114798]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=114798 >

This is a bug report for perl from francois.perrad@​gadz.org,
generated with the help of perlbug 1.39 running under perl 5.14.2.

-----------------------------------------------------------------
[Please describe your issue here]
my goal is the cross-compiling of Perl with Buildroot,
see http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/msg191592.html
my last patch against Buildroot is http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

I'd like to hear jess' comments on this

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-ppc, qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@​@​ -2911,6 +2911,14 @​@​ fi
$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@​"
EOF
;;
+ qemu*)
+ to=​:
+ from=​:
+ cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@​"
+EOF
+ ;;
*) echo "Unknown targetrun '$targetrun'" >&4
exit 1
;;

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.14 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 10, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 19, 2012

From castaway@desert-island.me.uk

Hi,

I assume from your patches that you're just running a local compile, rather
than the scp/ssh dance that the cross-compiling defaults to?

On Sat Sep 08 23​:51​:49 2012, fperrad wrote​:

my goal is the cross-compiling of Perl with Buildroot,
see
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/msg191592.html
my last patch against Buildroot is
http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-ppc,
qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@​@​ -2911,6 +2911,14 @​@​ fi
$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@​"
EOF
;;
+ qemu*)
+ to=​:
+ from=​:
+ cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@​"
+EOF
+ ;;
*) echo "Unknown targetrun '$targetrun'" >&4
exit 1
;;

Silly reply-whatsit only lists one patch.

The only question I'd have is what is $qemulib? Can an existing variable be
used for it? The part that uses $qemulib should first test if it has been
set, and complain if not (preferably with a hint about what its for)

The rest seems quite sane to me.

Jes

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 19, 2012

From @fperrad

On Fri Oct 19 04​:52​:03 2012, JROBINSON wrote​:

Hi,

I assume from your patches that you're just running a local compile,
rather
than the scp/ssh dance that the cross-compiling defaults to?

Yes, I do real cross-compilation, not remote-compilation :)

On Sat Sep 08 23​:51​:49 2012, fperrad wrote​:

my goal is the cross-compiling of Perl with Buildroot,
see
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/msg191592.html
my last patch against Buildroot is
http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-ppc,
qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@​@​ -2911,6 +2911,14 @​@​ fi
$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@​"
EOF
;;
+ qemu*)
+ to=​:
+ from=​:
+ cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@​"
+EOF
+ ;;
*) echo "Unknown targetrun '$targetrun'" >&4
exit 1
;;

Silly reply-whatsit only lists one patch.

The only question I'd have is what is $qemulib? Can an existing
variable be
used for it? The part that uses $qemulib should first test if it has been
set, and complain if not (preferably with a hint about what its for)

The rest seems quite sane to me.

My needs have changed a bit. My use cases are now :
  $ ./Configure -Dusecrosscompile -Dtargetrun="qemu-arm -L
path/to/cross-libs" ...
  $ ./Configure -Dusecrosscompile -Dtargetrun="/my/home/built/qemu-arm" ...

So, I refactor my 3 patches without $qemulib. See them in attachment.

Fran�ois

Jes

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 19, 2012

From @fperrad

0002-fix-when-cross-devel.patch
From 3bf60a97774a5a7a456eec2fb7ab8034b7efa65b Mon Sep 17 00:00:00 2001
From: Francois Perrad <francois.perrad@gadz.org>
Date: Fri, 19 Oct 2012 18:46:23 +0200
Subject: [PATCH 2/3] fix when cross-devel

$run must be used

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 Configure |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Configure b/Configure
index 3c2f8c7..1b84736 100755
--- a/Configure
+++ b/Configure
@@ -5059,7 +5059,7 @@ checkccflag='check=$1; flag=$2; callback=$3;
 echo " ";
 echo "Checking if your compiler accepts $flag" 2>&1;
 echo "int main(void) { return 0; }" > gcctest.c;
-if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
+if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest; then
     echo "Yes, it does." 2>&1;
     if $test -s gcctest.out ; then
         echo "But your platform does not like it:";
-- 
1.7.9.5

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 19, 2012

From @fperrad

0001-add-qemu-support.patch
From 2e7c8c54ac20ea8d5a2330102372d57bb78ed3b2 Mon Sep 17 00:00:00 2001
From: Francois Perrad <francois.perrad@gadz.org>
Date: Fri, 19 Oct 2012 18:45:49 +0200
Subject: [PATCH 1/3] add qemu support

$targetrun = "qemu-arm -L path/to/cross-libs"
or $targetrun = "/my/home/built/qemu-arm"

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 Configure |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Configure b/Configure
index a1bc835..3c2f8c7 100755
--- a/Configure
+++ b/Configure
@@ -2871,7 +2871,7 @@ $define|true|[yY]*)
 	case "$targetfrom" in
 	'') targetfrom=scp ;;
 	esac
-    	run=$run-$targetrun
+    	run=$run-`basename \`echo "$targetrun" | sed -e 's/^\([^ \t]*\).*$/\1/'\``
     	to=$to-$targetto
     	from=$from-$targetfrom
 	case "$targetdir" in
@@ -2911,6 +2911,14 @@ fi
 $targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@"
 EOF
 	    ;;
+	*qemu*)
+	    to=:
+	    from=:
+	    cat >$run <<EOF
+#!/bin/sh
+$targetrun "\$@"
+EOF
+	    ;;
 	*)  echo "Unknown targetrun '$targetrun'" >&4
 	    exit 1
 	    ;;
-- 
1.7.9.5

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Oct 19, 2012

From @fperrad

0003-add-a-targethost-default-when-qemu.patch
From 18c13c8ed59d8884f6507dbe555832b008fea99f Mon Sep 17 00:00:00 2001
From: Francois Perrad <francois.perrad@gadz.org>
Date: Fri, 19 Oct 2012 18:46:49 +0200
Subject: [PATCH 3/3] add a targethost default when qemu

targethost is mandatory with a ssh connection, but useless with qemu

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 Configure |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/Configure b/Configure
index 1b84736..fec6dd0 100755
--- a/Configure
+++ b/Configure
@@ -2840,6 +2840,9 @@ $define|true|[yY]*)
             ;;
         *)  echo "Using usrinc $usrinc." >&4 ;;
 	esac
+	case "$targetrun" in
+	*qemu*) targethost=dummy ;;
+	esac
 	case "$targethost" in
 	'') echo "Targethost not defined." >&4; croak=y ;;
         *)  echo "Using targethost $targethost." >&4
-- 
1.7.9.5

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 8, 2012

From castaway@desert-island.me.uk

Gah, perlbug didn't notify me on updates, I've now added myself to the
watchers list.

I'm just looking at this part myself. I think what I'd like to do is​:
a) Add a way to cross-compile, but skip the whole "run stuff on another
host" altogether, instead of changing parts of it. I'll probably have a
go at this by splitting the "figure out your compiler" part from the
"run on another host" part. IMO one could want to run on another host
even if not cross-compiling..

b) Allow you to just provide your own value of "run", or for a hints
file to override it.

I'm not quite sure I understand what your patch for run=`basename ... `
line is doing, given you then have a qemu section that ignores it?

On Fri Oct 19 11​:51​:31 2012, fperrad wrote​:

On Fri Oct 19 04​:52​:03 2012, JROBINSON wrote​:

Hi,

I assume from your patches that you're just running a local compile,
rather
than the scp/ssh dance that the cross-compiling defaults to?

Yes, I do real cross-compilation, not remote-compilation :)

On Sat Sep 08 23​:51​:49 2012, fperrad wrote​:

my goal is the cross-compiling of Perl with Buildroot,
see
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/
msg191592.html
my last patch against Buildroot is
http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00
2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-
ppc,
qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@​@​ -2911,6 +2911,14 @​@​ fi
$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@​"
EOF
;;
+ qemu*)
+ to=​:
+ from=​:
+ cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@​"
+EOF
+ ;;
*) echo "Unknown targetrun '$targetrun'" >&4
exit 1
;;

Silly reply-whatsit only lists one patch.

The only question I'd have is what is $qemulib? Can an existing
variable be
used for it? The part that uses $qemulib should first test if it
has been
set, and complain if not (preferably with a hint about what its for)

The rest seems quite sane to me.

My needs have changed a bit. My use cases are now :
$ ./Configure -Dusecrosscompile -Dtargetrun="qemu-arm -L
path/to/cross-libs" ...
$ ./Configure -Dusecrosscompile -Dtargetrun="/my/home/built/qemu-
arm" ...

So, I refactor my 3 patches without $qemulib. See them in attachment.

Fran�ois

Jes

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 31, 2014

From @Hugmeir

On Sun, Sep 9, 2012 at 3​:51 AM, Francois PERRAD
<perlbug-followup@​perl.org>wrote​:

# New Ticket Created by Francois PERRAD
# Please include the string​: [perl #114798]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=114798 >

This is a bug report for perl from francois.perrad@​gadz.org,
generated with the help of perlbug 1.39 running under perl 5.14.2.

-----------------------------------------------------------------
[Please describe your issue here]
my goal is the cross-compiling of Perl with Buildroot,
see
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/09/msg191592.html
my last patch against Buildroot is
http​://patchwork.ozlabs.org/patch/182554/
(the recipe is in package/perl/perl.mk)

So, Configure needs a support of qemu (user mode).

Find below 3 patches against blead

From 42abf7caea008ee7dc8a876d88e3dd4d7de3cc16 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:26​:09 +0200
Subject​: [PATCH 1/3] add qemu support

$targetrun contains something like : qemu-arm, qemu-i386, qemu-ppc,
qemu-x86_64
$qemulib is a path
Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/Configure b/Configure
index a1ba981..c78cf77 100755
--- a/Configure
+++ b/Configure
@​@​ -2911,6 +2911,14 @​@​ fi
$targetrun -l $targetuser $targethost "cd \$cwd && ./\$exe \$@​"
EOF
;;
+ qemu*)
+ to=​:
+ from=​:
+ cat >$run <<EOF
+#!/bin/sh
+$targetrun -L $qemulib "\$@​"
+EOF
+ ;;
*) echo "Unknown targetrun '$targetrun'" >&4
exit 1
;;
--
1.7.9.5

From f686dacad60a327728141efa38dee1614a875368 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:27​:48 +0200
Subject​: [PATCH 2/3] fix when cross-devel

$run must be used

Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Configure b/Configure
index c78cf77..6cc87af 100755
--- a/Configure
+++ b/Configure
@​@​ -5059,7 +5059,7 @​@​ checkccflag='check=$1; flag=$2; callback=$3;
echo " ";
echo "Checking if your compiler accepts $flag" 2>&1;
echo "int main(void) { return 0; }" > gcctest.c;
-if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && ./gcctest; then
+if $cc -O2 $flag -o gcctest gcctest.c 2>gcctest.out && $run ./gcctest;
then
echo "Yes, it does." 2>&1;
if $test -s gcctest.out ; then
echo "But your platform does not like it​:";
--
1.7.9.5

From fc0278276b992191dd4d81a55a64f5b3b6922812 Mon Sep 17 00​:00​:00 2001
From​: Francois Perrad <francois.perrad@​gadz.org>
Date​: Tue, 4 Sep 2012 16​:45​:30 +0200
Subject​: [PATCH 3/3] add a default for targethost when qemu

targethost is mandatory with a ssh connection, but useless with qemu

Signed-off-by​: Francois Perrad <francois.perrad@​gadz.org>
---
Configure | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Configure b/Configure
index 6cc87af..ff81233 100755
--- a/Configure
+++ b/Configure
@​@​ -2840,6 +2840,9 @​@​ $define|true|[yY]*)
;;
*) echo "Using usrinc $usrinc." >&4 ;;
esac
+ case "$targetrun" in
+ qemu*) targethost=dummy ;;
+ esac
case "$targethost" in
'') echo "Targethost not defined." >&4; croak=y ;;
*) echo "Using targethost $targethost." >&4
--
1.7.9.5

Jumpstarting this ticket. Francois recently chimed in on another thread &
updated the patch[0], so I applied it locally and gave it a try.
With some tweaking I was able to build a perl on my amd64 Linux box that
runs on a raspberry pi without needing to access the target system in any
way; additionally, with some manual hacks 'make test' for that perl managed
to run in its entirely, *locally*, which is huge. So I think that there's
quite a bit of worth in pursuing this.

That being said, I had a couple of problems along the way. First, for me
the current $run dies with 'FATAL​: kernel too old'. Some googling lead me
to discover that I could pass qemu the kernel version with the -r switch,
ala qemu-arm -r 3.11, and that solved the problem, so to the very least, a
way of passing options to qemu is needed. Additionally, $run needs to be
able to handle -cwd and -env, so locally it looks like this for me​:

  cat >$run <<EOF
#!/bin/sh
env=''
case "\$1" in
-cwd)
  shift
  cwd=\$1
  shift
  ;;
esac
case "\$1" in
-env)
  shift
  env=\$1
  shift
  ;;
esac
case "\$cwd" in
'') ;;
*) cd \$cwd ;;
esac
\$env $targetrun $qemuoptions -L $sysroot "\$@​"
EOF

With $qemuoptions being something like "-r 3.11".

Moving on, I too am unsure about the `basename ...` line. The intent seems
to be that $run end up as run-qemu-arm when Configure is called with either
-Dtargetrun=/foo/bar/qemu-arm or -Dtargetrun='qemu-arm -r 3.11'. The latter
seems like the wrong way to go about it; for the former, we currently
assume that whatever targetrun is, it'll be in PATH; if we're going to
start accepting fulls paths to binaries in targetrun, the other options
should be fixed as well.

For 'make test', I had to basically replace ./perl with a script that
called ./original-perl through $run, but I also had to make it load a
compat module that removed 'original-' from $^X. Which is just nasty.

Unrelated to this patch but in a similar vein, yesterday I pushed a branch
that allows cross-compiling from Linux to Win32, either through ssh or
wine[1]. The wine bits are unsurprisingly pretty similar to this.

[0]
https://github.com/fperrad/br/blob/perl-castaway/package/perl/perl-configure-qemu.patch
[1]
http​://perl5.git.perl.org/perl.git/shortlog/refs/heads/hugmeir/cross-compile-win32

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 1, 2014

From @fperrad

2014-01-31 Brian Fraser <fraserbn@​gmail.com>​:

On Sun, Sep 9, 2012 at 3​:51 AM, Francois PERRAD <perlbug-followup@​perl.org>
wrote​:

# New Ticket Created by Francois PERRAD
# Please include the string​: [perl #114798]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=114798 >

Jumpstarting this ticket. Francois recently chimed in on another thread &
updated the patch[0], so I applied it locally and gave it a try.
With some tweaking I was able to build a perl on my amd64 Linux box that
runs on a raspberry pi without needing to access the target system in any
way; additionally, with some manual hacks 'make test' for that perl managed
to run in its entirely, *locally*, which is huge. So I think that there's
quite a bit of worth in pursuing this.

The use of Qemu has some limitations :
1) Qemu is not available for all CPU architecture
2) qemu-i386 is buggy, I filled this ticket
https://bugs.launchpad.net/qemu/+bug/1076445
with a minimal test case which doesn't depend on Perl configure/build.

For testing purpose, I copy the whole build tree on the target
(Buildroot linux), and run
  $ cd t
  $ ln -s ../perl perl
  $ ./perl harness

François

That being said, I had a couple of problems along the way. First, for me the
current $run dies with 'FATAL​: kernel too old'. Some googling lead me to
discover that I could pass qemu the kernel version with the -r switch, ala
qemu-arm -r 3.11, and that solved the problem, so to the very least, a way
of passing options to qemu is needed. Additionally, $run needs to be able to
handle -cwd and -env, so locally it looks like this for me​:

     cat >$run \<\<EOF

#!/bin/sh
env=''
case "\$1" in
-cwd)
shift
cwd=\$1
shift
;;
esac
case "\$1" in
-env)
shift
env=\$1
shift
;;
esac
case "\$cwd" in
'') ;;
*) cd \$cwd ;;
esac
\$env $targetrun $qemuoptions -L $sysroot "\$@​"
EOF

With $qemuoptions being something like "-r 3.11".

Moving on, I too am unsure about the `basename ...` line. The intent seems
to be that $run end up as run-qemu-arm when Configure is called with either
-Dtargetrun=/foo/bar/qemu-arm or -Dtargetrun='qemu-arm -r 3.11'. The latter
seems like the wrong way to go about it; for the former, we currently assume
that whatever targetrun is, it'll be in PATH; if we're going to start
accepting fulls paths to binaries in targetrun, the other options should be
fixed as well.

For 'make test', I had to basically replace ./perl with a script that called
./original-perl through $run, but I also had to make it load a compat module
that removed 'original-' from $^X. Which is just nasty.

Unrelated to this patch but in a similar vein, yesterday I pushed a branch
that allows cross-compiling from Linux to Win32, either through ssh or
wine[1]. The wine bits are unsurprisingly pretty similar to this.

[0]
https://github.com/fperrad/br/blob/perl-castaway/package/perl/perl-configure-qemu.patch
[1]
http​://perl5.git.perl.org/perl.git/shortlog/refs/heads/hugmeir/cross-compile-win32

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 29, 2017

From @jkeenan

On Sat, 01 Feb 2014 13​:51​:09 GMT, fperrad wrote​:

2014-01-31 Brian Fraser <fraserbn@​gmail.com>​:

On Sun, Sep 9, 2012 at 3​:51 AM, Francois PERRAD <perlbug-
followup@​perl.org>
wrote​:

# New Ticket Created by Francois PERRAD
# Please include the string​: [perl #114798]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=114798 >

Jumpstarting this ticket. Francois recently chimed in on another
thread &
updated the patch[0], so I applied it locally and gave it a try.
With some tweaking I was able to build a perl on my amd64 Linux box
that
runs on a raspberry pi without needing to access the target system in
any
way; additionally, with some manual hacks 'make test' for that perl
managed
to run in its entirely, *locally*, which is huge. So I think that
there's
quite a bit of worth in pursuing this.

The use of Qemu has some limitations :
1) Qemu is not available for all CPU architecture
2) qemu-i386 is buggy, I filled this ticket
https://bugs.launchpad.net/qemu/+bug/1076445
with a minimal test case which doesn't depend on Perl configure/build.

For testing purpose, I copy the whole build tree on the target
(Buildroot linux), and run
$ cd t
$ ln -s ../perl perl
$ ./perl harness

François

That being said, I had a couple of problems along the way. First, for
me the
current $run dies with 'FATAL​: kernel too old'. Some googling lead me
to
discover that I could pass qemu the kernel version with the -r
switch, ala
qemu-arm -r 3.11, and that solved the problem, so to the very least,
a way
of passing options to qemu is needed. Additionally, $run needs to be
able to
handle -cwd and -env, so locally it looks like this for me​:

cat >$run <<EOF
#!/bin/sh
env=''
case "\$1" in
-cwd)
shift
cwd=\$1
shift
;;
esac
case "\$1" in
-env)
shift
env=\$1
shift
;;
esac
case "\$cwd" in
'') ;;
*) cd \$cwd ;;
esac
\$env $targetrun $qemuoptions -L $sysroot "\$@​"
EOF

With $qemuoptions being something like "-r 3.11".

Moving on, I too am unsure about the `basename ...` line. The intent
seems
to be that $run end up as run-qemu-arm when Configure is called with
either
-Dtargetrun=/foo/bar/qemu-arm or -Dtargetrun='qemu-arm -r 3.11'. The
latter
seems like the wrong way to go about it; for the former, we currently
assume
that whatever targetrun is, it'll be in PATH; if we're going to start
accepting fulls paths to binaries in targetrun, the other options
should be
fixed as well.

For 'make test', I had to basically replace ./perl with a script that
called
./original-perl through $run, but I also had to make it load a compat
module
that removed 'original-' from $^X. Which is just nasty.

Unrelated to this patch but in a similar vein, yesterday I pushed a
branch
that allows cross-compiling from Linux to Win32, either through ssh
or
wine[1]. The wine bits are unsurprisingly pretty similar to this.

[0]
https://github.com/fperrad/br/blob/perl-castaway/package/perl/perl-
configure-qemu.patch
[1]
http​://perl5.git.perl.org/perl.git/shortlog/refs/heads/hugmeir/cross-
compile-win32

François, are you still attempting this work for Buildroot? Do you still need modifications to Perl 5's Configure?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 29, 2017

From @fperrad

François, are you still attempting this work for Buildroot? Do you
still need modifications to Perl 5's Configure?

Thank you very much.

No.
In Buildroot, the goal (cross-compilation of Perl) was achieved with <https://arsv.github.io/perl-cross/>.

François

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 29, 2017

From @jkeenan

On Fri, 29 Dec 2017 17​:49​:35 GMT, fperrad wrote​:

François, are you still attempting this work for Buildroot? Do you
still need modifications to Perl 5's Configure?

Thank you very much.

No.
In Buildroot, the goal (cross-compilation of Perl) was achieved with
<https://arsv.github.io/perl-cross/>.

François

Thanks for your quick response. Closing this ticket.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 29, 2017

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant