Skip to content

Compile native code with -ffunction-sections#79322

Merged
marek-safar merged 3 commits intomainfrom
MichalStrehovsky-patch-1
Dec 7, 2022
Merged

Compile native code with -ffunction-sections#79322
marek-safar merged 3 commits intomainfrom
MichalStrehovsky-patch-1

Conversation

@MichalStrehovsky
Copy link
Member

We specify /Gy on Windows, but don't do this on non-Windows. This looks like an omission. For NativeAOT, doing this saves ~140 kB in size on a Hello World.

Cc @dotnet/ilc-contrib

We specify `/Gy` on Windows, but don't do this on non-Windows. This looks like an omission. For NativeAOT, doing this saves ~140 kB in size on a Hello World.
@ghost
Copy link

ghost commented Dec 7, 2022

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned MichalStrehovsky Dec 7, 2022
@jkotas
Copy link
Member

jkotas commented Dec 7, 2022

Need to suppress this for tvOS. clang : error : -ffunction-sections is not supported with -fembed-bitcode

@am11
Copy link
Member

am11 commented Dec 7, 2022

-ffunction-sections is set for debug and checked builds which is now redundant and can be deleted:

# -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
# -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
add_compile_options("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")


# Separate functions so linker can remove them. But not on Apple mobile platforms because
# -ffunction-sections is not supported with -fembed-bitcode.
if (NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should work for iOS, and only tvOS needs be disabled

Copy link
Member Author

Choose a reason for hiding this comment

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

Saw the failed iOS leg and assumed it's the same problem. But iOS maybe failed for unrelated reasons then. I'll put it back:

.packages/microsoft.dotnet.helix.sdk/8.0.0-beta.22579.2/tools/Microsoft.DotNet.Helix.Sdk.MultiQueue.targets(90,5): error : (NETCORE_ENGINEERING_TELEMETRY=Test) Work item System.Runtime.Tests in job 5143df8d-e525-435f-9a37-d062df01b8cb has failed.

@ghost
Copy link

ghost commented Dec 7, 2022

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Issue Details

We specify /Gy on Windows, but don't do this on non-Windows. This looks like an omission. For NativeAOT, doing this saves ~140 kB in size on a Hello World.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: MichalStrehovsky
Labels:

area-Infrastructure

Milestone: -

Comment on lines +483 to +487
# Separate functions so linker can remove them. But not on tvOS because
# -ffunction-sections is not supported with -fembed-bitcode.
if (NOT CLR_CMAKE_HOST_TVOS)
add_compile_options(-ffunction-sections)
endif()
Copy link
Member

@filipnavara filipnavara Dec 7, 2022

Choose a reason for hiding this comment

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

Is tvOS still compiled with bitcode? I thought Apple basically deprecated that across the board.

https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-14-release-notes:

Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14.

Xcode no longer builds bitcode by default and generates a warning message if a project explicitly enables bitcode: “Building with bitcode is deprecated. Please update your project and/or target settings to disable bitcode.” The capability to build with bitcode will be removed in a future Xcode release. IPAs that contain bitcode will have the bitcode stripped before being submitted to the App Store. Debug symbols can only be downloaded from App Store Connect / TestFlight for existing bitcode submissions and are no longer available for submissions made with Xcode 14. (86118779)

Copy link
Member

Choose a reason for hiding this comment

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

CI is using v13:

Running 'CC="/Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"..

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 it necessarily matters what CI uses. The change is that App Store doesn't require it anymore for new submissions.

Copy link
Member

Choose a reason for hiding this comment

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

@marek-safar marek-safar merged commit 20af770 into main Dec 7, 2022
@marek-safar marek-safar deleted the MichalStrehovsky-patch-1 branch December 7, 2022 17:51
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants