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

Build issues w/Bazel on macOS

Open sgammon opened this issue 5 years ago • 8 comments

Hello esteemed Pagespeed authors,

I am having trouble building the Envoy targets via Bazel on macOS. See below for the error. My (naive) guess would be a compiler difference between macOS and Linux, but any help or insight would be much appreciated.

macOS Version: 10.15.6 (19G73) Code revision: master at the time of filing (82f7f34a2)

envoy/config/core/v3/proxy_protocol.proto: warning: Import validate/validate.proto but not used.
envoy/config/core/v3/substitution_format_string.proto: warning: Import udpa/annotations/status.proto but not used.
envoy/config/core/v3/substitution_format_string.proto: warning: Import validate/validate.proto but not used.
INFO: From CcCmakeMakeRule external/envoy/bazel/foreign_cc/ares/include:

ERROR: /Volumes/KICKSTART/incubator-pagespeed-mod/pagespeed/kernel/html/BUILD:16:11: C++ compilation of rule '//pagespeed/kernel/html:html' failed (Exit 1) wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 122 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
pagespeed/kernel/html/html_name.gperf:98:20: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
gperf_case_memcmp (register const char *s1, register const char *s2, register unsigned int n)
                   ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:98:45: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
gperf_case_memcmp (register const char *s1, register const char *s2, register unsigned int n)
                                            ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:98:70: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
gperf_case_memcmp (register const char *s1, register const char *s2, register unsigned int n)
                                                                     ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:124:22: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
KeywordMapper::hash (register const char *str, register unsigned int len)
                     ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:124:48: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
KeywordMapper::hash (register const char *str, register unsigned int len)
                                               ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:155:3: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  register unsigned int hval = len;
  ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:225:24: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
KeywordMapper::Lookup (register const char *str, register unsigned int len)
                       ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:225:50: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
KeywordMapper::Lookup (register const char *str, register unsigned int len)
                                                 ^~~~~~~~~
pagespeed/kernel/html/html_name.gperf:234:13: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
            register const char *s = kHtmlNameTable[key].name;
            ^~~~~~~~~
9 errors generated.
Target //pagespeed/envoy:envoy failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 97.442s, Critical Path: 79.64s
INFO: 1147 processes: 1147 darwin-sandbox.
FAILED: Build did NOT complete successfully

sgammon avatar Aug 03 '20 08:08 sgammon

@oschaaf any ideas? i want to begin examining integration of the new Envoy code! :) perhaps i can provide an early test case.

sgammon avatar Aug 03 '20 08:08 sgammon

That would be awesome, but would it be possible to build on linux/ubuntu? I've been using 19.10 with clang-10. I don't expect any fundamental blockers for OSX, but I think getting the build to work end to end there is going to take some trial and error.

oschaaf avatar Aug 03 '20 08:08 oschaaf

(As I don't have powerful mac hardware, I anticipate iterations are going to take quite a while.. in this case it looks like building with something like bazel build --cxxopt=-Wno-register //pagespeed/envoy/...) might resolve; but I'm not sure what else we'll run into

oschaaf avatar Aug 03 '20 09:08 oschaaf

yeah, so I tried, and some of the BUILD files would have to be patched to ignore the register keyword usage in files generated by gperf. That resolves this particular build error, and things get quite far, but when we enter the build of apr and aprutil, things break again. I think this didn't work earlier too, but it should be fixable. There's also the <sys/prctl.h> which doesn't exist on OSX. All fixable, but I can't look into that right now as I have other priorities at the moment.

oschaaf avatar Aug 03 '20 09:08 oschaaf

fwiw, looking at the rest of the code, I suspect the issues above are actually all of it. Envoy itself builds fine on OSX, and modulo apr/apr-util/serf, the direct dependencies all seem to build OK.

oschaaf avatar Aug 03 '20 09:08 oschaaf

@oschaaf the flags you suggested got the build much further on my machine as well. however, i got stuck realizing there was only an ia32 set of headers for the third_party/{apr,aprutil}/gen includes.

is that something that can be generated for x64 on mac?

sgammon avatar Aug 04 '20 05:08 sgammon

I think that those apr headers may actually be OK for osx/64bit, but that we need a different set of defines (-DXXX flags) in the build options to make them work. I haven't done that before, it would require some looking into to get it right. Having said that -- while it would be nice to have -- if it's a lot of work to get this right, another option would be to just disable stuff that needs this for OSX (or in general). We need apr/aprutil for Serf (to fetch inputs over http(s)), and for the memcached client.

  • We might be able to depend on the PoC Envoy fetcher soon (which will bring asynchronous http1/http2/http3 fetching)
  • We'd need a replacement for the memcached client though to be able to drop the dependencies, but I think that's not too hard, and we may be able to offer a good alternative based on plain http caching as a stock option.

These things would need to be discussed broader first, but I thought it would be good to mention them here

oschaaf avatar Aug 04 '20 08:08 oschaaf

One more note on apr/aprutil/serf: it might be worth looking at what happened on branch 36 with respect to building these, as that had the old build system still going (gyp). For example https://github.com/apache/incubator-pagespeed-mod/blob/36/third_party/apr/apr.gyp has stuff like:

              ['OS=="mac"', {
                'defines': [
                  'HAVE_CONFIG_H',
                  'DARWIN',
                  'SIGPROCMASK_SETS_THREAD_MASK',
                ]}],

However, a word of warning there is warranted too: as far as I know, nobody was using OSX to build the project, so I really have no idea if this is correct and / or all of it.

oschaaf avatar Aug 04 '20 14:08 oschaaf