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

Ubuntu test environment flag incompatibilities #1

Open
Lewiscowles1986 opened this issue Dec 29, 2016 · 2 comments
Open

Ubuntu test environment flag incompatibilities #1

Lewiscowles1986 opened this issue Dec 29, 2016 · 2 comments

Comments

@Lewiscowles1986
Copy link

Ubuntu Xenial seems to compile with fPIE instead of fPIC which AFAIK is stopping this (or any shared module) compiling.

sudo apt install -y nginx-full
nginx -V
nginx version: nginx/1.10.0 (Ubuntu)
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled
configure arguments: --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' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/build/nginx-pzhfc2/nginx-1.10.0/debian/modules/nginx-auth-pam --add-module=/build/nginx-pzhfc2/nginx-1.10.0/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-pzhfc2/nginx-1.10.0/debian/modules/nginx-echo --add-module=/build/nginx-pzhfc2/nginx-1.10.0/debian/modules/nginx-upstream-fair --add-module=/build/nginx-pzhfc2/nginx-1.10.0/debian/modules/ngx_http_substitutions_filter_module

Build (needed to edit deps anyway...)

./configure --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' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --add-dynamic-module=/opt/nginx-http-json-log/
root@ubuntu-xenial:/opt/nginx-1.10.0# make modules
make -f objs/Makefile modules
make[1]: Entering directory '/opt/nginx-1.10.0'
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
	-o objs/addon/nginx-http-json-log/ngx_http_json_log_module.o \
	/opt/nginx-http-json-log//ngx_http_json_log_module.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
	-o objs/ngx_http_json_log_module_modules.o \
	objs/ngx_http_json_log_module_modules.c
cc -o objs/ngx_http_json_log_module.so \
objs/addon/nginx-http-json-log/ngx_http_json_log_module.o \
objs/ngx_http_json_log_module_modules.o \
-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -ljansson \
-shared
/usr/bin/ld: objs/addon/nginx-http-json-log/ngx_http_json_log_module.o: relocation R_X86_64_PC32 against symbol `ngx_http_json_log_module' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
objs/Makefile:1194: recipe for target 'objs/ngx_http_json_log_module.so' failed
make[1]: *** [objs/ngx_http_json_log_module.so] Error 1
make[1]: Leaving directory '/opt/nginx-1.10.0'
Makefile:14: recipe for target 'modules' failed
make: *** [modules] Error 2

Fix build

./configure --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 -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --add-dynamic-module=/opt/nginx-http-json-log/
make modules
make -f objs/Makefile modules
make[1]: Entering directory '/opt/nginx-1.10.0'
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
	-o objs/addon/nginx-http-json-log/ngx_http_json_log_module.o \
	/opt/nginx-http-json-log//ngx_http_json_log_module.c
cc -c -fPIC -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
	-o objs/ngx_http_json_log_module_modules.o \
	objs/ngx_http_json_log_module_modules.c
cc -o objs/ngx_http_json_log_module.so \
objs/addon/nginx-http-json-log/ngx_http_json_log_module.o \
objs/ngx_http_json_log_module_modules.o \
-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -ljansson \
-shared
make[1]: Leaving directory '/opt/nginx-1.10.0'

@Lewiscowles1986
Copy link
Author

In-case it is not clear this means the whole of nginx needs to be compiled so author repository is probably a better fit

@Lewiscowles1986
Copy link
Author

this seems to also cover apache/incubator-pagespeed-ngx#1135

Probably the -fPIC vs fPIE flag...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant