各位好,

目前我在CentOS 8中尝试编译了最新版的openresty-1.17.8.1rc1及openresty-1.15.8.3版本,均会在 gmake 阶段出现错误,编译参数及错误信息如下:
系统是  CentOS Linux release 8.1.1911 (Core) ,已经升级到最新版本

-------------
编译openresty-1.15.8.3
编译参数./configure --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --w
ith-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.44 --with-openssl=../openssl-1.1.1d


/usr/bin/ld: /root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/../zlib-1.2.11/libz.a(trees.o): relocation R_X86_64_32S against hidden symbol `_length_code' can not be used when making a PIE object
/usr/bin/ld: /root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/../zlib-1.2.11/libz.a(zutil.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
gmake[2]: *** [objs/Makefile:495: objs/nginx] Error 1
gmake[2]: Leaving directory '/root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/build/nginx-1.15.8'
gmake[1]: *** [Makefile:8: build] Error 2
gmake[1]: Leaving directory '/root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/build/nginx-1.15.8'
gmake: *** [Makefile:9: all] Error 2

-------------------
编译 openresty-1.17.8.1rc1  with openssl-1.1.1e
编译参数 ./configure --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.44 --with-openssl=../openssl-1.1.1e

install libcrypto.pc -> /root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/../openssl-1.1.1e/.openssl/lib/pkgconfig/libcrypto.pc
install libssl.pc -> /root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/../openssl-1.1.1e/.openssl/lib/pkgconfig/libssl.pc
install openssl.pc -> /root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/../openssl-1.1.1e/.openssl/lib/pkgconfig/openssl.pc
gmake[3]: Leaving directory '/root/openresty-1.17.8.1rc1-1.1.1e/openssl-1.1.1e'
gmake[2]: Leaving directory '/root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/build/nginx-1.17.8'
gmake[1]: *** [Makefile:8: build] Error 2
gmake[1]: Leaving directory '/root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/build/nginx-1.17.8'
gmake: *** [Makefile:9: all] Error 2

-------------------

编译 openresty-1.17.8.1rc1 使用系统openssl
编译参数  ./configure --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module


gmake[2]: *** No rule to make target 'src/http/modules/perl/nginx.pm', needed by 'objs/src/http/modules/perl/Makefile'.  Stop.
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/build/nginx-1.17.8'
gmake[1]: *** [Makefile:8: build] Error 2
gmake[1]: Leaving directory '/root/openresty-1.17.8.1rc1-1.1.1e/openresty-1.17.8.1rc1/build/nginx-1.17.8'
gmake: *** [Makefile:9: all] Error 2


有哪位可以帮忙看看是哪里的问题?
不知道是不是  gmake[2]: *** No rule to make target 'src/http/modules/perl/nginx.pm', needed by 'objs/src/http/modules/perl/Makefile'.  Stop.  这个问题
如何解决呢?
谢谢


9 days later

askiter
编译openresty-1.15.8.3编译参数
./configure --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.44 --with-openssl=../openssl-1.1.1d
/usr/bin/ld: /root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/../zlib-1.2.11/libz.a(trees.o): relocation R_X86_64_32S against hidden symbol _length_code' can not be used when making a PIE object
/usr/bin/ld: /root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/../zlib-1.2.11/libz.a(zutil.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on outputcollect2: error: ld returned 1 exit status
gmake[2]: *** [objs/Makefile:495: objs/nginx] Error 1
gmake[2]: Leaving directory '/root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/build/nginx-1.15.8'gmake[1]: *** [Makefile:8: build] Error 2
gmake[1]: Leaving directory '/root/openresty-1.15.8.3-1.1.1d/openresty-1.15.8.3/build/nginx-1.15.8'
gmake: *** [Makefile:9: all] Error 2

这个问题我在本地也复现了,发现 pcre 和 zlib 都是静态编译的,目前我在看是哪里错误的引进了 -pie 选项

    6 days later

    编译openresty-1.15.8.3 时新增选项,使用 -fPIC 参数进行编译,自测编译成功

    --with-cc-opt="-fPIC"  \
    --with-pcre-conf-opt="--with-pic=yes" \
    --with-zlib-opt="-fPIC"

    编译参数全文:

    ./configure --with-pcre-jit --with-http_ssl_module --with-http_v2_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --w
    ith-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.44 --with-openssl=../openssl-1.1.1d \
    --with-cc-opt="-fPIC"  \
    --with-pcre-conf-opt="--with-pic=yes" \
    --with-zlib-opt="-fPIC"
    17 days later

    xiaocang 非常感谢,按照你上面的做法,openresty-1.15.8.3在CentOS8下面编译成功

    另外,同样的我也试了一下openresty-1.17.8.1rc1这个版本,是不行的,依然是报 nginx.pm 相关的错误

      Write a Reply...