Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5098ba6a
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5098ba6a
编写于
11月 24, 2019
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move linking ouside the interface queries.
上级
266ede1b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
67 addition
and
32 deletion
+67
-32
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+23
-12
src/librustc_interface/queries.rs
src/librustc_interface/queries.rs
+44
-20
未找到文件。
src/librustc_driver/lib.rs
浏览文件 @
5098ba6a
...
...
@@ -283,7 +283,7 @@ pub fn run_compiler(
return
sess
.compile_status
();
}
compiler
.enter
(|
queries
|
{
let
linker
=
compiler
.enter
(|
queries
|
{
queries
.parse
()
?
;
if
let
Some
(
ppm
)
=
&
sess
.opts.pretty
{
...
...
@@ -309,17 +309,20 @@ pub fn run_compiler(
compiler
.output_file
()
.as_ref
()
.map
(|
p
|
&**
p
),
);
}
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
if
callbacks
.after_parsing
(
compiler
)
==
Compilation
::
Stop
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
if
sess
.opts.debugging_opts.parse_only
||
sess
.opts.debugging_opts.show_span
.is_some
()
||
sess
.opts.debugging_opts.ast_json_noexpand
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
{
...
...
@@ -328,13 +331,15 @@ pub fn run_compiler(
// Lint plugins are registered; now we can process command line flags.
if
sess
.opts.describe_lints
{
describe_lints
(
&
sess
,
&
lint_store
,
true
);
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
}
queries
.expansion
()
?
;
if
callbacks
.after_expansion
(
compiler
)
==
Compilation
::
Stop
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
queries
.prepare_outputs
()
?
;
...
...
@@ -342,14 +347,16 @@ pub fn run_compiler(
if
sess
.opts.output_types
.contains_key
(
&
OutputType
::
DepInfo
)
&&
sess
.opts.output_types
.len
()
==
1
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
queries
.global_ctxt
()
?
;
if
sess
.opts.debugging_opts.no_analysis
||
sess
.opts.debugging_opts.ast_json
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
if
sess
.opts.debugging_opts.save_analysis
{
...
...
@@ -381,7 +388,8 @@ pub fn run_compiler(
queries
.global_ctxt
()
?
.peek_mut
()
.enter
(|
tcx
|
tcx
.analysis
(
LOCAL_CRATE
))
?
;
if
callbacks
.after_analysis
(
compiler
)
==
Compilation
::
Stop
{
return
sess
.compile_status
();
sess
.compile_status
()
?
;
return
Ok
(
None
);
}
if
sess
.opts.debugging_opts.save_analysis
{
...
...
@@ -397,11 +405,14 @@ pub fn run_compiler(
sess
.code_stats
.print_type_sizes
();
}
queries
.link
()
?
;
Ok
(())
let
linker
=
queries
.linker
()
?
;
Ok
(
Some
(
linker
))
})
?
;
if
let
Some
(
linker
)
=
linker
{
linker
.link
()
?
}
if
sess
.opts.debugging_opts.perf_stats
{
sess
.print_perf_stats
();
}
...
...
src/librustc_interface/queries.rs
浏览文件 @
5098ba6a
...
...
@@ -81,7 +81,6 @@ pub struct Queries<'comp> {
prepare_outputs
:
Query
<
OutputFilenames
>
,
global_ctxt
:
Query
<
BoxedGlobalCtxt
>
,
ongoing_codegen
:
Query
<
Box
<
dyn
Any
>>
,
link
:
Query
<
()
>
,
}
impl
<
'comp
>
Queries
<
'comp
>
{
...
...
@@ -98,7 +97,6 @@ pub fn new(compiler: &'comp Compiler) -> Queries<'comp> {
prepare_outputs
:
Default
::
default
(),
global_ctxt
:
Default
::
default
(),
ongoing_codegen
:
Default
::
default
(),
link
:
Default
::
default
(),
}
}
...
...
@@ -278,24 +276,43 @@ pub fn ongoing_codegen(&self) -> Result<&Query<Box<dyn Any>>> {
})
}
pub
fn
link
(
&
self
)
->
Result
<&
Query
<
()
>>
{
self
.link
.compute
(||
{
let
sess
=
self
.session
();
pub
fn
linker
(
self
)
->
Result
<
Linker
>
{
let
dep_graph
=
self
.dep_graph
()
?
;
let
prepare_outputs
=
self
.prepare_outputs
()
?
;
let
ongoing_codegen
=
self
.ongoing_codegen
()
?
;
let
ongoing_codegen
=
self
.ongoing_codegen
()
?
.take
();
let
sess
=
self
.session
()
.clone
();
let
codegen_backend
=
self
.codegen_backend
()
.clone
();
self
.codegen_backend
()
.join_codegen_and_link
(
ongoing_codegen
,
sess
,
&*
self
.dep_graph
()
?
.peek
(),
&*
self
.prepare_outputs
()
?
.peek
(),
)
.map_err
(|
_
|
ErrorReported
)
?
;
Ok
(())
Ok
(
Linker
{
sess
,
dep_graph
:
dep_graph
.take
(),
prepare_outputs
:
prepare_outputs
.take
(),
ongoing_codegen
:
ongoing_codegen
.take
(),
codegen_backend
,
})
}
}
pub
struct
Linker
{
sess
:
Lrc
<
Session
>
,
dep_graph
:
DepGraph
,
prepare_outputs
:
OutputFilenames
,
ongoing_codegen
:
Box
<
dyn
Any
>
,
codegen_backend
:
Lrc
<
Box
<
dyn
CodegenBackend
>>
,
}
impl
Linker
{
pub
fn
link
(
self
)
->
Result
<
()
>
{
self
.codegen_backend
.join_codegen_and_link
(
self
.ongoing_codegen
,
&
self
.sess
,
&
self
.dep_graph
,
&
self
.prepare_outputs
,
)
.map_err
(|
_
|
ErrorReported
)
}
}
impl
Compiler
{
// This method is different to all the other methods in `Compiler` because
// it lacks a `Queries` entry. It's also not currently used. It does serve
...
...
@@ -303,10 +320,10 @@ impl Compiler {
// between some passes. And see `rustc_driver::run_compiler` for a more
// complex example.
pub
fn
enter
<
'c
,
F
,
T
>
(
&
'c
self
,
f
:
F
)
->
Result
<
T
>
where
F
:
for
<
'q
>
FnOnce
(
&
'q
Queries
<
'c
>
)
->
Result
<
T
>
where
F
:
FnOnce
(
Queries
<
'c
>
)
->
Result
<
T
>
{
let
queries
=
Queries
::
new
(
&
self
);
f
(
&
queries
)
f
(
queries
)
}
// This method is different to all the other methods in `Compiler` because
...
...
@@ -315,13 +332,13 @@ pub fn enter<'c, F, T>(&'c self, f: F) -> Result<T>
// between some passes. And see `rustc_driver::run_compiler` for a more
// complex example.
pub
fn
compile
(
&
self
)
->
Result
<
()
>
{
self
.enter
(|
queries
|
{
let
linker
=
self
.enter
(|
queries
|
{
queries
.prepare_outputs
()
?
;
if
self
.session
()
.opts.output_types
.contains_key
(
&
OutputType
::
DepInfo
)
&&
self
.session
()
.opts.output_types
.len
()
==
1
{
return
Ok
(
()
)
return
Ok
(
None
)
}
queries
.global_ctxt
()
?
;
...
...
@@ -334,7 +351,14 @@ pub fn compile(&self) -> Result<()> {
// Drop GlobalCtxt after starting codegen to free memory.
mem
::
drop
(
queries
.global_ctxt
()
?
.take
());
queries
.link
()
.map
(|
_
|
())
})
let
linker
=
queries
.linker
()
?
;
Ok
(
Some
(
linker
))
})
?
;
if
let
Some
(
linker
)
=
linker
{
linker
.link
()
?
}
Ok
(())
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录