Redis 源码阅读第一弹:MacOS + CLion 2023.2.2 搭建 Redis 源码阅读环境

1 源码下载

直接从 GitHub 源码仓库下载:

git clone https://github.com/redis/redis.git

我们以最新的 tag 上去:

git checkout tags/7.0.4 -b 7.0.4

编译

首先确保安装了 GCC,我本地已安装。
编译:

make CFLAGS="-g -O0" 

备注:-O0 参数旨在强制编译器不要进行编译优化,避免 debug 的时候源码与实际运行代码不匹配

启动

拥抱 jetbrains 全家桶,使用 CLion 2023.2.2 编译好的 Redis 源码。

启动配置如下:
![](