Improve: ship release builds without debug info and symbols
linux/CMakeLists.txt forced -g into the global flags regardless of build type, so even a Release build carried full DWARF: 7.7MB of the 10.3MB binary was .debug_* material the client never uses at runtime. Drop the forced -g and default CMAKE_BUILD_TYPE to Release, stripping the symbol table at link time (-s) so only Debug builds keep symbols. Do the same for macOS with ld64's -Wl,-x on Release, which drops the 8.3k local symbols while keeping external ones and the signature ld appends. linux/ghost drops from 10.3MB to 2.5MB (UPX on top: 0.87MB). Rebuilt under WSL and verified with readelf: no .debug_*/.symtab/.strtab, BuildID kept. The macOS change is not verified here; it needs a build on the Mac. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
326e162d16
commit
913b74097b
3 files changed
+22
-3
No files matched your search
@@ -140,6 +140,14 @@ make -j$(nproc)
|
||||
|
||||
编译成功后生成可执行文件 `ghost`。
|
||||
|
||||
默认按 Release 构建(`-O3`,链接时 `-s` 剥离符号表,产物约 2.5MB,不含调试信息)。
|
||||
需要 gdb 调试或保留 DWARF 时改用:
|
||||
|
||||
```bash
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug . # -g(未优化)
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . # -O2 -g -DNDEBUG
|
||||
```
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 基本用法
|
||||
|
||||
Reference in new issue
Block a user