Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

Cross-compiling, Errno_pm.PL and include paths..

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


castaway at desert-island

Aug 14, 2012, 9:30 AM

Post #1 of 4 (204 views)
Permalink
Cross-compiling, Errno_pm.PL and include paths..

I asked this briefly on #p5p the other day, and well, not enough yelling
ensued, so I thought I'd better double-check.. :)

Through the Android standalone-toolchain docs, I learnt of the --sysroot
option to gcc, which seems quite useful. This sets the logical root dir
for all libraries and headers, which is lovely for using a cross compiler
with its own set of said libraries and headers.

Thus my current cross-compiling cc looks like this:

/usr/src/android/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
--sysroot=/usr/src/android/android-ndk-r8/platforms/android-8/arch-arm/

The only issue I've discovered so far is that Errno_pm.PL (ext/Errno),
contains a series of checks to find /usr/include/errno.h. Under this
scenario, it should look under $sysroot/usr/include/errno.h.

So I've added code to do so, under the check for gcc:

diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index 56bc815..61111a2 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -142,10 +142,15 @@ sub get_files {
$Config{gccversion} !~ /intel/i
# might be using, say, Intel's icc
) {
+ # General cross-compiling use, cross-compiler in $SYSROOT
+ my $sysroot = `$Config{cc} -print-sysroot` || '';
+ chomp($sysroot);
+
# Some Linuxes have weird errno.hs which generate
# no #file or #line directives
- my $linux_errno_h = -e '/usr/include/errno.h' ?
- '/usr/include/errno.h' : '/usr/local/include/errno.h';
+ my $linux_errno_h = -e "$sysroot/usr/include/errno.h"
+ ? "$sysroot/usr/include/errno.h"
+ : "$sysroot/usr/local/include/errno.h";
$file{$linux_errno_h} = 1;
} elsif ($^O eq 'beos' || $^O eq 'haiku') {
# hidden in a special place
@@ -495,3 +500,15 @@ under the same terms as Perl itself.
ESQ

}
+
+#
+# Local variables:
+# c-indentation-style: bsd
+# c-basic-offset: 4
+# indent-tabs-mode: t
+# tab-width: 8
+# End:
+#
+# ex: set ts=8 sts=4 sw=4 noet:
+#
+

(Plus the sty;e variables to keep me from going crazy..)

Objections?

Jess


nick at ccl4

Aug 15, 2012, 7:55 AM

Post #2 of 4 (186 views)
Permalink
Re: Cross-compiling, Errno_pm.PL and include paths.. [In reply to]

On Tue, Aug 14, 2012 at 05:30:34PM +0100, Jess Robinson wrote:

> The only issue I've discovered so far is that Errno_pm.PL (ext/Errno),
> contains a series of checks to find /usr/include/errno.h. Under this
> scenario, it should look under $sysroot/usr/include/errno.h.
>
> So I've added code to do so, under the check for gcc:
>
> diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
> index 56bc815..61111a2 100644
> --- a/ext/Errno/Errno_pm.PL
> +++ b/ext/Errno/Errno_pm.PL
> @@ -142,10 +142,15 @@ sub get_files {
> $Config{gccversion} !~ /intel/i
> # might be using, say, Intel's icc
> ) {
> + # General cross-compiling use, cross-compiler in $SYSROOT
> + my $sysroot = `$Config{cc} -print-sysroot` || '';
> + chomp($sysroot);
> +

I see that the context happens to get a bit to snipped. The above is only
run on Linux, and only for a real gcc. (Not icc)

Some C compilers are special. If I run this on AIX

perl -e 'print `cc -print-sysroot` || "bother!\n"'

it helpfully drops me into the pager, to show me the cc man page.
I don't think that gcc has ever been that special.

> +# Local variables:
> +# c-indentation-style: bsd
> +# c-basic-offset: 4
> +# indent-tabs-mode: t

The new black is indent-tabs-mode: nil

> +# End:
> +#
> +# ex: set ts=8 sts=4 sw=4 noet:
> +#
> +

and hence (I think) et:

I'm not sure where that needs to be documented, as it doesn't seem to be yet.

Nicholas Clark


h.m.brand at xs4all

Aug 15, 2012, 8:17 AM

Post #3 of 4 (184 views)
Permalink
Re: Cross-compiling, Errno_pm.PL and include paths.. [In reply to]

On Wed, 15 Aug 2012 15:55:05 +0100, Nicholas Clark <nick [at] ccl4>
wrote:

> > +# Local variables:
> > +# c-indentation-style: bsd
> > +# c-basic-offset: 4
> > +# indent-tabs-mode: t
>
> The new black is indent-tabs-mode: nil
>
> > +# End:
> > +#
> > +# ex: set ts=8 sts=4 sw=4 noet:
> > +#
> > +
>
> and hence (I think) et:
>
> I'm not sure where that needs to be documented, as it doesn't seem to be yet.
>
> Nicholas Clark

My ex clone does not know about et (nor expandtab):

bad option name et

It does however have

inputtab, itab (One-Of, buf)
The inputtab option controls the behavior of the Tab key. It can be set
to one of the following values:
* tab - insert an actual tab character. This is the traditional vi
behavior, and the default for user buffers.
* spaces - insert enough space characters to look like a tab
character.
* filename - attempt filename completion on the preceding word.
Normally this only completes the names of text files, but you can
set the completebinary option to allow binary file names to be
completed too.
* identifier - attempt tag name completion on the preceding word. If
the word is already complete, or if cursor isn't at the end of a
word, then it inserts a plain tab character. This can be handy when
you're editing source code.
* ex - a smarter version of filename completion, it knows enough
about ex command line syntax to avoid some tabbing mistakes that
the filename setting can make. It can also complete ex command
names, tag names, option names, and option values. This is the
default for the (Elvis ex history) buffer, which is used for
entering in ex commands.
smarttab, sta (Boolean, global)
The smarttab option only affects the behavior of the Tab key in input
mode, when the cursor is in the indentation portion of a line -- before
the first non-whitespace character. If this option is true, then Tab is
treated like ^T, so the line is shifted rightward by one shiftwidth. By
default this option is false, so the Tab key is treated normally (in
accordance with the inputtab option).
autotab, at (Boolean, buf)
The autotab option affects the behavior of the < and > operator commands,
and the ^D and ^T input mode keystrokes. If autotab is true then elvis
will include tab characters in the indentation whitespace; if it is false
then the indentation whitespace will consist entirely of space
characters. By default, it is true.
Note that if you start with a buffer which contains no tabs, and do a ":
set inputtab=spaces noautotab" then no amount of editing will result in
the buffer containing tabs... unless you get tricky with ^V or something.

How far do you want to go in making editor hints editor-dependent?

--
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/


castaway at desert-island

Aug 16, 2012, 2:58 PM

Post #4 of 4 (188 views)
Permalink
Re: Cross-compiling, Errno_pm.PL and include paths.. [In reply to]

On Wed, 15 Aug 2012, Nicholas Clark wrote:

> On Tue, Aug 14, 2012 at 05:30:34PM +0100, Jess Robinson wrote:
>
>> The only issue I've discovered so far is that Errno_pm.PL (ext/Errno),
>> contains a series of checks to find /usr/include/errno.h. Under this
>> scenario, it should look under $sysroot/usr/include/errno.h.
>>
>> So I've added code to do so, under the check for gcc:
>>
>> diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
>> index 56bc815..61111a2 100644
>> --- a/ext/Errno/Errno_pm.PL
>> +++ b/ext/Errno/Errno_pm.PL
>> @@ -142,10 +142,15 @@ sub get_files {
>> $Config{gccversion} !~ /intel/i
>> # might be using, say, Intel's icc
>> ) {
>> + # General cross-compiling use, cross-compiler in $SYSROOT
>> + my $sysroot = `$Config{cc} -print-sysroot` || '';
>> + chomp($sysroot);
>> +
>
> I see that the context happens to get a bit to snipped. The above is only
> run on Linux, and only for a real gcc. (Not icc)

Oops yes, silly diff. This is the rest of the context:

} elsif ($^O eq 'linux' &&
$Config{gccversion} ne '' && $Config{gccversion} !~ /intel/i
# might be using, say, Intel's icc
) {

So we only run it on linux and for gcc. (Maybe others later if working
and necessary?)

> Some C compilers are special. If I run this on AIX
>
> perl -e 'print `cc -print-sysroot` || "bother!\n"'
>
> it helpfully drops me into the pager, to show me the cc man page.
> I don't think that gcc has ever been that special.

Purty, Should avoid that then :)

>> +# Local variables:
>> +# c-indentation-style: bsd
>> +# c-basic-offset: 4
>> +# indent-tabs-mode: t
>
> The new black is indent-tabs-mode: nil
>
>> +# End:
>> +#
>> +# ex: set ts=8 sts=4 sw=4 noet:
>> +#
>> +

I stole this from a random .c file, I think it was av.c (this is still on
my oldish 5.15 branch).


> and hence (I think) et:
>
> I'm not sure where that needs to be documented, as it doesn't seem to be yet.
>

Happy to do so if anyone has ideas where and we can figure out a sane set.

Jess

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.