google / zetasql

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

Can't build on linux/aarch64 #112

Open riordan opened 2 years ago

riordan commented 2 years ago

I'm one of those horrible M1 Mac users screwing up the buildchain for every open source projects. So let me begin by thanking you for abstracting macos/darwin builds so they're architecture independent. It would be great if we could do the same for Linux.

Things work fine in MacOS. It gets interesting when we involve Docker.

Containers can be built for multiple architectures (e.g. x86_64 & aarch64). Docker can run either architecture, though it prefers the native architecture of the host machine. So if an ARM/aarch64 mac tries to build zetasql inside a (local default) aarch64 container, it'll fail, as linux-specific builds are tied to:

"@bazel_tools//src/conditions:linux_x86_64"

While mac/darwin builds are configured to use:

"@bazel_tools//src/conditions:darwin" or "@platforms//os:macos"

It would be nice if linux builds could be configured independent of cpu architecture, or at least could select for linux_aarch64.

pgrivachev commented 2 years ago

I also tried to build it in docker on M1 Mac and the build failed with the following error:

#7 75.81 ERROR: /zetasql/zetasql/jdk/BUILD:22:11: Configurable attribute "includes" doesn't match this configuration (would a default condition help?).
#7 75.81 Conditions checked:
#7 75.81  @bazel_tools//src/conditions:darwin
#7 75.81  @bazel_tools//src/conditions:linux_x86_64
#7 75.82 INFO: Repository remotejdk11_linux_aarch64 instantiated at:
#7 75.82   /DEFAULT.WORKSPACE.SUFFIX:64:6: in <toplevel>
#7 75.82   /root/.cache/bazel/_bazel_root/6dfaba79244706669db31964876895d7/external/bazel_tools/tools/build_defs/repo/utils.bzl:201:18: in maybe
#7 75.82 Repository rule http_archive defined at:
#7 75.82   /root/.cache/bazel/_bazel_root/6dfaba79244706669db31964876895d7/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
#7 75.82 INFO: Repository boringssl instantiated at:
#7 75.82   /zetasql/WORKSPACE:81:20: in <toplevel>
#7 75.82   /root/.cache/bazel/_bazel_root/6dfaba79244706669db31964876895d7/external/com_google_zetasql/bazel/zetasql_deps_step_2.bzl:217:25: in zetasql_deps_step_2
#7 75.82 Repository rule http_archive defined at:
#7 75.82   /root/.cache/bazel/_bazel_root/6dfaba79244706669db31964876895d7/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
#7 75.95 ERROR: Analysis of target '//zetasql/jdk:jni' failed; build aborted: /zetasql/zetasql/jdk/BUILD:22:11: Configurable attribute "includes" doesn't match this configuration (would a default condition help?).
#7 75.95 Conditions checked:
#7 75.95  @bazel_tools//src/conditions:darwin
#7 75.95  @bazel_tools//src/conditions:linux_x86_64
riordan commented 2 years ago

I should mention @pgrivachev is the author of zetasql-npm, a fantastically useful FFI binding for zetasql.

The existence of that library has me incredibly excited at the potential of Zetasql's build process targeting not only x86_64, and arm, but also WASM so that Zetasql could be executed client-side and in-browser. Just planting that seed 🌱 .

leoch20 commented 1 year ago

@riordan you mentioned

Things work fine in MacOS

Was that on a M1 mac? I'm getting an error due to no support for aarch64 https://github.com/google/zetasql/blob/fa3c85e5492c7191a25804a7ede7e93e1f977d74/java/com/google/zetasql/JniChannelProvider.java#L47-L49

It would be awesome to get aarch64 support

laughedelic commented 1 year ago

@leoch20 if you are just trying to use ZetaSQL on an M1 mac, you need to make sure you're using the right x86_64 JVM (and you'll need Rosetta installed for that)

leoch20 commented 1 year ago

Thanks @laughedelic that did it for me

billstark commented 1 year ago

Hello @pgrivachev! Currently I am trying to build zetasql-snowflake on my local machine with MBP M1 chip. I got this error but have zero idea about how to solve this. Have you encountered this before? Thanks!

Target '//zetasql/parser:ast_node_util' depends on toolchain '@local_config_cc//:cc-compiler-darwin_arm64', which cannot be found: no such target '@local_config_cc//:cc-compiler-darwin_arm64': target 'cc-compiler-darwin_arm64' not declared in package '' defined by /private/var/tmp/_bazel_xxxxxxx/cae2a4c9d01ba6e33628c063444874a9/external/local_config_cc/BUILD'
pgrivachev commented 1 year ago

Hey @billstark! I don't remember such issue. I can only suggest using an environment that works for me:

Xcode 14.0
Command Line Tools for Xcode 14.0
Bazel 4.2.4