Skip to content

Conversation

@artemcm
Copy link
Contributor

@artemcm artemcm commented Feb 14, 2023

Resolves rdar://105261863

@artemcm artemcm requested a review from dcci February 14, 2023 00:34
@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

cc @dmcyk.

@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

@swift-ci test

@dcci
Copy link
Member

dcci commented Feb 14, 2023

Does this allow arbitrary -Oxxx ? (e.g. -O, -O1, -Oz)?
Looks like it, but I want to double check.

@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

Does this allow arbitrary -Oxxx ? (e.g. -O, -O1, -Oz)?
Looks like it, but I want to double check.

It doesn't, because Swift (driver or frontend) does not have such flags.
Swift only has:

-O                   - Compile with optimizations
-Osize               - Compile with optimizations and target small code size
-Ounchecked          - Compile with optimizations and remove runtime safety checks
-Oplayground         - Compile with optimizations appropriate for a playground

So the mapping that myself and @dmcyk came up with is:

-O and -Ounchecked -> -O3
-Onone             -> -O0
-Osize             -> -Os
-Oplayground       -> -O0 (that's what it maps to in swift-frontend) 

@dcci
Copy link
Member

dcci commented Feb 14, 2023

sounds good.

@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

Users can override this with a more fine-grained Clang flag if they wish to, adding to their swiftc command:

-Xclang-linker -O2

Copy link

@dmcyk dmcyk left a comment

Choose a reason for hiding this comment

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

Left two minor comments, but otherwise LGTM!

@artemcm artemcm force-pushed the OptimizationLevelOnLinkerInvocations branch from 4ca2c95 to 7cda054 Compare February 14, 2023 17:12
@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Feb 14, 2023

@swift-ci test Windows platform

@artemcm artemcm merged commit 6aaa811 into swiftlang:main Feb 14, 2023
@artemcm artemcm deleted the OptimizationLevelOnLinkerInvocations branch February 14, 2023 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants