编译 Perl 5.12.1 (RHEL 5.5) 时出错

tel*_*ium 3 redhat perl

我正在尝试在 Red Hat Enterprise Linux 5.5 上的主目录中编译 Perl 5.12.1。但是,当我尝试制作时,最终收到以下错误:

    Making IO (all)
make[1]: Entering directory `/users/rmi1/build/perl-5.12.0/dist/IO'
make[1]: Leaving directory `/users/rmi1/build/perl-5.12.0/dist/IO'
Making all in dist/IO
 make all PERL_CORE=1 LIBPERL_A=libperl.a LINKTYPE=dynamic
make[1]: Entering directory `/users/rmi1/build/perl-5.12.0/dist/IO'
cc -c   -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"1.25_02\" -DXS_VERSION=\"1.25_02\" -fPIC "-I../.."   IO.c
IO.xs: In function ‘XS_IO__Poll__poll’:
IO.xs:249: error: invalid application of ‘sizeof’ to incomplete type ‘struct pollfd’ 
IO.xs:253: error: invalid use of undefined type ‘struct pollfd’
IO.xs:253: error: dereferencing pointer to incomplete type
IO.xs:255: error: invalid use of undefined type ‘struct pollfd’
IO.xs:255: error: dereferencing pointer to incomplete type
IO.xs:257: error: invalid use of undefined type ‘struct pollfd’
IO.xs:257: error: dereferencing pointer to incomplete type
IO.xs:261: error: invalid use of undefined type ‘struct pollfd’
IO.xs:261: error: dereferencing pointer to incomplete type
IO.xs:262: error: invalid use of undefined type ‘struct pollfd’
IO.xs:262: error: dereferencing pointer to incomplete type
make[1]: *** [IO.o] Error 1
make[1]: Leaving directory `/users/rmi1/build/perl-5.12.0/dist/IO'
Unsuccessful make(dist/IO): code=512 at make_ext.pl line 449.
make: *** [lib/auto/IO/IO.so] Error 2
Run Code Online (Sandbox Code Playgroud)

什么可能导致这种情况?

小智 8

我刚刚遇到了同样的问题并找到了根本原因:C_INCLUDE_PATH环境变量。我的碰巧设置如下:

% printenv C_INCLUDE_PATH
C_INCLUDE_PATH=/home/me/REDACTED/include:
Run Code Online (Sandbox Code Playgroud)

这来自某个地方的登录脚本,它正在做类似的事情

export C_INCLUDE_PATH=$HOME/REDACTED/include:$C_INCLUDE_PATH
Run Code Online (Sandbox Code Playgroud)

在设置我的环境时。乍一看,这看起来是正确的;不幸的foo:是,foo:.在这种情况下,情况似乎与等效——也就是说,该两项以冒号分隔的列表中的空字符串似乎被隐式地视为与.. 这有效地将当前目录添加到系统包含路径,这使得#include <poll.h>做同样的事情#include "poll.h",这是不好的。

在 Perl 的情况下,恶意包含路径导致 Perlpoll.h包含自身而不是/usr/include/poll.h. 由于 Perlpoll.h有防止多重包含的机制,第二个包含无声无息地执行任何操作,您最终什么都不做poll.h,这很快导致我们都看到的编译器错误。这也解释了为什么您的补丁使问题消失:./sys/poll.h构建目录中没有,因此编译器/usr/include/sys/poll.h最终会找到,这最终恰好是您想要的。

我的解决方案是摆脱C_INCLUDE_PATH. 就我而言,我发现脚本设置不正确并修复了它,以便它明确检查前一个C_INCLUDE_PATH为空的情况,而不是在这种情况下添加冒号。当然,作为一种快速的一次性修复,我也可以手动运行export C_INCLUDE_PATH=/home/me/REDACTED/includeunset C_INCLUDE_PATH在构建 Perl 之前运行。