Make build failing on Apple silicon - macbook m2 pro
LocalAI version:
728f297bb8c390d0de7b95b1969cbf1ad1864ab4
Environment, CPU architecture, OS, and Version:
arm64(mac m2 pro) Ventura 13.3.1
Describe the bug
make build failing for mac m2 pro,
Error
LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:19: error: variable has incomplete type 'struct stat64'
To Reproduce
git clone the repo
make build on mac m2 pro
Expected behavior
build should not fail
Logs
make build
go mod edit -replace github.com/go-skynet/go-llama.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-llama
go mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=/Users/ankur/dev/generative-ai/LocalAI/gpt4all/gpt4all-bindings/golang
go mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-ggml-transformers
go mod edit -replace github.com/donomii/go-rwkv.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-rwkv
go mod edit -replace github.com/ggerganov/whisper.cpp=/Users/ankur/dev/generative-ai/LocalAI/whisper.cpp
go mod edit -replace github.com/go-skynet/go-bert.cpp=/Users/ankur/dev/generative-ai/LocalAI/go-bert
go mod edit -replace github.com/go-skynet/bloomz.cpp=/Users/ankur/dev/generative-ai/LocalAI/bloomz
go mod edit -replace github.com/mudler/go-stable-diffusion=/Users/ankur/dev/generative-ai/LocalAI/go-stable-diffusion
go mod download
cd go-rwkv && cd rwkv.cpp && cmake . -DRWKV_BUILD_SHARED_LIBRARY=OFF && cmake --build . && cp librwkv.a .. && cp ggml/src/libggml.a ..
-- Accelerate framework found
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- Accelerate framework found
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp
[ 25%] Built target ggml
[ 37%] Building CXX object CMakeFiles/rwkv.dir/rwkv.cpp.o
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:209:5: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
sprintf(full_key, "blocks.%d.%s", block_index, key.c_str());
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:19: error: variable has incomplete type 'struct stat64'
struct stat64 file_stat;
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:471:12: note: forward declaration of 'stat64'
struct stat64 file_stat;
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:638:30: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
((struct rwkv_context *) ctx)->last_error = RWKV_ERROR_NONE;
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:640:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, state_out != NULL, "state_out is NULL");
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:641:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, logits_out != NULL, "logits_out is NULL");
^
/Users/ankur/dev/generative-ai/LocalAI/go-rwkv/rwkv.cpp/rwkv.cpp:642:31: warning: cast from 'const rwkv_context *' to 'rwkv_context *' drops const qualifier [-Wcast-qual]
RWKV_CTX_ASSERT_FALSE_MSG(ctx, RWKV_ERROR_ARGS, token < ctx->model->n_vocab, "Token is out of range 0..%d", ctx->model->n_vocab - 1);
^
5 warnings and 1 error generated.
make[3]: *** [CMakeFiles/rwkv.dir/rwkv.cpp.o] Error 1
make[2]: *** [CMakeFiles/rwkv.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [go-rwkv/librwkv.a] Error 2
Additional context
Hi @devilankur18 , thanks for your feedback. I am not sure if this is bug, I build it in M1 without any issue before. So, please investigate it further. And I saw you pick up a commit with a dependency update. May you try to build the main branch in your local env?
@Aisuko I stared with master branch only, when it failed I tried falling back to older versions.
I also have this problem on my M1 Pro Macbook
Hi, guys. I hit the issue of the building process in my (arrch64) container environment https://github.com/go-skynet/LocalAI/pull/282#issuecomment-1554691619 but I did not hit the issue on my laptop(M1). May you guys try to use the x86_64 environment? Github Codespace is pretty ok, I use it as the built environment.
Please use make clean to clean all the binding packages and make sure there without any changes to the code.
And resetting every binding packages's changes by using git submodule foreach git reset --hard command.
And you can use make prepare re-download and compile all the files, making sure everything works out. After that, make test check if everything is ok.
This issue may be caused by the loaded sub-project: https://github.com/donomii/go-rwkv.cpp. When using the project's built-in compilation script: ./build-mac.sh, it fails to compile on my Macbook M1 Pro. Has anyone been able to successfully compile it?
I don't have a macOS, and the CI seems to pass for MacOS reducing my possibilities to test it. Can you see if you can compile https://github.com/saharNooby/rwkv.cpp? The issue seems to come from there. would be great to open an issue to rwkv.cpp too
I have made the changes and it worked
this is the fix https://github.com/saharNooby/rwkv.cpp/blob/a8ebb07d2501dcb6fd544177022421660537030f/rwkv.cpp#L20-L36 and should be merged in a day or two
Thank you so much @LoganDark !
ping @donomii chance to include https://github.com/saharNooby/rwkv.cpp/pull/74 in go-rwkv.cpp anytime soon ?
I'll do it later today