Skip to content

Commit df0466d

Browse files
committed
Rebase to the llvm-project monorepo
The new git submodule src/llvm-project is a monorepo replacing src/llvm and src/tools/{clang,lld,lldb}. This also serves as a rebase for these projects to the new 8.x branch from trunk. The src/llvm-emscripten fork is unchanged for now.
1 parent bf669d1 commit df0466d

File tree

18 files changed

+166
-65
lines changed

18 files changed

+166
-65
lines changed

.gitmodules

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[submodule "src/llvm"]
2-
path = src/llvm
3-
url = https://github.com/rust-lang/llvm.git
4-
branch = master
51
[submodule "src/rust-installer"]
62
path = src/tools/rust-installer
73
url = https://github.com/rust-lang/rust-installer.git
@@ -38,20 +34,13 @@
3834
[submodule "src/stdsimd"]
3935
path = src/stdsimd
4036
url = https://github.com/rust-lang-nursery/stdsimd.git
41-
[submodule "src/tools/lld"]
42-
path = src/tools/lld
43-
url = https://github.com/rust-lang/lld.git
44-
[submodule "src/tools/lldb"]
45-
path = src/tools/lldb
46-
url = https://github.com/rust-lang-nursery/lldb.git
47-
branch = rust-release-80-v2
48-
[submodule "src/tools/clang"]
49-
path = src/tools/clang
50-
url = https://github.com/rust-lang-nursery/clang.git
51-
branch = rust-release-80-v2
5237
[submodule "src/doc/rustc-guide"]
5338
path = src/doc/rustc-guide
5439
url = https://github.com/rust-lang/rustc-guide.git
5540
[submodule "src/doc/edition-guide"]
5641
path = src/doc/edition-guide
57-
url = https://github.com/rust-lang-nursery/edition-guide
42+
url = https://github.com/rust-lang-nursery/edition-guide.git
43+
[submodule "src/llvm-project"]
44+
path = src/llvm-project
45+
url = https://github.com/rust-lang/llvm-project.git
46+
branch = rustc/8.0-2019-01-16

COPYRIGHT

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The Rust Project includes packages written by third parties.
2323
The following third party packages are included, and carry
2424
their own copyright notices and license terms:
2525

26-
* LLVM. Code for this package is found in src/llvm.
26+
* LLVM. Code for this package is found in src/llvm-project.
2727

2828
Copyright (c) 2003-2013 University of Illinois at
2929
Urbana-Champaign. All rights reserved.
@@ -73,8 +73,8 @@ their own copyright notices and license terms:
7373
OTHER DEALINGS WITH THE SOFTWARE.
7474

7575
* Additional libraries included in LLVM carry separate
76-
BSD-compatible licenses. See src/llvm/LICENSE.txt for
77-
details.
76+
BSD-compatible licenses. See src/llvm-project/llvm/LICENSE.TXT
77+
for details.
7878

7979
* compiler-rt, in src/compiler-rt is dual licensed under
8080
LLVM's license and MIT:

src/bootstrap/bootstrap.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -701,21 +701,13 @@ def update_submodules(self):
701701
filtered_submodules = []
702702
submodules_names = []
703703
for module in submodules:
704-
if module.endswith("llvm"):
705-
if self.get_toml('llvm-config'):
704+
if module.endswith("llvm-project"):
705+
if self.get_toml('llvm-config') and self.get_toml('lld') != 'true':
706706
continue
707707
if module.endswith("llvm-emscripten"):
708708
backends = self.get_toml('codegen-backends')
709709
if backends is None or not 'emscripten' in backends:
710710
continue
711-
if module.endswith("lld"):
712-
config = self.get_toml('lld')
713-
if config is None or config == 'false':
714-
continue
715-
if module.endswith("lldb") or module.endswith("clang"):
716-
config = self.get_toml('lldb')
717-
if config is None or config == 'false':
718-
continue
719711
check = self.check_submodule(module, slow_submodules)
720712
filtered_submodules.append((module, check))
721713
submodules_names.append(module)

src/bootstrap/dist.rs

+21-4
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,24 @@ fn copy_src_dirs(builder: &Builder, src_dirs: &[&str], exclude_dirs: &[&str], ds
788788
if spath.ends_with("~") || spath.ends_with(".pyc") {
789789
return false
790790
}
791-
if (spath.contains("llvm/test") || spath.contains("llvm\\test")) &&
791+
792+
const LLVM_PROJECTS: &[&str] = &[
793+
"llvm-project/clang", "llvm-project\\clang",
794+
"llvm-project/lld", "llvm-project\\lld",
795+
"llvm-project/lldb", "llvm-project\\lldb",
796+
"llvm-project/llvm", "llvm-project\\llvm",
797+
];
798+
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
799+
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))
800+
{
801+
return false;
802+
}
803+
804+
const LLVM_TEST: &[&str] = &[
805+
"llvm-project/llvm/test", "llvm-project\\llvm\\test",
806+
"llvm-emscripten/test", "llvm-emscripten\\test",
807+
];
808+
if LLVM_TEST.iter().any(|path| spath.contains(path)) &&
792809
(spath.ends_with(".ll") ||
793810
spath.ends_with(".td") ||
794811
spath.ends_with(".s")) {
@@ -2076,7 +2093,7 @@ impl Step for LlvmTools {
20762093
}
20772094

20782095
builder.info(&format!("Dist LlvmTools stage{} ({})", stage, target));
2079-
let src = builder.src.join("src/llvm");
2096+
let src = builder.src.join("src/llvm-project/llvm");
20802097
let name = pkgname(builder, "llvm-tools");
20812098

20822099
let tmp = tmpdir(builder);
@@ -2135,7 +2152,7 @@ impl Step for Lldb {
21352152
const DEFAULT: bool = true;
21362153

21372154
fn should_run(run: ShouldRun) -> ShouldRun {
2138-
run.path("src/tools/lldb")
2155+
run.path("src/llvm-project/lldb").path("src/tools/lldb")
21392156
}
21402157

21412158
fn make_run(run: RunConfig) {
@@ -2160,7 +2177,7 @@ impl Step for Lldb {
21602177
}
21612178

21622179
builder.info(&format!("Dist Lldb ({})", target));
2163-
let src = builder.src.join("src/tools/lldb");
2180+
let src = builder.src.join("src/llvm-project/lldb");
21642181
let name = pkgname(builder, "lldb");
21652182

21662183
let tmp = tmpdir(builder);

src/bootstrap/native.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ impl Step for Llvm {
3636
const ONLY_HOSTS: bool = true;
3737

3838
fn should_run(run: ShouldRun) -> ShouldRun {
39-
run.path("src/llvm").path("src/llvm-emscripten")
39+
run.path("src/llvm-project")
40+
.path("src/llvm-project/llvm")
41+
.path("src/llvm")
42+
.path("src/llvm-emscripten")
4043
}
4144

4245
fn make_run(run: RunConfig) {
@@ -97,7 +100,7 @@ impl Step for Llvm {
97100
t!(fs::create_dir_all(&out_dir));
98101

99102
// http://llvm.org/docs/CMake.html
100-
let root = if self.emscripten { "src/llvm-emscripten" } else { "src/llvm" };
103+
let root = if self.emscripten { "src/llvm-emscripten" } else { "src/llvm-project/llvm" };
101104
let mut cfg = cmake::Config::new(builder.src.join(root));
102105

103106
let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) {
@@ -189,8 +192,7 @@ impl Step for Llvm {
189192
}
190193

191194
if want_lldb {
192-
cfg.define("LLVM_EXTERNAL_CLANG_SOURCE_DIR", builder.src.join("src/tools/clang"));
193-
cfg.define("LLVM_EXTERNAL_LLDB_SOURCE_DIR", builder.src.join("src/tools/lldb"));
195+
cfg.define("LLVM_ENABLE_PROJECTS", "clang;lldb");
194196
// For the time being, disable code signing.
195197
cfg.define("LLDB_CODESIGN_IDENTITY", "");
196198
} else {
@@ -411,7 +413,7 @@ impl Step for Lld {
411413
const ONLY_HOSTS: bool = true;
412414

413415
fn should_run(run: ShouldRun) -> ShouldRun {
414-
run.path("src/tools/lld")
416+
run.path("src/llvm-project/lld").path("src/tools/lld")
415417
}
416418

417419
fn make_run(run: RunConfig) {
@@ -441,7 +443,7 @@ impl Step for Lld {
441443
let _time = util::timeit(&builder);
442444
t!(fs::create_dir_all(&out_dir));
443445

444-
let mut cfg = cmake::Config::new(builder.src.join("src/tools/lld"));
446+
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
445447
configure_cmake(builder, target, &mut cfg);
446448

447449
// This is an awful, awful hack. Discovered when we migrated to using

src/ci/init_repo.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function fetch_submodule {
4545
rm $cached
4646
}
4747

48-
included="src/llvm src/llvm-emscripten src/doc/book src/doc/rust-by-example"
49-
included="$included src/tools/lld src/tools/clang src/tools/lldb"
48+
included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example"
5049
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
5150
modules=($modules)
5251
use_git=""

src/librustc_codegen_llvm/debuginfo/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
1212

1313
use llvm;
1414
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DISubprogram, DIArray, DIFlags,
15-
DILexicalBlock};
15+
DISPFlags, DILexicalBlock};
1616
use rustc::hir::CodegenFnAttrFlags;
1717
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
1818
use rustc::ty::subst::{Substs, UnpackedKind};
@@ -283,7 +283,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
283283
let linkage_name = mangled_name_of_instance(self, instance);
284284

285285
let scope_line = span_start(self, span).line;
286-
let is_local_to_unit = is_node_local_to_unit(self, def_id);
287286

288287
let function_name = CString::new(name).unwrap();
289288
let linkage_name = SmallCStr::new(&linkage_name.as_str());
@@ -300,6 +299,14 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
300299
flags |= DIFlags::FlagNoReturn;
301300
}
302301

302+
let mut spflags = DISPFlags::SPFlagDefinition;
303+
if is_node_local_to_unit(self, def_id) {
304+
spflags |= DISPFlags::SPFlagLocalToUnit;
305+
}
306+
if self.sess().opts.optimize != config::OptLevel::No {
307+
spflags |= DISPFlags::SPFlagOptimized;
308+
}
309+
303310
let fn_metadata = unsafe {
304311
llvm::LLVMRustDIBuilderCreateFunction(
305312
DIB(self),
@@ -309,11 +316,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
309316
file_metadata,
310317
loc.line as c_uint,
311318
function_type_metadata,
312-
is_local_to_unit,
313-
true,
314319
scope_line as c_uint,
315320
flags,
316-
self.sess().opts.optimize != config::OptLevel::No,
321+
spflags,
317322
llfn,
318323
template_parameters,
319324
None)

src/librustc_codegen_llvm/llvm/ffi.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::debuginfo::{
22
DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
33
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
44
DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
5-
DINameSpace, DIFlags,
5+
DINameSpace, DIFlags, DISPFlags,
66
};
77

88
use libc::{c_uint, c_int, size_t, c_char};
@@ -591,6 +591,20 @@ pub mod debuginfo {
591591
const FlagMainSubprogram = (1 << 21);
592592
}
593593
}
594+
595+
// These values **must** match with LLVMRustDISPFlags!!
596+
bitflags! {
597+
#[repr(C)]
598+
#[derive(Default)]
599+
pub struct DISPFlags: ::libc::uint32_t {
600+
const SPFlagZero = 0;
601+
const SPFlagVirtual = 1;
602+
const SPFlagPureVirtual = 2;
603+
const SPFlagLocalToUnit = (1 << 2);
604+
const SPFlagDefinition = (1 << 3);
605+
const SPFlagOptimized = (1 << 4);
606+
}
607+
}
594608
}
595609

596610
extern { pub type ModuleBuffer; }
@@ -1387,11 +1401,9 @@ extern "C" {
13871401
File: &'a DIFile,
13881402
LineNo: c_uint,
13891403
Ty: &'a DIType,
1390-
isLocalToUnit: bool,
1391-
isDefinition: bool,
13921404
ScopeLine: c_uint,
13931405
Flags: DIFlags,
1394-
isOptimized: bool,
1406+
SPFlags: DISPFlags,
13951407
Fn: &'a Value,
13961408
TParam: &'a DIArray,
13971409
Decl: Option<&'a DIDescriptor>)
@@ -1529,7 +1541,7 @@ extern "C" {
15291541
AlignInBits: u32,
15301542
Elements: &'a DIArray,
15311543
ClassType: &'a DIType,
1532-
IsFixed: bool)
1544+
IsScoped: bool)
15331545
-> &'a DIType;
15341546

15351547
pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,

src/llvm

-1
This file was deleted.

src/llvm-project

Submodule llvm-project added at a27fbee

src/rustllvm/PassWrapper.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ struct LLVMRustThinLTOData {
789789
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
790790

791791
#if LLVM_VERSION_GE(7, 0)
792-
LLVMRustThinLTOData() : Index(/* isPerformingAnalysis = */ false) {}
792+
LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}
793793
#endif
794794
};
795795

@@ -865,7 +865,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
865865
auto deadIsPrevailing = [&](GlobalValue::GUID G) {
866866
return PrevailingType::Unknown;
867867
};
868+
#if LLVM_VERSION_GE(8, 0)
869+
computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
870+
deadIsPrevailing, /* ImportEnabled = */ true);
871+
#else
868872
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
873+
#endif
869874
#else
870875
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
871876
#endif

0 commit comments

Comments
 (0)