﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
859	-lpcre should preceed -lpthread in objs/Makefile	sinner-@…		"Hi nginx team,

Firstly, thanks very much for the awesome webserver software!

I was compiling nginx 1.99 from source today using Debian 8 (stable/jessie) and the following configure options:

./configure \
  --with-cpu-opt=amd64 \
  --with-ld-opt=""-static"" \
  --with-http_stub_status_module \
  --with-http_gzip_static_module \
  --with-file-aio \
  --with-pcre \
  --with-cc-opt=""-O2 -static -static-libgcc -fstack-protector-all --param ssp-buffer-size=4 -ftrapv -Wl,-z,relro,-z,now -D_FORTIFY_SOURCE=2"" \
  --without-http_charset_module \
  --without-http_ssi_module \
  --without-http_userid_module \
  --without-http_auth_basic_module \
  --without-http_autoindex_module \
  --without-http_geo_module \
  --without-http_map_module \
  --without-http_split_clients_module \
  --without-http_referer_module \
  --without-http_proxy_module \
  --without-http_uwsgi_module \
  --without-http_scgi_module \
  --without-http_memcached_module \
  --without-http_empty_gif_module \
  --without-http_browser_module \
  --without-http_upstream_ip_hash_module \
  --without-http_upstream_least_conn_module \
  --without-http_upstream_keepalive_module \
  --without-mail_pop3_module \
  --without-mail_imap_module \
  --without-mail_smtp_module

and during the compile I got this error:

/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_free_exec':
(.text+0x66c): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `_pcre_jit_compile':
(.text+0x24d26): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `_pcre_jit_compile':
(.text+0x24e19): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `_pcre_jit_compile':
(.text+0x25854): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `_pcre_jit_compile':
(.text+0x25a89): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `pcre_jit_free_unused_memory':
(.text+0x262a9): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_free_exec':
(.text+0x6d4): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `pcre_jit_free_unused_memory':
(.text+0x26319): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame_info_bases':
(.text+0x16f7): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame_info':
(.text+0x1792): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame':
(.text+0x1834): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame_info_table_bases':
(.text+0x18bb): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__deregister_frame_info_bases':
(.text+0x195e): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__deregister_frame_info_bases':
(.text+0x19f8): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `_Unwind_Find_FDE':
(.text+0x1ac6): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `_Unwind_Find_FDE':
(.text+0x1b16): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `_Unwind_Find_FDE':
(.text+0x1c00): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame_info_bases':
(.text+0x1716): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame_info':
(.text+0x17b1): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o): In function `__register_frame':
(.text+0x1858): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc_eh.a(unwind-dw2-fde-dip.o):(.text+0x18da): more undefined references to `pthread_mutex_unlock' follow
collect2: error: ld returned 1 exit status
objs/Makefile:198: recipe for target 'objs/nginx' failed
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory '/root/hidden-nginx/nginx-1.9.9'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

I googled this error and it seemed to have something to do with the precedence of -lpthread and -lpcre in the Makefile. 

So just to test, I changed objs/Makefile line 294 from:

-static -lpthread -lpcre -lz

to:

-static -lpcre -lpthread -lz

and the compilation worked.

Here is an example mailing list post discussing same issue for a different software package:

https://mail.haskell.org/pipermail/ghc-devs/2013-January/000146.html

Thanks."	defect	closed	minor		nginx-core	1.9.x	wontfix			Linux hidden 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6 (2015-11-09) x86_64 GNU/Linux	nginx version: nginx/1.9.9
