Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (20feee5cda2afd7824cf60a0c424b368f4bd474e)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Pavel Vinogradov <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (20feee5cda2afd7824cf60a0c424b368f4bd474e)
  • Date: Fri, 24 Nov 2017 01:18:56 +0000

GIT changes to master grimoire by Pavel Vinogradov <public AT sourcemage.org>:

devel/rust/HISTORY |
1
devel/rust/patches/0001-rustc-Fix-some-ThinLTO-internalization.patch |
211 ++++++++++
devel/rust/patches/0002-Update-ThinLTO-for-LLVM-5.patch |
103 ++++
devel/rust/patches/0003-Update-ThinLTO-internalization-for-LLVM-5.patch |
62 ++
4 files changed, 377 insertions(+)

New commits:
commit 20feee5cda2afd7824cf60a0c424b368f4bd474e
Author: Pavel Vinogradov <public AT sourcemage.org>
Commit: Pavel Vinogradov <public AT sourcemage.org>

devel/rust: added some upstream fixes to build with LLVM 5.0

diff --git a/devel/rust/HISTORY b/devel/rust/HISTORY
index 21ca034..f93cd8b 100644
--- a/devel/rust/HISTORY
+++ b/devel/rust/HISTORY
@@ -1,5 +1,6 @@
2017-11-23 Pavel Vinogradov <public AT sourcemage.org>
* DETAILS: version 1.22.1
+ * patches/000[1-3]*.patch: added upstream fixes for LLVM 5.0

2017-10-12 Pavel Vinogradov <public AT sourcemage.org>
* DETAILS: version 1.21.0
diff --git
a/devel/rust/patches/0001-rustc-Fix-some-ThinLTO-internalization.patch
b/devel/rust/patches/0001-rustc-Fix-some-ThinLTO-internalization.patch
new file mode 100644
index 0000000..4e08733
--- /dev/null
+++ b/devel/rust/patches/0001-rustc-Fix-some-ThinLTO-internalization.patch
@@ -0,0 +1,211 @@
+From 2e1c4cd0f51c28b8cfc003fda67f6641bb4335f2 Mon Sep 17 00:00:00 2001
+From: Alex Crichton <alex AT alexcrichton.com>
+Date: Wed, 11 Oct 2017 11:19:59 -0700
+Subject: [PATCH] rustc: Fix some ThinLTO internalization
+
+First the `addPreservedGUID` function forgot to take care of "alias"
summaries.
+I'm not 100% sure what this is but the current code now matches upstream.
Next
+the `computeDeadSymbols` return value wasn't actually being used, but it
needed
+to be used! Together these should...
+
+Closes #45195
+---
+ src/librustc_trans/back/lto.rs | 20
+++++++++++++++++++-
+ src/librustc_trans/back/write.rs | 10 ++++++----
+ src/rustllvm/PassWrapper.cpp | 13 ++++++++-----
+ src/test/run-pass/thinlto/auxiliary/dylib.rs | 16 ++++++++++++++++
+ .../{ => thinlto}/auxiliary/thin-lto-inlines-aux.rs | 0
+ src/test/run-pass/thinlto/dylib-works.rs | 18 ++++++++++++++++++
+ src/test/run-pass/{ => thinlto}/thin-lto-inlines.rs | 0
+ src/test/run-pass/{ => thinlto}/thin-lto-inlines2.rs | 0
+ 8 files changed, 67 insertions(+), 10 deletions(-)
+ create mode 100644 src/test/run-pass/thinlto/auxiliary/dylib.rs
+ rename src/test/run-pass/{ => thinlto}/auxiliary/thin-lto-inlines-aux.rs
(100%)
+ create mode 100644 src/test/run-pass/thinlto/dylib-works.rs
+ rename src/test/run-pass/{ => thinlto}/thin-lto-inlines.rs (100%)
+ rename src/test/run-pass/{ => thinlto}/thin-lto-inlines2.rs (100%)
+
+diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs
+index 8f75b891a3..01d3d656df 100644
+--- a/src/librustc_trans/back/lto.rs
++++ b/src/librustc_trans/back/lto.rs
+@@ -130,6 +130,7 @@ pub fn run(cgcx: &CodegenContext,
+ .filter_map(symbol_filter)
+ .collect::<Vec<CString>>();
+ timeline.record("whitelist");
++ info!("{} symbols to preserve in this crate", symbol_white_list.len());
+
+ // If we're performing LTO for the entire crate graph, then for each of
our
+ // upstream dependencies, find the corresponding rlib and load the
bitcode
+@@ -437,7 +438,24 @@ fn run_pass_manager(cgcx: &CodegenContext,
+ assert!(!pass.is_null());
+ llvm::LLVMRustAddPass(pm, pass);
+
+- with_llvm_pmb(llmod, config, &mut |b| {
++ // When optimizing for LTO we don't actually pass in `-O0`, but we
force
++ // it to always happen at least with `-O1`.
++ //
++ // With ThinLTO we mess around a lot with symbol visibility in a way
++ // that will actually cause linking failures if we optimize at O0
which
++ // notable is lacking in dead code elimination. To ensure we at
least
++ // get some optimizations and correctly link we forcibly switch to
`-O1`
++ // to get dead code elimination.
++ //
++ // Note that in general this shouldn't matter too much as you
typically
++ // only turn on ThinLTO when you're compiling with optimizations
++ // otherwise.
++ let opt_level =
config.opt_level.unwrap_or(llvm::CodeGenOptLevel::None);
++ let opt_level = match opt_level {
++ llvm::CodeGenOptLevel::None => llvm::CodeGenOptLevel::Less,
++ level => level,
++ };
++ with_llvm_pmb(llmod, config, opt_level, &mut |b| {
+ if thin {
+ if
!llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm) {
+ panic!("this version of LLVM does not support ThinLTO");
+diff --git a/src/librustc_trans/back/write.rs
b/src/librustc_trans/back/write.rs
+index 9d914243ec..f7e0ad029a 100644
+--- a/src/librustc_trans/back/write.rs
++++ b/src/librustc_trans/back/write.rs
+@@ -217,7 +217,7 @@ pub struct ModuleConfig {
+ passes: Vec<String>,
+ /// Some(level) to optimize at a certain level, or None to run
+ /// absolutely no optimizations (used for the metadata module).
+- opt_level: Option<llvm::CodeGenOptLevel>,
++ pub opt_level: Option<llvm::CodeGenOptLevel>,
+
+ /// Some(level) to optimize binary size, or None to not affect program
size.
+ opt_size: Option<llvm::CodeGenOptSize>,
+@@ -507,7 +507,8 @@ unsafe fn optimize(cgcx: &CodegenContext,
+ if !config.no_prepopulate_passes {
+ llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
+ llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
+- with_llvm_pmb(llmod, &config, &mut |b| {
++ let opt_level =
config.opt_level.unwrap_or(llvm::CodeGenOptLevel::None);
++ with_llvm_pmb(llmod, &config, opt_level, &mut |b| {
+ llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b,
fpm);
+ llvm::LLVMPassManagerBuilderPopulateModulePassManager(b,
mpm);
+ })
+@@ -1842,16 +1843,17 @@ pub fn run_assembler(sess: &Session, outputs:
&OutputFilenames) {
+
+ pub unsafe fn with_llvm_pmb(llmod: ModuleRef,
+ config: &ModuleConfig,
++ opt_level: llvm::CodeGenOptLevel,
+ f: &mut FnMut(llvm::PassManagerBuilderRef)) {
+ // Create the PassManagerBuilder for LLVM. We configure it with
+ // reasonable defaults and prepare it to actually populate the pass
+ // manager.
+ let builder = llvm::LLVMPassManagerBuilderCreate();
+- let opt_level = config.opt_level.unwrap_or(llvm::CodeGenOptLevel::None);
+ let opt_size = config.opt_size.unwrap_or(llvm::CodeGenOptSizeNone);
+ let inline_threshold = config.inline_threshold;
+
+- llvm::LLVMRustConfigurePassManagerBuilder(builder, opt_level,
++ llvm::LLVMRustConfigurePassManagerBuilder(builder,
++ opt_level,
+ config.merge_functions,
+ config.vectorize_slp,
+ config.vectorize_loop);
+diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
+index e37f048dd4..1287b94159 100644
+--- a/src/rustllvm/PassWrapper.cpp
++++ b/src/rustllvm/PassWrapper.cpp
+@@ -901,9 +901,7 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+ }
+ }
+
+- GlobalValueSummary *GVSummary = Summary.get();
+- if (isa<FunctionSummary>(GVSummary)) {
+- FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
++ if (auto *FS = dyn_cast<FunctionSummary>(Summary.get())) {
+ for (auto &Call: FS->calls()) {
+ if (Call.first.isGUID()) {
+ addPreservedGUID(Index, Preserved, Call.first.getGUID());
+@@ -916,6 +914,10 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+ addPreservedGUID(Index, Preserved, GUID);
+ }
+ }
++ if (auto *AS = dyn_cast<AliasSummary>(Summary.get())) {
++ auto GUID = AS->getAliasee().getOriginalName();
++ addPreservedGUID(Index, Preserved, GUID);
++ }
+ }
+ }
+
+@@ -963,12 +965,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule
*modules,
+ // combined index
+ //
+ // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
+- computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
++ auto DeadSymbols = computeDeadSymbols(Ret->Index,
Ret->GUIDPreservedSymbols);
+ ComputeCrossModuleImport(
+ Ret->Index,
+ Ret->ModuleToDefinedGVSummaries,
+ Ret->ImportLists,
+- Ret->ExportLists
++ Ret->ExportLists,
++ &DeadSymbols
+ );
+
+ // Resolve LinkOnce/Weak symbols, this has to be computed early be cause
it
+diff --git a/src/test/run-pass/thinlto/auxiliary/dylib.rs
b/src/test/run-pass/thinlto/auxiliary/dylib.rs
+new file mode 100644
+index 0000000000..cdb3f49cae
+--- /dev/null
++++ b/src/test/run-pass/thinlto/auxiliary/dylib.rs
+@@ -0,0 +1,16 @@
++// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
++// file at the top-level directory of this distribution and at
++// http://rust-lang.org/COPYRIGHT.
++//
++// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
++// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
++// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
++// option. This file may not be copied, modified, or distributed
++// except according to those terms.
++
++// compile-flags: -Z thinlto -C codegen-units=8
++
++#[inline]
++pub fn foo(b: u8) {
++ b.to_string();
++}
+diff --git a/src/test/run-pass/auxiliary/thin-lto-inlines-aux.rs
b/src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs
+similarity index 100%
+rename from src/test/run-pass/auxiliary/thin-lto-inlines-aux.rs
+rename to src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs
+diff --git a/src/test/run-pass/thinlto/dylib-works.rs
b/src/test/run-pass/thinlto/dylib-works.rs
+new file mode 100644
+index 0000000000..3f54519d0d
+--- /dev/null
++++ b/src/test/run-pass/thinlto/dylib-works.rs
+@@ -0,0 +1,18 @@
++// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
++// file at the top-level directory of this distribution and at
++// http://rust-lang.org/COPYRIGHT.
++//
++// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
++// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
++// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
++// option. This file may not be copied, modified, or distributed
++// except according to those terms.
++
++// aux-build:dylib.rs
++// min-llvm-version 4.0
++
++extern crate dylib;
++
++fn main() {
++ dylib::foo(1);
++}
+diff --git a/src/test/run-pass/thin-lto-inlines.rs
b/src/test/run-pass/thinlto/thin-lto-inlines.rs
+similarity index 100%
+rename from src/test/run-pass/thin-lto-inlines.rs
+rename to src/test/run-pass/thinlto/thin-lto-inlines.rs
+diff --git a/src/test/run-pass/thin-lto-inlines2.rs
b/src/test/run-pass/thinlto/thin-lto-inlines2.rs
+similarity index 100%
+rename from src/test/run-pass/thin-lto-inlines2.rs
+rename to src/test/run-pass/thinlto/thin-lto-inlines2.rs
+--
+2.15.0
+
diff --git a/devel/rust/patches/0002-Update-ThinLTO-for-LLVM-5.patch
b/devel/rust/patches/0002-Update-ThinLTO-for-LLVM-5.patch
new file mode 100644
index 0000000..6ba1b98
--- /dev/null
+++ b/devel/rust/patches/0002-Update-ThinLTO-for-LLVM-5.patch
@@ -0,0 +1,103 @@
+From 56f5a19e4561434919ecda627c5409a3b16ba1d0 Mon Sep 17 00:00:00 2001
+From: Alex Crichton <alex AT alexcrichton.com>
+Date: Tue, 10 Oct 2017 12:29:14 -0700
+Subject: [PATCH] Update ThinLTO for LLVM 5
+
+---
+ src/rustllvm/PassWrapper.cpp | 39 ++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 38 insertions(+), 1 deletion(-)
+
+diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
+index 1287b94159..c7d966fcdf 100644
+--- a/src/rustllvm/PassWrapper.cpp
++++ b/src/rustllvm/PassWrapper.cpp
+@@ -26,11 +26,13 @@
+ #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+
+ #if LLVM_VERSION_GE(4, 0)
+-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
+ #include "llvm/Transforms/IPO/AlwaysInliner.h"
+ #include "llvm/Transforms/IPO/FunctionImport.h"
+ #include "llvm/Transforms/Utils/FunctionImportUtils.h"
+ #include "llvm/LTO/LTO.h"
++#if LLVM_VERSION_LE(4, 0)
++#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
++#endif
+ #endif
+
+ #include "llvm-c/Transforms/PassManagerBuilder.h"
+@@ -888,6 +890,28 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+ return;
+ Preserved.insert(GUID);
+
++#if LLVM_VERSION_GE(5, 0)
++ auto Info = Index.getValueInfo(GUID);
++ if (!Info) {
++ return;
++ }
++ for (auto &Summary : Info.getSummaryList()) {
++ for (auto &Ref : Summary->refs()) {
++ addPreservedGUID(Index, Preserved, Ref.getGUID());
++ }
++
++ GlobalValueSummary *GVSummary = Summary.get();
++ if (isa<FunctionSummary>(GVSummary)) {
++ FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
++ for (auto &Call: FS->calls()) {
++ addPreservedGUID(Index, Preserved, Call.first.getGUID());
++ }
++ for (auto &GUID: FS->type_tests()) {
++ addPreservedGUID(Index, Preserved, GUID);
++ }
++ }
++ }
++#else
+ auto SummaryList = Index.findGlobalValueSummaryList(GUID);
+ if (SummaryList == Index.end())
+ return;
+@@ -919,6 +943,7 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+ addPreservedGUID(Index, Preserved, GUID);
+ }
+ }
++#endif
+ }
+
+ // The main entry point for creating the global ThinLTO analysis. The
structure
+@@ -939,6 +964,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule
*modules,
+
+ Ret->ModuleMap[module->identifier] = mem_buffer;
+
++#if LLVM_VERSION_GE(5, 0)
++ if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) {
++ LLVMRustSetLastError(toString(std::move(Err)).c_str());
++ return nullptr;
++ }
++#else
+ Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>>
ObjOrErr =
+ object::ModuleSummaryIndexObjectFile::create(mem_buffer);
+ if (!ObjOrErr) {
+@@ -947,6 +978,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
+ }
+ auto Index = (*ObjOrErr)->takeIndex();
+ Ret->Index.mergeFrom(std::move(Index), i);
++#endif
+ }
+
+ // Collect for each module the list of function it defines (GUID ->
Summary)
+@@ -981,8 +1013,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule
*modules,
+ StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>>
ResolvedODR;
+ DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
+ for (auto &I : Ret->Index) {
++#if LLVM_VERSION_GE(5, 0)
++ if (I.second.SummaryList.size() > 1)
++ PrevailingCopy[I.first] =
getFirstDefinitionForLinker(I.second.SummaryList);
++#else
+ if (I.second.size() > 1)
+ PrevailingCopy[I.first] = getFirstDefinitionForLinker(I.second);
++#endif
+ }
+ auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary
*S) {
+ const auto &Prevailing = PrevailingCopy.find(GUID);
+--
+2.15.0
+
diff --git
a/devel/rust/patches/0003-Update-ThinLTO-internalization-for-LLVM-5.patch
b/devel/rust/patches/0003-Update-ThinLTO-internalization-for-LLVM-5.patch
new file mode 100644
index 0000000..91eaeb6
--- /dev/null
+++ b/devel/rust/patches/0003-Update-ThinLTO-internalization-for-LLVM-5.patch
@@ -0,0 +1,62 @@
+From 3efa00365fc13f3145b143ee41b90fb5405b334f Mon Sep 17 00:00:00 2001
+From: Tatsuyuki Ishi <ishitatsuyuki AT gmail.com>
+Date: Tue, 17 Oct 2017 14:41:56 +0900
+Subject: [PATCH] Update ThinLTO (internalization) for LLVM 5
+
+Ref:
https://github.com/llvm-mirror/llvm/commit/ccb80b9c0f60f33780e5e29bf66a87bb56968b99
+---
+ src/rustllvm/PassWrapper.cpp | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
+index c7d966fcdf..b397ad1e98 100644
+--- a/src/rustllvm/PassWrapper.cpp
++++ b/src/rustllvm/PassWrapper.cpp
+@@ -902,7 +902,7 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+
+ GlobalValueSummary *GVSummary = Summary.get();
+ if (isa<FunctionSummary>(GVSummary)) {
+- FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
++ auto *FS = cast<FunctionSummary>(GVSummary);
+ for (auto &Call: FS->calls()) {
+ addPreservedGUID(Index, Preserved, Call.first.getGUID());
+ }
+@@ -910,6 +910,11 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
+ addPreservedGUID(Index, Preserved, GUID);
+ }
+ }
++ if (isa<AliasSummary>(GVSummary)) {
++ auto *AS = cast<AliasSummary>(GVSummary);
++ auto GUID = AS->getAliasee().getOriginalName();
++ addPreservedGUID(Index, Preserved, GUID);
++ }
+ }
+ #else
+ auto SummaryList = Index.findGlobalValueSummaryList(GUID);
+@@ -997,6 +1002,15 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule
*modules,
+ // combined index
+ //
+ // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
++#if LLVM_VERSION_GE(5, 0)
++ computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
++ ComputeCrossModuleImport(
++ Ret->Index,
++ Ret->ModuleToDefinedGVSummaries,
++ Ret->ImportLists,
++ Ret->ExportLists
++ );
++#else
+ auto DeadSymbols = computeDeadSymbols(Ret->Index,
Ret->GUIDPreservedSymbols);
+ ComputeCrossModuleImport(
+ Ret->Index,
+@@ -1005,6 +1019,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule
*modules,
+ Ret->ExportLists,
+ &DeadSymbols
+ );
++#endif
+
+ // Resolve LinkOnce/Weak symbols, this has to be computed early be cause
it
+ // impacts the caching.
+--
+2.15.0
+



  • [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (20feee5cda2afd7824cf60a0c424b368f4bd474e), Pavel Vinogradov, 11/23/2017

Archive powered by MHonArc 2.6.24.

Top of Page