Skip to content

Commit c4dd50e

Browse files
committed
Split debug - add an extra folder to the META-INF outputs
1 parent 6ab90a7 commit c4dd50e

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,39 @@ The project includes both Java and C++ unit tests. You can run them using:
6464
### Cross-JDK Testing
6565
`JAVA_TEST_HOME=<path to test JDK> ./gradlew testDebug`
6666

67+
## Release Builds and Debug Information
68+
69+
### Split Debug Information
70+
Release builds automatically generate split debug information to optimize deployment size while preserving debugging capabilities:
71+
72+
- **Stripped libraries** (~1.2MB): Production-ready binaries with symbols removed for deployment
73+
- **Debug symbol files** (~6.1MB): Separate `.debug` files containing full debugging information
74+
- **Debug links**: Stripped libraries include `.gnu_debuglink` sections pointing to debug files
75+
76+
### Build Artifacts Structure
77+
```
78+
ddprof-lib/build/
79+
├── lib/main/release/linux/x64/
80+
│ ├── libjavaProfiler.so # Original library with debug symbols
81+
│ ├── stripped/
82+
│ │ └── libjavaProfiler.so # Stripped library (83% smaller)
83+
│ └── debug/
84+
│ └── libjavaProfiler.so.debug # Debug symbols only
85+
├── native/release/
86+
│ └── META-INF/native-libs/linux-x64/
87+
│ └── libjavaProfiler.so # Final stripped library (deployed)
88+
└── native/release-debug/
89+
└── META-INF/native-libs/linux-x64/
90+
└── libjavaProfiler.so.debug # Debug symbols package
91+
```
92+
93+
### Build Options
94+
- **Skip debug extraction**: `./gradlew buildRelease -Pskip-debug-extraction=true`
95+
- **Debug extraction requires**: `objcopy` (Linux) or `dsymutil` (macOS)
96+
- Ubuntu/Debian: `sudo apt-get install binutils`
97+
- Alpine: `apk add binutils`
98+
- macOS: Included with Xcode command line tools
99+
67100
## Development
68101

69102
### Code Quality

ddprof-lib/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def getMissingToolErrorMessage(toolName, installInstructions) {
6363
def createDebugExtractionTask(config, linkTask) {
6464
return tasks.register('extractDebugLibRelease', Exec) {
6565
onlyIf {
66-
config.active && !shouldSkipDebugExtraction()
66+
!shouldSkipDebugExtraction()
6767
}
6868
dependsOn linkTask
6969
description = 'Extract debug symbols from release library'
@@ -109,7 +109,7 @@ def createDebugExtractionTask(config, linkTask) {
109109
def createDebugLinkTask(config, linkTask, extractDebugTask) {
110110
return tasks.register('addDebugLinkLibRelease', Exec) {
111111
onlyIf {
112-
config.active && os().isLinux() && !shouldSkipDebugExtraction()
112+
os().isLinux() && !shouldSkipDebugExtraction()
113113
}
114114
dependsOn extractDebugTask
115115
description = 'Add debug link to the original library'
@@ -148,16 +148,14 @@ def createDebugCopyTask(config, extractDebugTask) {
148148

149149
// Main function to setup debug extraction for release builds
150150
def setupDebugExtraction(config, linkTask) {
151-
if (config.name == 'release') {
151+
if (config.name == 'release' && config.active && !project.hasProperty('skip-native')) {
152152
// Create all debug-related tasks
153153
def extractDebugTask = createDebugExtractionTask(config, linkTask)
154154
def addDebugLinkTask = createDebugLinkTask(config, linkTask, extractDebugTask)
155155

156156
// Create the strip task and configure it properly
157157
def stripTask = tasks.register('stripLibRelease', StripSymbols) {
158-
onlyIf {
159-
config.active
160-
}
158+
// No onlyIf needed here - setupDebugExtraction already handles the main conditions
161159
dependsOn addDebugLinkTask
162160
}
163161

@@ -176,6 +174,9 @@ def setupDebugExtraction(config, linkTask) {
176174
if (copyTask != null) {
177175
copyTask.dependsOn stripTask
178176
copyTask.inputs.files stripTask.get().outputs.files
177+
178+
// Create an extra folder for the debug symbols
179+
copyTask.dependsOn copyDebugTask
179180
}
180181
}
181182
}

0 commit comments

Comments
 (0)