[android] Add -keepnativesymbols to Windows build#114466
[android] Add -keepnativesymbols to Windows build#114466steveisok wants to merge 4 commits intodotnet:mainfrom
Conversation
This is so the symbols are kept in the native libs so that you can debug straight away in android studio. The cmake that gets generated for each test app also needed CMAKE_BUILD_TYPE to be set otherwise the breakpoints would not be hit. It'll just work on non-windows.
There was a problem hiding this comment.
Copilot reviewed 2 out of 6 changed files in this pull request and generated no comments.
Files not reviewed (4)
- eng/build.ps1: Language not supported
- src/coreclr/runtime.proj: Language not supported
- src/native/libs/build-native.proj: Language not supported
- src/tasks/AndroidAppBuilder/Templates/CMakeLists-android.txt: Language not supported
Comments suppressed due to low confidence (2)
src/tasks/MobileBuildTasks/Android/AndroidProject.cs:67
- The removal of the Debug build configuration in the else branch might lead to unintended behavior for builds that expect a Debug configuration. Confirm that this change aligns with the intended debugging experience on non-Windows platforms.
cmakeGenArgs += " -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_C_FLAGS=\"-s -Wno-unused-command-line-argument\"";
src/tasks/AndroidAppBuilder/ApkBuilder.cs:363
- Appending 'set(CMAKE_BUILD_TYPE Debug)' directly in the CMakeLists may conflict with other build type settings. Verify that this approach consistently enables breakpoints in the intended debug builds.
defines.AppendLine("set(CMAKE_BUILD_TYPE Debug)");
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(TargetsBrowser)' == 'true'"> | ||
| <ItemGroup Condition="'$(KeepNativeSymbols)' == 'true' or '$(TargetsWindows)' != 'true'"> |
There was a problem hiding this comment.
This condition replaces `$(KeepNativeSymbols)' != 'false'. I'm still not a fan as I think we want it to be opt in except for (I think) wasm that wants it on explicitly.
Are there other platforms where want this on by default?
There was a problem hiding this comment.
I don't think we have other platforms. Symbols in separate files remove > 50% from the binary size, e.g.
$ dotnet10 publish -o dist -c Release
$ du -sh dist/*
1.3M dist/aot7
2.3M dist/aot7.dbg
$ dotnet10 publish -o dist -c Release -p:StripSymbols=false
$ du -sh dist/*
3.5M dist/aot7Production machine will only need a binary. Symbols are deemed optional; downloaded only when investigating issues.
This is so the symbols are kept in the native libs so that you can debug straight away in android studio. Also, the cmake that gets generated for each test app also needed CMAKE_BUILD_TYPE to be set otherwise the breakpoints would not be hit. It'll just work on non-windows.