This is an archive of the discontinued LLVM Phabricator instance.

[LTO][clang] Teaching Clang to Pass Plugin Options to the AIX Linker
ClosedPublic

Authored by qiongsiwu1 on Sep 28 2022, 11:59 AM.

Details

Summary

This patch teaches clang to use the prefix -bplugin_opt: (instead of -plugin-opt) on AIX, when passing plugin options to the linker. This patch follows https://reviews.llvm.org/D134668.

We put the code that decides what plugin option prefix to use at the top of the function tools::addLTOOptions. The plugin option prefix, the mcpu prefix, and the opt level prefix are different on AIX. We thought about choosing the strings in a function that reads the linker name and the target triple, or we could push the logic into different derived ToolChain classes. But this logic would not be used anywhere else, so these alternatives looked too complicated for what they did. Therefore we are doing it the current way. That said, I am all ears for suggestions to improve this code!

Subsequent code uses the PluginOptPrefix variable consistently instead of the hardcoded -plugin-opt.

Diff Detail

Event Timeline

qiongsiwu1 created this revision.Sep 28 2022, 11:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 11:59 AM
qiongsiwu1 requested review of this revision.Sep 28 2022, 11:59 AM
qiongsiwu1 edited the summary of this revision. (Show Details)Sep 28 2022, 12:16 PM

Fix the test failure on Windows.

Fix test case on Windows.

Try fixing the test case on Windows, hopefully one last time.

MaskRay added inline comments.Sep 29 2022, 7:48 PM
clang/test/Driver/lto-aix.c
3

Replace legacy -target with --target=

qiongsiwu1 updated this revision to Diff 464683.Oct 3 2022, 7:31 AM

Address a code review comment.

qiongsiwu1 marked an inline comment as done.Oct 3 2022, 7:32 AM

LGTM

clang/lib/Driver/ToolChains/CommonArgs.cpp
72

Adding Twine to one operand of + suffices.

76

Adding Twine to one operand of + suffices.

495

delete blank line

qiongsiwu1 updated this revision to Diff 464998.EditedOct 4 2022, 7:11 AM

Address review comments. Remove unnecessary Twines.

qiongsiwu1 marked 2 inline comments as done.Oct 4 2022, 7:12 AM
qiongsiwu1 marked an inline comment as done.
MaskRay accepted this revision.Oct 4 2022, 12:32 PM
This revision is now accepted and ready to land.Oct 4 2022, 12:32 PM

Rebase with latest main.