google / zetasql

ZetaSQL - Analyzer Framework for SQL
Apache License 2.0
2.28k stars 214 forks source link

Can't build ZetaSQL #107

Open yiannis-had opened 2 years ago

yiannis-had commented 2 years ago

I tried building it locally on MacOS (cloning the repo, installing bazelisk, and building) but that failed.

Then I tried building it using a Dockerfile, but that fails too. Does anyone have a working Dockerfile for this?

Dockerfile used:

FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
  && apt-get install -y curl gnupg \
  && echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
  && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \
  && apt-get update \
  && apt-get install -y \
    bazel-4.0.0 \
    g++ \
    git \
    make \
    openjdk-8-jdk-headless \
    python \
    python3-distutils \
    tzdata \
  && apt-get autoremove -y \
  && apt-get clean -y \
  && rm -rf /var/lib/apt/lists/* \
  && ln -s /usr/bin/bazel-4.0.0 /usr/bin/bazel

RUN git clone https://github.com/google/zetasql.git /zetasql \
  && cd /zetasql \
  && bazel build ...

Log output from cloning and building: https://pastebin.com/zhedaggZ

matthewcbrown commented 2 years ago

Here is the list we use internally (might have some extra stuff need for our test environment)

But, notice, we use g++-8, which is not the default for 18.04

apt-get -qq install pkg-config zip g++-8 gcc-8 zlib1g-dev unzip python wget openjdk-8-jdk git tzdata

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8

Do you have some more details on what failed in MacOS?

yiannis-had commented 2 years ago

Hi, thanks for getting back to me.

This is the output from trying to build on MacOS: https://pastebin.com/KjsLC8SV Seems like a C++ compiler error again. Apparently, MacOS uses clang instead of g++, so not sure which clang version works best. Is there a way to find out without trial and error?

Regarding the Dockerfile, it's still failing to build with g++-8 (although it fails later on in the build phase): https://pastebin.com/0ssQ5uLX

matthewcbrown commented 2 years ago

Can you build with --config=g++ for linux and --config=clang

this shouldn't really affect the build, but will signifantly reduce the log spam.

the ubuntu build looks like it crashed the compiler, which I've never seen before, or possibly it was killed by some external signal, is it possible docker ran out of time/memory/disk space?

We currently test the mac builds on catalina with ( I think) Xcode Version 12.4.

The main requirement for a c++ compiler is support for c++17, in theory it should work on any compiler with that support, but we've only really tested with a couple configurations.

yiannis-had commented 2 years ago

There is no g++ option in the .bazelrc file so I added build:g++ --cxxopt=-fpermissive.

My C++ knowledge is very limited and I've only learned about Bazel last week so I don't know how most of the things work in this space or this project.

I think you were spot on about the docker resources. We are using colima and I had left the default options on (2 CPUs, 2GiB memory and 60GiB disk). I've increased the resources to 6 CPUs, 20GiB memory and 100GiB disk and it seems to have failed due to certificate errors? https://pastebin.com/HUrgjxe9

When using --config=clang on my Macbook, I get very similar logs to building without the config option: https://pastebin.com/jYWuwvEu Why does it mention C99 close to the end?