Skip to content

Revert "Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows"" #32237

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

Resolve CI failure on android and other hosts addressed at #31146 (comment) and restore #32235

Android test cases try to use gold linker -use-ld=gold but we don't support gold and other linkers except for lld for LTO now. So I changed to force to use lld when LTO on Unix like toolchain

: 'RUN: at line 13';   /home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/buildbot_linux/swift-linux-x86_64/bin/swiftc -target armv7-none-linux-android -toolchain-stdlib-rpath -Xcc --sysroot=/home/ubuntu/android-ndk-r17/platforms/android-21/arch-arm -Xclang-linker --sysroot=/home/ubuntu/android-ndk-r17/platforms/android-21/arch-arm -tools-directory /home/ubuntu/android-ndk-r17/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin -L /home/ubuntu/android-ndk-r17/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -L /home/ubuntu/android-ndk-r17/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x -L /home/ubuntu/android-ndk-r17/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib  -module-cache-path '/home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/buildbot_linux/swift-linux-x86_64/swift-test-results/armv7-none-linux-androideabi/clang-module-cache' -use-ld=gold /home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/swift/test/Driver/Inputs/lto/lib.swift -static -lto=llvm -emit-library -emit-module -module-name A -working-directory /home/ubuntu/jenkins/workspace/oss-swift-RA-linux-ubuntu-16.04-android/buildbot_linux/swift-linux-x86_64/test-android-armv7/Driver/Output/link-time-opt-staticlib-thin.swift.tmp/thin-static

CC: @compnerd

At this time, we don't support gold and other linkers for LTO.
@compnerd
Copy link
Member

compnerd commented Jun 8, 2020

@swift-ci please test

@kateinoigakukun
Copy link
Member Author

@compnerd Could you trigger android and other platforms CI jobs?

@compnerd
Copy link
Member

compnerd commented Jun 9, 2020

I dont think its possible to trigger a run for android sadly. I can trigger it for AWS Linux and CentOS 8 though, so lets just ensure that those will stay green.

@compnerd
Copy link
Member

compnerd commented Jun 9, 2020

@swift-ci Please test Amazon Linux 2 platform

@compnerd
Copy link
Member

compnerd commented Jun 9, 2020

@swift-ci Please test CentOS 8 platform

@swift-ci
Copy link
Contributor

swift-ci commented Jun 9, 2020

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

@swift-ci
Copy link
Contributor

swift-ci commented Jun 9, 2020

Build failed
Swift Test CentOS 8 Platform
Git Sha - 97eb7dc

@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented Jun 9, 2020

Hmm, it seems these CI jobs are not working well...

@kateinoigakukun
Copy link
Member Author

I'm not sure who maintains these platforms CI, but it seems something wrong in CI system. CC: @compnerd

@compnerd
Copy link
Member

CC: @shahmishal - are CentOS and AWS Linux CI builders supposed to work?

@shahmishal
Copy link
Member

They should be working, I will look into this tomorrow.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

@swift-ci
Copy link
Contributor

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

@swift-ci
Copy link
Contributor

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

@compnerd
Copy link
Member

@swift-ci Please test Amazon Linux 2 platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

@compnerd
Copy link
Member

compnerd commented Jun 15, 2020

FAILED: src/swift/libswiftDispatch.a src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Data.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Dispatch.swift.o src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Queue.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.o src/swift/CMakeFiles/swiftDispatch.dir/Wrapper.swift.o src/swift/swift/Dispatch.swiftmodule 
: && /home/build-user/build/buildbot_linux/swift-linux-x86_64/bin/swiftc -output-file-map src/swift/CMakeFiles/swiftDispatch.dir/output-file-map.json -incremental -j 32 -emit-library -static -o src/swift/libswiftDispatch.a -module-name Dispatch -module-link-name swiftDispatch -emit-module -emit-module-path src/swift/swift/Dispatch.swiftmodule -emit-dependencies  -O   -Xcc -fblocks -Xcc -fmodule-map-file=/home/build-user/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/home/build-user/swift-corelibs-libdispatch -I /home/build-user/swift-corelibs-libdispatch/src/BlocksRuntime -I . -I /home/build-user/swift-corelibs-libdispatch -I /home/build-user/swift-corelibs-libdispatch/src -I src /home/build-user/swift-corelibs-libdispatch/src/swift/Block.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Data.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Dispatch.swift /home/build-user/swift-corelibs-libdispatch/src/swift/IO.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Private.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Queue.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Source.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Time.swift /home/build-user/swift-corelibs-libdispatch/src/swift/Wrapper.swift    && :
/home/build-user/swift-corelibs-libdispatch/src/swift/Dispatch.swift:99:4: warning: default will never be executed
                        default: return nil
                        ^
<unknown>:0: error: unable to execute command: <unknown>

Thats not really helpful :/, lets try this once more. If it fails (due to infra), lets go ahead and merge and deal with the fallout.

@compnerd
Copy link
Member

@swift-ci please test Amazon Linux 2 platform

@shahmishal
Copy link
Member

Thats not really helpful :/, lets try this once more. If it fails (due to infra), lets go ahead and merge and deal with the fallout.

Why merge it with known failure? Are you not able to reproduce this locally?

@compnerd
Copy link
Member

@shahmishal hmm, are there instructions for reproducing the builds locally? But, I suspect that its a disk size thing.

@compnerd
Copy link
Member

@swift-ci please test CentOS 8 platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test CentOS 8 Platform
Git Sha - 97eb7dc

@compnerd
Copy link
Member

@shahmishal CentOS still is failing without building:

 ---> Running in 0432b5ffb4f0
CentOS-8 - AppStream                            0.0  B/s |   0  B     00:20    
�[91mFailed to download metadata for repo 'AppStream'
�[0m�[91mError: Failed to download metadata for repo 'AppStream'
�[0mThe command '/bin/sh -c yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm' returned a non-zero code: 1
Build step 'Execute shell' marked build as failure

@shahmishal
Copy link
Member

@compnerd I am looking into the CentOS 8 issues, however Amazon Linux 2 issue looks real.

@swift-ci
Copy link
Contributor

Build failed
Swift Test CentOS 8 Platform
Git Sha - 97eb7dc

@swift-ci
Copy link
Contributor

Build failed
Swift Test CentOS 8 Platform
Git Sha - 97eb7dc

assert(Kind != LinkKind::None && Kind != LinkKind::StaticLibrary);
}

LinkKind getKind() const { return Kind; }

bool PerformLTO() const { return LTO; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow naming guidelines!

-> shouldPerformLTO().

Can you rename the flag to ShouldPerformLTO? What does bool LTO even mean? It is ambiguous.

@@ -217,6 +223,8 @@ class IRGenOptions {
/// Whether we should embed the bitcode file.
IRGenEmbedMode EmbedMode : 2;

IRGenLLVMLTOKind LLVMLTOKind: 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

This code has not been run through git-clang-format. Please do so before this lands!

@@ -1779,6 +1782,18 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,

}

if (const Arg *A = Args.getLastArg(options::OPT_lto)) {
auto LTOVariant = llvm::StringSwitch<Optional<OutputInfo::LTOKind>>(A->getValue())
.Case("llvm", OutputInfo::LTOKind::LLVMThin)
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets be explicit here and be clear that it is llvm-thin.

}
break;
}
case OutputInfo::LTOKind::None: break;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another example where you haven't used git-clang-format. Please do so before this lands!

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

I want to look at this again before it goes back in. All of the changes that have been made to IRGen need IRGen FileCheck test cases.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Amazon Linux 2 Platform
Git Sha - 97eb7dc

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

At a higher level, you probably want to split up this PR into a PR that handles the driver part and the part that handles the pipeline part. The first PR would have a bunch of IR tests that validate that all of the proper LTO bigs work together ignoring the driver. This PR smooshes the two together and doesn't provide any .ll tests. That needs to be fixed.

// When performing LTO, we always use lld that supports auto linking mechanism with ELF.
// So embed dependent libraries names in "llvm.dependent-libraries" instead of "llvm.linker.options".
const StringRef AutolinkSectionName =
TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None
Copy link
Contributor

Choose a reason for hiding this comment

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

Test?

llvm::MDNode::get(ctx, llvm::MDString::get(ctx, opt)));
if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None) {
// When performing LTO, we always use lld that supports auto linking mechanism with ELF.
// So embed dependent libraries names in "llvm.dependent-libraries" instead of options
Copy link
Contributor

Choose a reason for hiding this comment

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

Test?

@compnerd
Copy link
Member

CC: @atrick @eeckstein

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.

5 participants