Skip to content
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

Remove libstdc++ dependency from NativeAOT #76705

Merged
merged 3 commits into from
Oct 13, 2022

Conversation

am11
Copy link
Member

@am11 am11 commented Oct 6, 2022

Fixes #76655.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Oct 6, 2022
@EgorBo
Copy link
Member

EgorBo commented Oct 6, 2022

nice, I'm just curious - does it lead to a smaller binary size?

@eerhardt
Copy link
Member

eerhardt commented Oct 6, 2022

does it lead to a smaller binary size?

I don't know about the binary size (I haven't tested it), but it leads to a smaller container size because you don't need to install libstdc++ as a dependency. Here's the "docker inspect" of a small example NativeAOT app built on alpine:

image

Note that the libstdc++ dependency almost doubles the starting image size.

@am11
Copy link
Member Author

am11 commented Oct 6, 2022

nice, I'm just curious - does it lead to a smaller binary size?

Yes and no.

linux-x64: yes (-15kb). crossgen2's native binary size went from 45249216 -> 45233888 bytes.
osx-arm64: no (+1.4kb). crossgen2's native binary size went from 67941062 -> 67942550 bytes.

If we convert it to pure C, then it will get slimmer on both. Right now, compiler is baking in some code in -nostdlib / -nostdlib++ mode for C++ sources and it is bulkier than pure C (and what can be achieved with -ffreestanding).

@am11 am11 marked this pull request as ready for review October 7, 2022 12:10
@am11 am11 requested a review from MichalStrehovsky as a code owner October 7, 2022 12:10
@am11 am11 closed this Oct 8, 2022
@am11 am11 reopened this Oct 8, 2022
@am11 am11 closed this Oct 10, 2022
@am11 am11 reopened this Oct 10, 2022
@build-analysis build-analysis bot mentioned this pull request Oct 10, 2022
2 tasks
@am11 am11 force-pushed the feature/nativeaot/nostdlib++ branch from 19bd9ac to 5a30a0d Compare October 11, 2022 23:32
@am11 am11 closed this Oct 12, 2022
@am11 am11 reopened this Oct 12, 2022
@am11 am11 force-pushed the feature/nativeaot/nostdlib++ branch from 4a730cb to cd2825c Compare October 12, 2022 05:27
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@AaronRobinsonMSFT Any other feedback?

cc @dotnet/gc for awareness. This contains some minor changes in GC/EE interface contract. These changes do not break binary compatibility - newer standalone gc builds should continue to work with older runtimes, just like before.

Copy link
Member

@mangod9 mangod9 left a comment

Choose a reason for hiding this comment

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

thx!

@jkotas
Copy link
Member

jkotas commented Oct 13, 2022

Failure is dotnet/arcade#11239

@jkotas jkotas merged commit 546fad9 into dotnet:main Oct 13, 2022
@am11 am11 deleted the feature/nativeaot/nostdlib++ branch October 13, 2022 10:01
@am11
Copy link
Member Author

am11 commented Oct 13, 2022

@EgorBo, crossgen2 binary size with final changes:

macOS (arm64): +272 bytes
Linux (x64): -10608 bytes

@ghost ghost locked as resolved and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove runtime dependencies on libstdc++
8 participants