Skip to content

[android] Add -keepnativesymbols to Windows build #114466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

steveisok
Copy link
Member

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.

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.
@Copilot Copilot AI review requested due to automatic review settings April 10, 2025 01:24
@ghost ghost added the area-Build-mono label Apr 10, 2025
@steveisok steveisok requested a review from a team April 10, 2025 01:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)");

@@ -103,7 +102,7 @@
<_CoreClrBuildArg Include="-cmakeargs &quot;-DCLR_CMAKE_ESRP_CLIENT=$(DotNetEsrpToolPath)&quot;" />
</ItemGroup>

<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<ItemGroup Condition="'$(KeepNativeSymbols)' == 'true' or '$(TargetsWindows)' != 'true'">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/aot7

Production machine will only need a binary. Symbols are deemed optional; downloaded only when investigating issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants