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

Impossible to detect perl CFLAGS and LDFLAGS for cross-compilation of plugins #14030

Open
p5pRT opened this issue Aug 17, 2014 · 1 comment
Open

Comments

@p5pRT
Copy link

p5pRT commented Aug 17, 2014

Migrated from rt.perl.org#122550 (status was 'new')

Searchable as RT122550$

@p5pRT
Copy link
Author

p5pRT commented Aug 17, 2014

From maillist-perl@barfooze.de

Created by maillist-perl@barfooze.de

due to lack of pkg-config files, it's impossible to find out the
right CFLAGS and LDFLAGS to add when trying to cross-compile software
that uses perl plugins and intends to link against libperl.

after several hours of searching the documentation/web, the only
vendor-provided way to query the required flags I found is​:

perl -MExtUtils​::Embed -e ccopts
perl -MExtUtils​::Embed -e ldopts

however those can only be used for the host installation.
for a cross-compiled perl, the target perl binary cannot even be
executed on the host.
By invoking the host perl with those flags, cross-compilation will
break trying to include host headers and libraries which are typically
built for a different architecture.
Since libperl.a/.so reside in a customized subdir in /var or /lib,
there's no canonical path to add so -lperl could be found.

Suggested fix​:
either provide a pkg-config (.pc) together with perl, installed into
the standard pkg-config path; or
create a symlink of libperl.a and the directory containing perl.h in the
canonical lib and include dirs.
so $prefix/lib/libperl.a -> $prefix/lib/perl5/core_perl/CORE/libperl.a
and $prefix/include/perl -> $prefix/lib/perl5/core_perl/CORE
(note that the exact path lib/perl5/core_perl/CORE/ depends on user-chosen
settings during perl compilation.)

But TBH perl should just supply a .pc file like anyone else does.
the pkg-config format is well-documented, understood, and widely supported.
there are even several available implementation, for example the BSD-
licensed "pkgconf". pkgconf and pkg-config support cross-compilation
out of the box using the PKG_CONFIG_SYSROOT_DIR environment variable.

Perl Info

Flags:
     category=library
     severity=high

Site configuration information for perl 5.16.3:

Configured by root at Wed Nov  6 14:51:20 UTC 2013.

Summary of my perl5 (revision 5 version 16 subversion 3) configuration:

   Platform:
     osname=linux, osvers=3.11.6, archname=x86_64-linux
     uname='linux sabotage 3.11.6 #1 smp sun oct 27 00:36:15 utc 2013 
x86_64 gnulinux '
     config_args='-des -Accflags=-D_GNU_SOURCE -D_BSD_SOURCE -fPIC 
-fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables 
-fno-asynchronous-unwind-tables -Wa,--noexecstack -ftree-dce 
-Aldflags=-s -Wl,--gc-sections -Wl,-z,relro,-z,now -Dprefix=/ 
-Dvendorprefix=/ -Dinstallprefix= -Dprivlib=//lib/perl5/core_perl 
-Darchlib=//lib/perl5/core_perl -Dsitelib=//lib/perl5/site_perl 
-Dsitearch=//lib/perl5/site_perl -Dvendorlib=//lib/perl5/vendor_perl 
-Dvendorarch=//lib/perl5/vendor_perl -Dscriptdir=//bin 
-Dsitescript=//bin -Dvendorscript=//bin -Dinc_version_list=none 
-Dman1dir=//share/man/man1perl -Dman1ext=1perl 
-Dman3dir=//share/man/man3perl -Dman3ext=3perl'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-D_GNU_SOURCE -D_BSD_SOURCE -fPIC 
-fdata-sections -ffunction-sections -Os -g0 -fno-unwind-tables 
-fno-asynchronous-unwind-tables -Wa,--noexecstack -ftree-dce 
-fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-D_GNU_SOURCE -D_BSD_SOURCE -fPIC -fdata-sections 
-ffunction-sections -Os -g0 -fno-unwind-tables 
-fno-asynchronous-unwind-tables -Wa,--noexecstack -ftree-dce 
-fno-strict-aliasing -pipe'
     ccversion='', gccversion='4.7.3', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -s -Wl,--gc-sections -Wl,-z,relro,-z,now'
     libpth=/lib /usr/lib
     libs=-lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lpthread
     perllibs=-ldl -lm -lcrypt -lutil -lc -lpthread
     libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC', lddlflags='-shared -O2'

Locally applied patches:



@INC for perl 5.16.3:
     //lib/perl5/site_perl
     //lib/perl5/vendor_perl
     //lib/perl5/core_perl
     .


Environment for perl 5.16.3:
     HOME=/home/js
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/local/bin:/bin
     PERL_BADLANG (unset)
     SHELL=/bin/bash

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

2 participants