Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

bazel build / psol #2084

Open
eilandert opened this issue Oct 18, 2021 · 7 comments
Open

bazel build / psol #2084

eilandert opened this issue Oct 18, 2021 · 7 comments

Comments

@eilandert
Copy link

eilandert commented Oct 18, 2021

@oschaaf or whoever knows how to do this ... :-)

First, when I build with bazel I need to add #include <cstdarg> to pagespeed/kernel/base/string.h or else bazel build will fail.

When I build with bazel I get a pagespeed_automatic.a which is 3mb big and not recognized by nginx configure. Is this size normal?

I tried a lot of things, I ended up with the following:

cd /usr/src/master
bazel build -c opt //pagespeed/automatic:automatic
cd /usr/src/master/pagespeed/automatic
ADIR="/usr/src/master/bazel-bin"
ALIST=$(find -L $ADIR -name "*.a" | grep -v main | grep -v copy | sed -e s/"^\."/"\/root"/g | xargs echo)

echo "merging libs"
./merge_libraries.sh ~/pagespeed_automatic.a.dirty $ALIST > merge.log
./rename_c_symbols.sh ~/pagespeed_automatic.a.dirty ~/pagespeed_automatic.a > symbol-rename.log
cd /usr/src/master
mkdir -p psol/include

if [ "$(uname -m)" = x86_64 ]; then
  bit_size_name=x64
else
  bit_size_name=ia32
fi

bindir="psol/lib/Release/linux/$bit_size_name"
mkdir -p "$bindir"
echo Copying files to psol directory...
cp -f ~/pagespeed_automatic.a $bindir/

rsync -arz "." "psol/include/" --prune-empty-dirs \
  --exclude=".svn" \
  --exclude=".git" \
  --include='*.h' \
  --include='*/' \
  --include="apr_thread_compatible_pool.cc" \
  --include="serf_url_async_fetcher.cc" \
  --include="apr_mem_cache.cc" \
  --include="key_value_codec.cc" \
  --include="apr_memcache2.c" \
  --include="loopback_route_fetcher.cc" \
  --include="add_headers_fetcher.cc" \
  --include="console_css_out.cc" \
  --include="console_out.cc" \
  --include="dense_hash_map" \
  --include="dense_hash_set" \
  --include="sparse_hash_map" \
  --include="sparse_hash_set" \
  --include="sparsetable" \
  --include="mod_pagespeed_console_out.cc" \
  --include="mod_pagespeed_console_css_out.cc" \
  --include="mod_pagespeed_console_html_out.cc" \
  --exclude='*'

cd /usr/src/master
tar czf /usr/src/psol.tar.gz psol

Any idea's or pointers?

@eilandert eilandert changed the title bazel build bazel build / psol Oct 18, 2021
@jmarantz
Copy link
Contributor

What do you need to add that #include into?

pagespeed_automatic.a is an intermediate library which can be used to build the Apache or nginx versions.

@eilandert
Copy link
Author

eilandert commented Oct 18, 2021

What do you need to add that #include into?

pagespeed_automatic.a is an intermediate library which can be used to build the Apache or nginx versions.

Sorry, there was a part github was not showing. updated my post. I need to add #include <cstdarg> in pagespeed/kernel/base/string.h or I get build errors about va_copy

My goal is to build a working PSOL from the master tree with bazel

@oschaaf
Copy link
Member

oschaaf commented Oct 18, 2021

I don't think I ever really got to producing/testing a standalone pagespeed_automatic.a.

Checking I did find this script, but unfortunately I left no context or notes:
https://github.com/apache/incubator-pagespeed-mod/blob/master/pagespeed/automatic/bazel_merge.sh

At a glance this script doesn't seem to be that different from what you are doing above (in fact it does less it seems) .. so I am pessimistic that it will produce a better pagespeed_automatic.a.

I do remember that at the time I was hoping for an a NGINX version that would support bazel builds. Because then
we could probably add that and this repo as native dependencies in ngx_pagespeed. https://github.com/S8Cloud/nginx-bazel is an example of that but it seems the effort stalled and it no longer gets any updates.

@eilandert
Copy link
Author

eilandert commented Oct 18, 2021

@oschaaf
Does that mean we are doomed to use the latest-stable tag?

I am trying to cook some things up with docker ( https://github.com/eilandert/psol-bazel ) but right now I get some 403 errors on some bazel stuff so I have to delay my attempts...

And yes, if I can build this I will try to use it with nginx/ngx_pagespeed ;-)

@oschaaf
Copy link
Member

oschaaf commented Oct 18, 2021

I wouldn't say doomed.. but it will require some effort to get ngx_pagespeed to work with the bleeding edge / bazel build system. The path of least resistance is probably producing a working pagespeed_automatic.a plus a set of headers, like you are currently attempting.

@eilandert
Copy link
Author

I am stuck now at
src/incubator-pagespeed-ngx/psol/include/base/logging.h:22:10: fatal error: glog/logging.h: No such file or directory

Will investigate later

@Lofesa
Copy link
Contributor

Lofesa commented Oct 20, 2021

@eilandert
Maybe is the same issue related here:
#2069 (comment)

"File "base/logging.h" contains "include glog/logging.h"
I had error about "glog" until I've added path to "glog/logging.h" to list of "include"-paths for CC-command in ngx/config:$pagespeed_include"

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

No branches or pull requests

4 participants