perlsolaris.html

来自「perl教程」· HTML 代码 · 共 769 行 · 第 1/3 页

HTML
769 行
字号
 $ grep /my/missing/file /var/sadm/install/contents</pre>
<p>This will display a line like this:</p>
<p>/usr/include/sys/errno.h f none 0644 root bin 7471 37605 956241356 SUNWhea</p>
<p>The last item listed (SUNWhea in this example) is the package you need.</p>
<p>
</p>
<h3><a name="avoid__usr_ucb_cc_">Avoid /usr/ucb/cc.</a></h3>
<p>You don't need to have /usr/ucb/ in your PATH to build perl.  If you
want /usr/ucb/ in your PATH anyway, make sure that /usr/ucb/ is NOT
in your PATH before the directory containing the right C compiler.</p>
<p>
</p>
<h3><a name="sun_s_c_compiler">Sun's C Compiler</a></h3>
<p>If you use Sun's C compiler, make sure the correct directory
(usually /opt/SUNWspro/bin/) is in your PATH (before /usr/ucb/).</p>
<p>
</p>
<h3><a name="gcc">GCC</a></h3>
<p>If you use gcc, make sure your installation is recent and complete.
perl versions since 5.6.0 build fine with gcc &gt; 2.8.1 on Solaris &gt;=
2.6.</p>
<p>You must Configure perl with</p>
<pre>
 $ sh Configure -Dcc=gcc</pre>
<p>If you don't, you may experience strange build errors.</p>
<p>If you have updated your Solaris version, you may also have to update
your gcc.  For example, if you are running Solaris 2.6 and your gcc is
installed under /usr/local, check in /usr/local/lib/gcc-lib and make
sure you have the appropriate directory, sparc-sun-solaris2.6/ or
i386-pc-solaris2.6/.  If gcc's directory is for a different version of
Solaris than you are running, then you will need to rebuild gcc for
your new version of Solaris.</p>
<p>You can get a precompiled version of gcc from
<a href="http://www.sunfreeware.com/">http://www.sunfreeware.com/</a> or <a href="http://www.blastwave.org/">http://www.blastwave.org/</a>. Make
sure you pick up the package for your Solaris release.</p>
<p>If you wish to use gcc to build add-on modules for use with the perl
shipped with Solaris, you should use the Solaris::PerlGcc module
which is available from CPAN.  The perl shipped with Solaris
is configured and built with the Sun compilers, and the compiler
configuration information stored in Config.pm is therefore only
relevant to the Sun compilers.  The Solaris:PerlGcc module contains a
replacement Config.pm that is correct for gcc - see the module for
details.</p>
<p>
</p>
<h3><a name="gnu_as_and_gnu_ld">GNU as and GNU ld</a></h3>
<p>The following information applies to gcc version 2.  Volunteers to
update it as appropropriate for gcc version 3 would be appreciated.</p>
<p>The versions of as and ld supplied with Solaris work fine for building
perl.  There is normally no need to install the GNU versions to
compile perl.</p>
<p>If you decide to ignore this advice and use the GNU versions anyway,
then be sure that they are relatively recent.  Versions newer than 2.7
are apparently new enough.  Older versions may have trouble with
dynamic loading.</p>
<p>If you wish to use GNU ld, then you need to pass it the -Wl,-E flag.
The hints/solaris_2.sh file tries to do this automatically by setting
the following Configure variables:</p>
<pre>
 ccdlflags=&quot;$ccdlflags -Wl,-E&quot;
 lddlflags=&quot;$lddlflags -Wl,-E -G&quot;</pre>
<p>However, over the years, changes in gcc, GNU ld, and Solaris ld have made
it difficult to automatically detect which ld ultimately gets called.
You may have to manually edit config.sh and add the -Wl,-E flags
yourself, or else run Configure interactively and add the flags at the
appropriate prompts.</p>
<p>If your gcc is configured to use GNU as and ld but you want to use the
Solaris ones instead to build perl, then you'll need to add
-B/usr/ccs/bin/ to the gcc command line.  One convenient way to do
that is with</p>
<pre>
 $ sh Configure -Dcc='gcc -B/usr/ccs/bin/'</pre>
<p>Note that the trailing slash is required.  This will result in some
harmless warnings as Configure is run:</p>
<pre>
 gcc: file path prefix `/usr/ccs/bin/' never used</pre>
<p>These messages may safely be ignored.
(Note that for a SunOS4 system, you must use -B/bin/ instead.)</p>
<p>Alternatively, you can use the GCC_EXEC_PREFIX environment variable to
ensure that Sun's as and ld are used.  Consult your gcc documentation
for further information on the -B option and the GCC_EXEC_PREFIX variable.</p>
<p>
</p>
<h3><a name="sun_and_gnu_make">Sun and GNU make</a></h3>
<p>The make under /usr/ccs/bin works fine for building perl.  If you
have the Sun C compilers, you will also have a parallel version of
make (dmake).  This works fine to build perl, but can sometimes cause
problems when running 'make test' due to underspecified dependencies
between the different test harness files.  The same problem can also
affect the building of some add-on modules, so in those cases either
specify '-m serial' on the dmake command line, or use
/usr/ccs/bin/make instead.  If you wish to use GNU make, be sure that
the set-group-id bit is not set.  If it is, then arrange your PATH so
that /usr/ccs/bin/make is before GNU make or else have the system
administrator disable the set-group-id bit on GNU make.</p>
<p>
</p>
<h3><a name="avoid_libucb_">Avoid libucb.</a></h3>
<p>Solaris provides some BSD-compatibility functions in /usr/ucblib/libucb.a.
Perl will not build and run correctly if linked against -lucb since it
contains routines that are incompatible with the standard Solaris libc.
Normally this is not a problem since the solaris hints file prevents
Configure from even looking in /usr/ucblib for libraries, and also
explicitly omits -lucb.</p>
<p>
</p>
<h2><a name="environment_for_compiling_perl_on_solaris">Environment for Compiling perl on Solaris</a></h2>
<p>
</p>
<h3><a name="path">PATH</a></h3>
<p>Make sure your PATH includes the compiler (/opt/SUNWspro/bin/ if you're
using Sun's compiler) as well as /usr/ccs/bin/ to pick up the other
development tools (such as make, ar, as, and ld).  Make sure your path
either doesn't include /usr/ucb or that it includes it after the
compiler and compiler tools and other standard Solaris directories.
You definitely don't want /usr/ucb/cc.</p>
<p>
</p>
<h3><a name="ld_library_path">LD_LIBRARY_PATH</a></h3>
<p>If you have the LD_LIBRARY_PATH environment variable set, be sure that
it does NOT include /lib or /usr/lib.  If you will be building
extensions that call third-party shared libraries (e.g. Berkeley DB)
then make sure that your LD_LIBRARY_PATH environment variable includes
the directory with that library (e.g. /usr/local/lib).</p>
<p>If you get an error message</p>
<pre>
 dlopen: stub interception failed</pre>
<p>it is probably because your LD_LIBRARY_PATH environment variable
includes a directory which is a symlink to /usr/lib (such as /lib).
The reason this causes a problem is quite subtle.  The file
libdl.so.1.0 actually *only* contains functions which generate 'stub
interception failed' errors!  The runtime linker intercepts links to
&quot;/usr/lib/libdl.so.1.0&quot; and links in internal implementations of those
functions instead.  [Thanks to Tim Bunce for this explanation.]</p>
<p>
</p>
<hr />
<h1><a name="run_configure_">RUN CONFIGURE.</a></h1>
<p>See the INSTALL file for general information regarding Configure.
Only Solaris-specific issues are discussed here.  Usually, the
defaults should be fine.</p>
<p>
</p>
<h2><a name="64bit_perl_on_solaris_">64-bit perl on Solaris.</a></h2>
<p>See the INSTALL file for general information regarding 64-bit compiles.
In general, the defaults should be fine for most people.</p>
<p>By default, perl-5.6.0 (or later) is compiled as a 32-bit application
with largefile and long-long support.</p>
<p>
</p>
<h3><a name="general_32bit_vs__64bit_issues_">General 32-bit vs. 64-bit issues.</a></h3>
<p>Solaris 7 and above will run in either 32 bit or 64 bit mode on SPARC
CPUs, via a reboot. You can build 64 bit apps whilst running 32 bit
mode and vice-versa. 32 bit apps will run under Solaris running in
either 32 or 64 bit mode.  64 bit apps require Solaris to be running
64 bit mode.</p>
<p>Existing 32 bit apps are properly known as LP32, i.e. Longs and
Pointers are 32 bit.  64-bit apps are more properly known as LP64.
The discriminating feature of a LP64 bit app is its ability to utilise a
64-bit address space.  It is perfectly possible to have a LP32 bit app
that supports both 64-bit integers (long long) and largefiles (&gt; 2GB),
and this is the default for perl-5.6.0.</p>
<p>For a more complete explanation of 64-bit issues, see the
&quot;Solaris 64-bit Developer's Guide&quot; at <a href="http://docs.sun.com/">http://docs.sun.com/</a></p>
<p>You can detect the OS mode using &quot;isainfo -v&quot;, e.g.</p>
<pre>
 $ isainfo -v   # Ultra 30 in 64 bit mode
 64-bit sparcv9 applications
 32-bit sparc applications</pre>
<p>By default, perl will be compiled as a 32-bit application.  Unless
you want to allocate more than ~ 4GB of memory inside perl, or unless
you need more than 255 open file descriptors, you probably don't need
perl to be a 64-bit app.</p>
<p>
</p>
<h3><a name="large_file_support">Large File Support</a></h3>
<p>For Solaris 2.6 and onwards, there are two different ways for 32-bit
applications to manipulate large files (files whose size is &gt; 2GByte).
(A 64-bit application automatically has largefile support built in
by default.)</p>
<p>First is the &quot;transitional compilation environment&quot;, described in
lfcompile64(5).  According to the man page,</p>
<pre>
 The transitional compilation  environment  exports  all  the
 explicit 64-bit functions (xxx64()) and types in addition to
 all the regular functions (xxx()) and types. Both xxx()  and
 xxx64()  functions  are  available to the program source.  A
 32-bit application must use the xxx64() functions in  order
 to  access  large  files.  See the lf64(5) manual page for a
 complete listing of the 64-bit transitional interfaces.</pre>
<p>The transitional compilation environment is obtained with the
following compiler and linker flags:</p>
<pre>
 getconf LFS64_CFLAGS        -D_LARGEFILE64_SOURCE
 getconf LFS64_LDFLAG        # nothing special needed
 getconf LFS64_LIBS          # nothing special needed</pre>
<p>Second is the &quot;large file compilation environment&quot;, described in
lfcompile(5).  According to the man page,</p>
<pre>
 Each interface named xxx() that needs to access 64-bit entities
 to  access  large  files maps to a xxx64() call in the
 resulting binary. All relevant data types are defined to  be
 of correct size (for example, off_t has a typedef definition
 for a 64-bit entity).</pre>
<pre>
 An application compiled in this environment is able  to  use
 the  xxx()  source interfaces to access both large and small
 files, rather than having to explicitly utilize the  transitional
 xxx64()  interface  calls to access large files.</pre>
<p>Two exceptions are <code>fseek()</code> and ftell().  32-bit applications should
use <code>fseeko(3C)</code> and ftello(3C).  These will get automatically mapped
to <code>fseeko64()</code> and ftello64().</p>
<p>The large file compilation environment is obtained with</p>
<pre>
 getconf LFS_CFLAGS      -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 getconf LFS_LDFLAGS     # nothing special needed
 getconf LFS_LIBS        # nothing special needed</pre>
<p>By default, perl uses the large file compilation environment and
relies on Solaris to do the underlying mapping of interfaces.</p>
<p>
</p>
<h3><a name="building_an_lp64_perl">Building an LP64 perl</a></h3>
<p>To compile a 64-bit application on an UltraSparc with a recent Sun Compiler,
you need to use the flag &quot;-xarch=v9&quot;.  <code>getconf(1)</code> will tell you this, e.g.</p>
<pre>
 $ getconf -a | grep v9
 XBS5_LP64_OFF64_CFLAGS:         -xarch=v9
 XBS5_LP64_OFF64_LDFLAGS:        -xarch=v9
 XBS5_LP64_OFF64_LINTFLAGS:      -xarch=v9
 XBS5_LPBIG_OFFBIG_CFLAGS:       -xarch=v9
 XBS5_LPBIG_OFFBIG_LDFLAGS:      -xarch=v9
 XBS5_LPBIG_OFFBIG_LINTFLAGS:    -xarch=v9
 _XBS5_LP64_OFF64_CFLAGS:        -xarch=v9
 _XBS5_LP64_OFF64_LDFLAGS:       -xarch=v9
 _XBS5_LP64_OFF64_LINTFLAGS:     -xarch=v9
 _XBS5_LPBIG_OFFBIG_CFLAGS:      -xarch=v9
 _XBS5_LPBIG_OFFBIG_LDFLAGS:     -xarch=v9
 _XBS5_LPBIG_OFFBIG_LINTFLAGS:   -xarch=v9</pre>
<p>This flag is supported in Sun WorkShop Compilers 5.0 and onwards
(now marketed under the name Forte) when used on Solaris 7 or later on
UltraSparc systems.</p>
<p>If you are using gcc, you would need to use -mcpu=v9 -m64 instead.  This
option is not yet supported as of gcc 2.95.2; from install/SPECIFIC
in that release:</p>
<pre>
 GCC version 2.95 is not able to compile code correctly for sparc64
 targets. Users of the Linux kernel, at least, can use the sparc32
 program to start up a new shell invocation with an environment that
 causes configure to recognize (via uname -a) the system as sparc-*-*
 instead.</pre>
<p>All this should be handled automatically by the hints file, if
requested.</p>
<p>
</p>
<h3><a name="long_doubles_">Long Doubles.</a></h3>
<p>As of 5.8.1, long doubles are working if you use the Sun compilers
(needed for additional math routines not included in libm).</p>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?