Skip to content

[TLOF][NFC] Make emitLinkerDirectives virtual and public. #123773

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
Jan 22, 2025

Conversation

nvjle
Copy link
Contributor

@nvjle nvjle commented Jan 21, 2025

Today, emitLinkerDirectives is private to TLOFCOFF-- it isolates parsing and processing of the linker options. Similar processing is also done by other TLOFs inline within emitModuleMetadata. This patch promotes emitLinkerDirectives to a virtual (public) method so that this handling is similarly isolated in the other TLOFs.

This also enables downstream targets to override just this handling instead of the whole of emitModuleMetadata.

Today, emitLinkerDirectives is private to TLOFCOFF-- it isolates
parsing and processing of the linker options. Similar processing
is also done by other TLOFs inline within emitModuleMetadata. This
patch promotes emitLinkerDirectives to a virtual (public) method so
that this handling is similarly isolated in the other TLOFs.

This also enables downstream targets to override just this handling
instead of the whole of emitModuleMetadata.
@nvjle nvjle marked this pull request as ready for review January 21, 2025 18:16
Copy link
Collaborator

@rnk rnk left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

SmallVector<std::string, 4> StrOptions;
for (const auto &Piece : cast<MDNode>(Option)->operands())
StrOptions.push_back(std::string(cast<MDString>(Piece)->getString()));
Streamer.emitLinkerOptions(StrOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL there is a MachO-specific .linker_option assembler directive. Who knew.

@nvjle nvjle merged commit 7cf8add into llvm:main Jan 22, 2025
11 checks passed
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