编译 NGINX 时 libpcre 抛出“创建共享对象时无法使用 .rodata”错误

Kat*_*tai 2 pcre compiler-errors nginx ubuntu-16.04

我正在尝试使用以下说明在 Ubuntu 16.04.3 LTS 上编译 NGINX:

https://www.vultr.com/docs/how-to-compile-nginx-from-source-on-ubuntu-16-04

nginx-1.13.1我尝试使用nginx-1.13.8(mainline)来代替,但在 期间make,我遇到了库错误pcre

...
objs/src/stream/ngx_stream_ssl_preread_module.o \
objs/ngx_modules.o \
-Wl,-Bsymbolic-functions -fPIC -pie -Wl,-z,relro -Wl,-z,now -ldl -lpthread -lpthread -lcrypt ../pcre-8.40/.libs/libpcre.a ../openssl-1.1.0f/.openssl/lib/libssl.a ../openssl-1.1.0f/.openssl/lib/libcrypto.a -ldl ../zlib-1.2.11/libz.a \
-Wl,-E
/usr/bin/ld: ../pcre-8.40/.libs/libpcre.a(libpcre_la-pcre_compile.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
../pcre-8.40/.libs/libpcre.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
objs/Makefile:328: recipe for target 'objs/nginx' failed
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory '/home/user1/nginx-1.13.8'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
Run Code Online (Sandbox Code Playgroud)

即使尝试遵循说明并更改:(-fPIE)

--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now'
Run Code Online (Sandbox Code Playgroud)

至:(-fPIC)

--with-cc-opt='-g -O2 -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIC -pie -Wl,-z,relro -Wl,-z,now'
Run Code Online (Sandbox Code Playgroud)

错误仍然存​​在。我该如何解决这个问题?理想情况下只改变./configure参数?到目前为止,该系统是全新设置。

小智 5

尝试在 nginx 中包含此配置选项:

--with-pcre-opt='-g -Ofast -fPIC -m64 -march=native -fstack-protector-strong -D_FORTIFY_SOURCE=2' \
--with-zlib-opt='-g -Ofast -fPIC -m64 -march=native -fstack-protector-strong -D_FORTIFY_SOURCE=2' \
Run Code Online (Sandbox Code Playgroud)

我刚刚成功地使用这个附加选项安装了 nginx。