chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://clickhouse.com/docs/en/chdb
Apache License 2.0
2.03k stars 72 forks source link

Unable to build on arm64 mac #164

Closed nevinpuri closed 9 months ago

nevinpuri commented 9 months ago

I've been trying to build chdb on my mac to use as a python library (as your version 1.0.2 doesn't have an arm64b build), but I've been having trouble building it. I've installed clang via homebrew, but I'm getting an error Could not find compiler set in environment variable CC. I'm not sure why it's looking for clang in /usr/local/opt/llvm/bin/clang, as I explicitly set CC=/opt/homebrew/opt/llvm/bin/clang and CXX=/opt/homebrew/opt/llvm/bin/clang.

If anyone has any ideas, any help is appreciated.

Make sure that git diff result is empty and you've just pulled fresh master. Try cleaning up cmake cache. Just in case, official build instructions are published here: https://clickhouse.com/docs/en/development/build/

Operating system

MacOS Sonoma 14.0

OS kind or distribution, specific version/release, non-standard kernel if any. If you are trying to build inside virtual machine, please mention it too.

Cmake version

3.27.7

Ninja version

1.11.1

Compiler name and version

Homebrew clang version 17.0.6 Target: arm64-apple-darwin23.0.0 Thread model: posix InstalledDir: /opt/homebrew/opt/llvm/bin

Full cmake and/or ninja output

CMake Error at /opt/homebrew/Cellar/cmake/3.27.7/share/cmake/Modules/CMakeDetermineCCompiler.cmake:49 (message):
  Could not find compiler set in environment variable CC:

  /usr/local/opt/llvm/bin/clang.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: *** [mac-arm64] Error 1
auxten commented 9 months ago

If there is no /usr/local/opt/llvm/bin/clang Try make symbol link /usr/local/opt/llvm to /opt/homebrew/opt/llvm

lmangani commented 9 months ago

version 1.0.2 doesn't have an arm64 build

We have an aarch64 build and you can use our docker builde to generate custom builds locally.

nevinpuri commented 9 months ago

I managed to get the build to work by modifying the build.sh file. However, it wouldn't install. I'll just use v1.0.0 and patch the python file.

diff --git a/chdb/build.sh b/chdb/build.sh
index 3af2a5c4c0c..ddfbadfb8df 100755
--- a/chdb/build.sh
+++ b/chdb/build.sh
@@ -12,9 +12,9 @@ HDFS="-DENABLE_HDFS=1 -DENABLE_GSASL_LIBRARY=1 -DENABLE_KRB5=1"
 MYSQL="-DENABLE_MYSQL=1"
 # check current os type
 if [ "$(uname)" == "Darwin" ]; then
-    export CXX=/usr/local/opt/llvm/bin/clang++
-    export CC=/usr/local/opt/llvm/bin/clang
-    export PATH=/usr/local/opt/llvm/bin:$PATH
+    export CC=/opt/homebrew/opt/llvm/bin/clang
+    export CXX=/opt/homebrew/opt/llvm/bin/clang++
+    export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
     GLIBC_COMPATIBILITY="-DGLIBC_COMPATIBILITY=0"