Skip to content

IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist #74178

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

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

aschwaighofer
Copy link
Contributor

Also emit it per default.

rdar://129299739

…objc_clsrolist

Also emit it per default.

rdar://129299739
@aschwaighofer
Copy link
Contributor Author

@swift-ci test

llvm::GlobalValue::InternalLinkage, Int8PtrTy, /*isConstant*/ false,
/*asContiguousArray*/ true, /*canBeStrippedByLinker*/ true);
/*asContiguousArray*/ true, /*canBeStrippedByLinker*/ false);
Copy link
Contributor

Choose a reason for hiding this comment

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

/canBeStrippedByLinker/ false

Is this about the symbol name or dead code stripping?

Copy link
Contributor Author

@aschwaighofer aschwaighofer Jun 6, 2024

Choose a reason for hiding this comment

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

This boolean decides whether llvm.used or llvm.compiler.used is used.

This will influence whether llvm's LTO can assume that the variable is unused if there are no other uses (that would happen with llvm.compiler.used i.e /canBeStrippedByLinker/ true) but will also cause the emission of .no_dead_strip _generic_ro_datas.

As in:

        .section        __LD,__objc_clsrolist
        .p2align        3, 0x0
_generic_ro_datas:
        .quad   ___unnamed_1+40
        .quad   ___unnamed_1+112
 ...
 .no_dead_strip  _generic_ro_datas

I assumed that is okay since the linker will know it is to remove that section at the point it uses it.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, right we need this for LTO. It means older linkers that don't know about the section won't be able to dead strip it. That's maybe fine though? I assume this won't be too big, and it's only a problem when building with new Swift compiler but using an older linker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There will be one entry per generic class definition. Yes, I assume this to be a marginal problem that if it turns out to be a problem for an individual project that uses a new compiler with an old linker can turn this off via compiler flags.

@aschwaighofer aschwaighofer merged commit 83ef1cd into swiftlang:main Jun 7, 2024
5 checks passed
jefferyq2 pushed a commit to jefferyq2/swift that referenced this pull request Jun 10, 2024
IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist
jefferyq2 pushed a commit to jefferyq2/swift that referenced this pull request Jun 10, 2024
IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist
jefferyq2 pushed a commit to jefferyq2/swift that referenced this pull request Jun 10, 2024
IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist
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.

2 participants