- Support one click to compile FE and BE.
- Support code jump in Clion and IDEA.
- All variables in the IDE can be analyzed normally without red lines.
- Clion can enable its analysis function normally.
- Support FE and BE debug.
Prepare
I use a MacBook(M1) for local coding and a remote server for compiling & testing StarRocks. (Remote server uses Ubuntu 22, at least need 16GB RAM). The overall idea is to write code on the MacBook, then automatically synchronize the code to the server through the IDE, and use the server to compile and develop StarRocks.MacBook Setup
Thrift 0.20
Protobuf
Just use the latest version v3 directly, because the latest version of Protobuf is compatible with the v2 version of the Protobuf protocol in StarRocks.Maven
OpenJDK 17
Python3
MacOS comes with it, no installation is needed.Setup system env
Ubuntu server setup
Clone StarRocks code
git clone https://github.com/StarRocks/starrocks.git
Install required tools for compilation
JAVA_HOME env
Do a compilation of StarRocks
IDE Setup
FE
FE development is simple because you can compile it in MacOS directly. Just enterfe folder and run the command mvn install -DskipTests.
Then you can use IDEA to open fe folder directly, everything is ok.
Local debug
The same as other Java applications. You might face OOM error while compiling StarRocks on Intellij IDEA, you can go to Build, Execution, Deployment -> Compiler -> Increase Heap size to a larger value.Remote debug
In Ubuntu server, run with./start_fe.sh --debug, then use IDEA remote debug to connect it. The default port is 5005, you can change it in start_fe.sh scripts.
Debug java parameter: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 is just copied from IDEA.

BE
It is recommended to runmvn install -DskipTests first in fe to generate the FE-side Java thrift/proto sources.
For BE, run the CMake configure/build flow once. The BE thrift/protobuf headers are materialized by CMake during configure/build into the active build directory (for example be/build_Release/gensrc/gen_cpp), so you no longer need cd gensrc && make for those files. If you need the shared script outputs first, run make -C gensrc script.
Use Clion to open be folder.
Enter Settings, add Toolchains. Add a remote server first, then setup Build Tool, C and C++ Compiler separately.

Settings / Deployment. Change folder mappings.

Settings / Cmake. Change Toolchain to be the remote toolchain just added. Add the following environment variables:
Include system environment variables.


Debug
BE debug is a little difficult, you have to use gdb in your remote server. Of course, you can use gdb server + Clion remote gdb, but I don’t recommend it, it’s too stuck. We need to changestart_backend.sh script from:
./bin/start_be.sh without any flag.
If you face the error report when debugging for lakehouse, just addhandle SIGSEGV nostop noprint passin~/.gdbinit.
LLVM
Of course, you can use LLVM tools to development be. Ubuntu LLVM installtion refer to: https://apt.llvm.org/ Then use the command:CC=clang-15 CXX=clang++-15 ./build.sh to compile be. But the premise is that your thirdparty has been compiled with gcc.