I'm trying to build nginx packages from a deb package source (from the popular, semi-official nginx mainline PPA) but linked to an openssl fork that contains ChaCha20 and Poly1305 additions.

I configured openssl with ./config no-ssl2 no-ssl3 shared -fPIC (I also set CFLAGS="-fPIC"), which worked and built successfully, and I can see -fPIC appearing in all the compilation steps during the build. When I build the nginx package with dpkg-buildpackage -b pointing at it (I edited auto/options and set OPENSSL=/home/admin/openssl), I get this error:

objs/ngx_modules.o \
-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -ldl -lpthread -lpthread -lcrypt -lpam -lexpat -lpcre /root/openssl/.openssl/lib/libssl.a 
/home/admin/openssl/.openssl/lib/libcrypto.a -ldl -lz -lxml2 -lxslt -lexslt -lgd -lGeoIP \
-Wl,-E /usr/bin/ld: /home/admin/openssl/.openssl/lib/libssl.a(s23_meth.o): 
relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/home/admin/openssl/.openssl/lib/libssl.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Any idea what I'm doing wrong, since I did build it with -fPIC?


I managed to make this work. It turns out that when building nginx this way, it does not use the pre-built openssl libraries, but compiles them anew, and at this point it's missing the configure options that I'd provided in the separate build. I spotted an OPENSSL_OPT property in the auto/options file. So the options I set in there were:

OPENSSL_OPT="no-ssl2 no-ssl3 -fPIC"

With those set, the compile completed successfully, and I was able to install the resulting packages.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.