incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

Building on newer glibc (eg. Ubuntu 21.10 and above)

Open eilandert opened this issue 3 years ago • 17 comments

Please note that PSOL built on Ubuntu 20.04 (Focal) and earlier will not work on systems with newer glibc (for example ubuntu Impish and upcoming Ubuntu LTS Jammy.

It's fixable with: sed -i -r 's/sys_siglist[signum]/strsignal(signum)/g' third_party/apr/src/threadproc/unix/signals.c sed -i s/"pthread_mutex_consistent_np"/"pthread_mutex_consistent"/g third_party/apr/src/locks/unix/proc_mutex.c sed -i s/"define HAVE_PTHREAD_YIELD 1"/"define HAVE_PTHREAD_YIELD 0"/g third_party/apr/gen/arch/linux/x64/include/apr_private.h

But if you do that I doubt it will compile and/or work on systems with older glibc.

Just a heads up

eilandert avatar Dec 16 '21 00:12 eilandert

Hello eilandert,

I don't see this files in folder structure which you have mentioned - I do have incubator-pagespees-ngx-latest-stable/psol/third_party/apr/src but no threadproc and locks. There are only the following folders: include, random, test and none of them seems to include the files you mentioned.

The only one I have found is: sed -i s/"define HAVE_PTHREAD_YIELD 1"/"define HAVE_PTHREAD_YIELD 0"/g third_party/apr/gen/arch/linux/x64/include/apr_private.h

nemihome avatar Apr 09 '22 14:04 nemihome

Hello @nemihome, try the latest master, recursive. git clone --recursive https://github.com/apache/incubator-pagespeed-mod.git

additionally, I uploaded precompiled psol binaries here: http://www.tiredofit.nl/psol-jammy.tar.xz (available: psol-bionic.tar.gz psol-focal.tar.gz psol-jammy.tar.xz psol-trusty.tar.gz psol-xenial.tar.gz)

and additionally, I'm offering debian and ubuntu packages (including jammy) here: https://deb.myguard.nl/nginx-modules/ (there is also a docker, for impish and bullseye)

eilandert avatar Apr 09 '22 19:04 eilandert

Hello @eilandert,

thank you. I tried your repository. Well Nginx is working with pagespeed but that changes half of the ubuntu 22.04 software to non standard. I don't like that much because if there are problems showing up like e.g.

"Note that the deactivation of "ssh-rsa" signatures does not necessarily require cessation of use for RSA keys. In the SSH protocol, keys may be capable of signing using multiple algorithms. In particular, "ssh-rsa" keys are capable of signing using "rsa-sha2-256" (RSA/SHA256), "rsa-sha2-512" (RSA/SHA512) and "ssh-rsa" (RSA/SHA1). Only the last of these is being turned off by default."

There is always the question if this is resulting from changes like + openssl3 + other changes or standard (yeah, i have noticed later that openssl3 is a separate package). If something is not working I am not shure if this is standard or special because of all the listed package changes which are mentioned your homepage. That's the opposite idea of using a LTS version in my opinion. That's more like a rolling release.

Is there a way to get only the nginx part of your packages automatically?

All this updates are not on my list of things I would like to have (I really would prefer just nginx in the package):

The following packages will be upgraded:

  apache2 apache2-bin apache2-data apache2-utils libjemalloc2 liblmdb0
  libluajit-5.1-2 libluajit-5.1-common liblzf1 libpcre2-16-0 libpcre2-32-0
  libunbound8 lua-cjson myguard openssh-client openssh-server
  openssh-sftp-server postfix redis redis-server redis-tools ssh zstd

So I ended up with a lot more updates which I don't want with the full auto install package via apt:

apache2 
apache2-bin 
apache2-data 
apache2-utils 
libbrotli1 
libjemalloc2 
liblmdb0 
libluajit-5.1-2 
libluajit-5.1-common 
liblzf1
libpcre2-16-0 
libpcre2-32-0 
libpcre2-8-0 
libunbound8 
libzstd1 
lua-cjson 
myguard 
openssh-client 
openssh-server 
openssh-sftp-server 
postfix redis 
redis-server 
redis-tools 
ssh 
zstd

And there are further effects which may be a result of this particular updates not planned in 22.04: The following packages have unmet dependencies: libfido2-1 : Depends: libcbor0.6 (>= 0.5.0) but it is not installable E: Unable to correct problems, you have held broken packages.


I have done the following steps for now (folder /home/admin). .

Optional parts = italic (only needed for geopip2 module) curl -L https://github.com/leev/ngx_http_geoip2_module/archive/master.zip --output master.zip unzip master.zip

Maybe folder name have to be adapted to ngx_http_geoip2_module or just change the folder name below in options part of nginx.

I used the standard script:

bash <(curl -f -L -sS https://ngxpagespeed.com/install)\
     --nginx-version latest --dynamic-module

After PSOL is downloaded and extracted (there are stop points and several steps in this script). I have replaced the incubator-pagespeed-ngx-latest-stable/psol folder by your jammy-psol/psol folder version folder and compiled nginx with the following options:

--prefix=/usr/lib/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_geoip_module=dynamic --with-mail_ssl_module --with-stream_realip_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-stream=dynamic --with-http_perl_module --with-http_gunzip_module --with-http_gzip_static_module --add-dynamic-module=/home/admin/master/ngx_http_geoip2_module-master

That seems to be working so far.

nemihome avatar Apr 17 '22 10:04 nemihome

Hi, Thanks for your feedback. I have an ubuntu ppa on https://launchpad.net/~eilander/+archive/ubuntu/nginx which may be more suitable for your needs. On my own repository I need to make a NGINX-only tree, but have yet to figure out how to do that in a sane way. I will look into it sometime soon.

I am happy that my jammy-psol works for you and probably others

eilandert avatar Apr 18 '22 19:04 eilandert

My way of resolving this was to patch Pagespeed, compile it on the working version of glibc, and package the result as a debian package.

I have automated the process here: https://github.com/knyzorg/nginx-pagespeed

And host the resulting debian files both in the repo and on my personal server for public use.

vezaynk avatar Apr 18 '22 19:04 vezaynk

Hello @nemihome, try the latest master, recursive. git clone --recursive https://github.com/apache/incubator-pagespeed-mod.git

additionally, I uploaded precompiled psol binaries here: http://www.tiredofit.nl/psol-jammy.tar.xz (available: psol-bionic.tar.gz psol-focal.tar.gz psol-jammy.tar.xz psol-trusty.tar.gz psol-xenial.tar.gz)

and additionally, I'm offering debian and ubuntu packages (including jammy) here: https://deb.myguard.nl/nginx-modules/ (there is also a docker, for impish and bullseye)

any hope for quic https://blog.cloudflare.com/experiment-with-http-3-using-nginx-and-quiche/ ?

lavacano avatar May 27 '22 16:05 lavacano

@knyzorg I have tried that. This is working for me. Thanks.

I have tried to compile nginx in latest version (1.23.0) and I'm running into a new error. But I think this is more a general topic than pagespeed related but I'm not shure about that (I could reproduce that error on two ubuntu 22.04 systems):

`/home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc: In function ‘ngx_int_t net_instaweb::{anonymous}::ps_set_cache_control(ngx_http_request_t*, char*)’: /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:407:36: error: request for member ‘elts’ in ‘r->ngx_http_request_s::headers_out.ngx_http_headers_out_t::cache_control’, which is of pointer type ‘ngx_table_elt_t*’ {aka ‘ngx_table_elt_s*’} (maybe you meant to use ‘->’ ?) 407 | if (r->headers_out.cache_control.elts == NULL) { | ^~~~ /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:408:35: error: cannot convert ‘ngx_table_elt_t**’ {aka ‘ngx_table_elt_s**’} to ‘ngx_array_t*’ 408 | ngx_int_t rc = ngx_array_init(&r->headers_out.cache_control, r->pool, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | ngx_table_elt_t** {aka ngx_table_elt_s**} In file included from src/core/ngx_core.h:65, from src/http/ngx_http.h:13, from /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.h:33, from /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:26: src/core/ngx_array.h:32:29: note: initializing argument 1 of ‘ngx_int_t ngx_array_init(ngx_array_t*, ngx_pool_t*, ngx_uint_t, size_t)’ 32 | ngx_array_init(ngx_array_t array, ngx_pool_t pool, ngx_uint_t n, size_t size) | ~~~~~~~~~~~~~^~~~~ /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:415:22: error: cannot convert ‘ngx_table_elt_t’ {aka ‘ngx_table_elt_s**’} to ‘ngx_array_t*’ 415 | ngx_array_push(&r->headers_out.cache_control)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | ngx_table_elt_t** {aka ngx_table_elt_s**} In file included from src/core/ngx_core.h:65, from src/http/ngx_http.h:13, from /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.h:33, from /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:26: src/core/ngx_array.h:27:35: note: initializing argument 1 of ‘void* ngx_array_push(ngx_array_t*)’ 27 | void ngx_array_push(ngx_array_t a); | ~~~~~~~~~~~~~^ /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc: In function ‘bool net_instaweb::{anonymous}::ps_get_cache_control(ngx_http_request_t, GoogleString)’: /home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:439:74: error: request for member ‘elts’ in ‘r->ngx_http_request_s::headers_out.ngx_http_headers_out_t::cache_control’, which is of pointer type ‘ngx_table_elt_t*’ {aka ‘ngx_table_elt_s*’} (maybe you meant to use ‘->’ ?) 439 | cp = static_cast<ngx_table_elt_t**>(r->headers_out.cache_control.elts); | ^~~~

/home/admin/incubator-pagespeed-ngx-latest-stable/src/ngx_pagespeed.cc:444:59: error: request for member ‘nelts’ in ‘r->ngx_http_request_s::headers_out.ngx_http_headers_out_t::cache_control’, which is of pointer type ‘ngx_table_elt_t*’ {aka ‘ngx_table_elt_s*’} (maybe you meant to use ‘->’ ?) 444 | for (ngx_uint_t i = 0; i < r->headers_out.cache_control.nelts; i++) { | ^~~~~ make[1]: *** [objs/Makefile:1588: objs/addon/src/ngx_pagespeed.o] Fehler 1 make[1]: Verzeichnis „/home/admin/nginx-1.23.0“ wird verlassen make: *** [Makefile:10: build] Fehler 2 Error: Failure running 'make', exiting.`

Fount some similar error mssage here but in another module.

nemihome avatar Jul 09 '22 07:07 nemihome

On Debian11 I succeeded with 1.22.0 version: bash <(curl -f -L -sS https://ngxpagespeed.com/install) --nginx-version 1.22.0

Sadly, 1.23.1 end up with the errors that you posted above.

myvesta avatar Aug 25 '22 11:08 myvesta

I've just tested 1.22.0 under Ubuntu 22.04.1 using @eilandert's PSOL, and it seemed to work well. I do have a few other plugins as well besides PageSpeed, but the compilation finished without any issue, and nginx most certainly launched.

I haven't tested 1.23.1 yet (since @myvesta reported having problems with it...) but I might give it a try!

GwynethLlewelyn avatar Sep 05 '22 01:09 GwynethLlewelyn

Whew. After much sweating, I managed to get this working under 1.23.1 as well, under Ubuntu 22.04.1 LTS (jammy), together with all my other plugins.

Now it's time to do some testing :-)

GwynethLlewelyn avatar Sep 08 '22 20:09 GwynethLlewelyn

Whew. After much sweating, I managed to get this working under 1.23.1 as well, under Ubuntu 22.04.1 LTS (jammy), together with all my other plugins.

Now it's time to do some testing :-)

Did all go well? ;-)

eilandert avatar Sep 12 '22 20:09 eilandert

@GwynethLlewelyn

I am 22.04.1

And just try 1.23.1

and it results some error like

ngx_table_elt_t** {aka ngx_table_elt_s**}

make[1]: *** [objs/Makefile:1493: objs/addon/src/ngx_pagespeed.o] Error 1

May I know how can you fix it? Many thanks.

mactrash avatar Sep 24 '22 16:09 mactrash

@GwynethLlewelyn

For 1.22.0 how can you make it work?

I got the error as below

/usr/bin/ld: /root/incubator-pagespeed-ngx-latest-stable/psol/lib/Release/linux/x64/pagespeed_automatic.a(107.thread.o.o): in function pagespeed_ol_apr_thread_yield': thread.c:(.text.apr_thread_yield+0x1): undefined reference to pthread_yield' collect2: error: ld returned 1 exit status make[1]: *** [objs/Makefile:323: objs/nginx] Error 1 make[1]: Leaving directory '/root/nginx-1.22.0' make: *** [Makefile:10: build] Error 2 Error: Failure running 'make', exiting.

mactrash avatar Sep 24 '22 17:09 mactrash

I cooked some build instructions in https://github.com/apache/incubator-pagespeed-ngx/issues/1760

eilandert avatar Sep 28 '22 23:09 eilandert

@eilandert: it went remarkably well, thanks for your 'special' compilation!

@mactrash: In the meantime, I've focused on 1.23.1 and left 1.22.X (because, well, it had some issues with newer versions of other, non-PageSpeed-related modules that I needed). Are you sure you have used @eilandert's PSOL compilation? I'm just asking since you get the error precisely while linking with the PSOL libraries.

On the other hand, the error you got is related to the pthread library.

So...

  • What GCC version do you have? I'm using 11.2.0, which is the current one on Ubuntu 22.04, AFAIK.
  • Did you install the dev version of pthread? If not, sudo apt-get install libpthread-stubs0-dev(see also a thread on StackOverflow — it's ancient, but nevertheless relevant)
  • Can you check if you GCC/linker is, indeed, calling the correct option for linking with libpthread.a? Or maybe you are not using @eilandert's PSOL compilation after all? See #1760 — he's gone through all that trouble to get the only working PSOL compilation so far, and, AFAIK, there is no 'easy' alternative (for now), at least not until the PageSpeed core developers wake up to the reality of a newer glibc version (a quick search on that error of yours on Google links to GitHub: namely, to this very rep, issue #1759!)

I'll be posting some additional compilation instructions for those bold enough to try nginx with full HTTP/3 support and PageSpeed, but, alas, this will be a bit beyond the scope of this rep — I'll crosslink to the discussion elsewhere once I'm finished with those...

Note, however, that my own compilation is (obviously!) pretty much built upon @eilandert's instructions, and it wouldn't have worked without his PSOL compilation; the rest is mostly a few more hacks to get HTTP/3 support without breaking PageSpeed.

GwynethLlewelyn avatar Sep 29 '22 20:09 GwynethLlewelyn

@GwynethLlewelyn the pthread_yield error is directly linked to glibc, in my first post I changed HAVE_PTHREAD_YIELD from 1 to 0 when compiling the PSOL library, I remember clearly it did not work with PTHREAD_YIELD enabled.

I haven't had the time to check HTTP/3 support, I am still waiting for it to appear in NGINX Mainline ;-) But even then it will probably not work with standard OpenSSL3.0, so I need to package https://github.com/quictls/openssl/ or use BoringSSL (which also doesn't have package afaik) and didn't want to go there yet ;-) So I am curious for your build instructions for HTTP/3 ;-) (especially the parts of not breaking pagespeed)

eilandert avatar Sep 29 '22 21:09 eilandert

@GwynethLlewelyn

Note, however, that my own compilation is (obviously!) pretty much built upon @eilandert's instructions, and it wouldn't have worked without his PSOL compilation; the rest is mostly a few more hacks to get HTTP/3 support without breaking PageSpeed.

I'm wondering what hacks do you need to get HTTP/3 support in pagespeed? Do I need them too?

I have a full HTTP/3 build with NGINX-quic and OpenSSL3/quic running on production now and I have not encountered any issues so far.

It's in beta/testing phase, but as said, I'm running in production now without problems debian/ubuntu: http://edge.deb.myguard.nl:8888/apt/nginx-quic/ (this is my dev repo) docker: https://hub.docker.com/r/eilandert/nginx-quic

eilandert avatar Dec 20 '22 01:12 eilandert