Skip to content

🍒 [clang] Do not duplicate "EnableSplitLTOUnit" module flag #4228

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

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Apr 15, 2022

Cherry-pick 53adfa8 to unlock hermetic-seal-at-link on non-Darwin platforms.

Since .bc can be archived into .a without processing it by clang linker, IRGen is responsible to add EnableSplitLTOUnit. However, main module's .bc is processed by clang linker, then EnableSplitLTOUnit is added twice.

module flag identifiers must be unique (or of 'require' type)
!"EnableSplitLTOUnit"
LLVM ERROR: Broken module found, compilation aborted!

Original commit message

If clang's output is set to bitcode and LTO is enabled, clang would
unconditionally add the flag to the module. Unfortunately, if the input were a
bitcode or IR file and had the flag set, this would result in two copies of the
flag, which is illegal IR. Guard the setting of the flag by checking whether it
already exists. This follows existing practice for the related "ThinLTO" module
flag.

Differential Revision: https://reviews.llvm.org/D112177

If clang's output is set to bitcode and LTO is enabled, clang would
unconditionally add the flag to the module.  Unfortunately, if the input were a
bitcode or IR file and had the flag set, this would result in two copies of the
flag, which is illegal IR.  Guard the setting of the flag by checking whether it
already exists.  This follows existing practice for the related "ThinLTO" module
flag.

Differential Revision: https://reviews.llvm.org/D112177
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@MaxDesiatov
Copy link

Hi @compnerd could you review this PR? It's a cherry-pick that's going to unblock one more PR in the Swift toolchain. Thanks!

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

I'm curious about the ignored verifier. Why does the verifier seem to be unhappy here?

@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented May 14, 2022

@compnerd As far as I confirmed, the test case passed even without the -disable-llvm-verifier option. I'm not sure the reason why the verifier can be unhappy in some situations, but I kept the lines as the original upstream patch does.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Keeping in sync with upstream sounds good

CC @hyp @bnbarham

@MaxDesiatov
Copy link

Hi @compnerd, can you merge this PR? Neither I nor @kateinoigakukun have permissions to merge in this repo. Thank you.

@compnerd compnerd merged commit d55f2c0 into swiftlang:stable/20211026 May 21, 2022
@kateinoigakukun kateinoigakukun deleted the katei/cherry-pick-53adfa8750eaf4558c41a50f699616545eb0151b branch June 11, 2022 04:08
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.

4 participants