Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a619901e
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,发现更多精彩内容 >>
提交
a619901e
编写于
5月 25, 2016
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trans: save metadata even with -Z no-trans.
上级
04464db9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
33 deletion
+58
-33
src/librustc/session/config.rs
src/librustc/session/config.rs
+1
-1
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+0
-4
src/librustc_trans/back/link.rs
src/librustc_trans/back/link.rs
+5
-0
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+41
-28
src/librustc_trans/context.rs
src/librustc_trans/context.rs
+4
-0
src/tools/compiletest/src/runtest.rs
src/tools/compiletest/src/runtest.rs
+7
-0
未找到文件。
src/librustc/session/config.rs
浏览文件 @
a619901e
...
...
@@ -1104,7 +1104,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let
no_analysis
=
debugging_opts
.no_analysis
;
let
mut
output_types
=
HashMap
::
new
();
if
!
debugging_opts
.parse_only
&&
!
no_trans
{
if
!
debugging_opts
.parse_only
{
for
list
in
matches
.opt_strs
(
"emit"
)
{
for
output_type
in
list
.split
(
','
)
{
let
mut
parts
=
output_type
.splitn
(
2
,
'='
);
...
...
src/librustc_driver/lib.rs
浏览文件 @
a619901e
...
...
@@ -511,10 +511,6 @@ fn build_controller(&mut self,
control
.after_write_deps.stop
=
Compilation
::
Stop
;
}
if
sess
.opts.no_trans
{
control
.after_analysis.stop
=
Compilation
::
Stop
;
}
if
!
sess
.opts.output_types
.keys
()
.any
(|
&
i
|
i
==
OutputType
::
Exe
)
{
control
.after_llvm.stop
=
Compilation
::
Stop
;
}
...
...
src/librustc_trans/back/link.rs
浏览文件 @
a619901e
...
...
@@ -188,6 +188,11 @@ pub fn link_binary(sess: &Session,
let
mut
out_filenames
=
Vec
::
new
();
for
&
crate_type
in
sess
.crate_types
.borrow
()
.iter
()
{
// Ignore executable crates if we have -Z no-trans, as they will error.
if
sess
.opts.no_trans
&&
crate_type
==
config
::
CrateTypeExecutable
{
continue
;
}
if
invalid_output_for_target
(
sess
,
crate_type
)
{
bug!
(
"invalid output type `{:?}` for target os `{}`"
,
crate_type
,
sess
.opts.target_triple
);
...
...
src/librustc_trans/base.rs
浏览文件 @
a619901e
...
...
@@ -2432,11 +2432,8 @@ fn contains_null(s: &str) -> bool {
s
.bytes
()
.any
(|
b
|
b
==
0
)
}
pub
fn
write_metadata
<
'a
,
'tcx
>
(
cx
:
&
SharedCrateContext
<
'a
,
'tcx
>
,
krate
:
&
hir
::
Crate
,
reachable
:
&
NodeSet
,
mir_map
:
&
MirMap
<
'tcx
>
)
->
Vec
<
u8
>
{
fn
write_metadata
(
cx
:
&
SharedCrateContext
,
reachable_ids
:
&
NodeSet
)
->
Vec
<
u8
>
{
use
flate
;
let
any_library
=
cx
.sess
()
...
...
@@ -2452,9 +2449,9 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
let
metadata
=
cstore
.encode_metadata
(
cx
.tcx
(),
cx
.export_map
(),
cx
.link_meta
(),
reachable
,
mir_map
,
krate
);
reachable
_ids
,
cx
.mir_map
()
,
cx
.tcx
()
.map
.krate
()
);
let
mut
compressed
=
cstore
.metadata_encoding_version
()
.to_vec
();
compressed
.extend_from_slice
(
&
flate
::
deflate_bytes
(
&
metadata
));
...
...
@@ -2639,10 +2636,12 @@ pub fn filter_reachable_ids(scx: &SharedCrateContext) -> NodeSet {
node
:
hir
::
ItemStatic
(
..
),
..
})
|
hir_map
::
NodeItem
(
&
hir
::
Item
{
node
:
hir
::
ItemFn
(
..
),
..
})
|
hir_map
::
NodeTraitItem
(
&
hir
::
TraitItem
{
node
:
hir
::
MethodTraitItem
(
_
,
Some
(
_
)),
..
})
|
hir_map
::
NodeImplItem
(
&
hir
::
ImplItem
{
node
:
hir
::
ImplItemKind
::
Method
(
..
),
..
})
=>
true
,
node
:
hir
::
ImplItemKind
::
Method
(
..
),
..
})
=>
{
let
def_id
=
scx
.tcx
()
.map
.local_def_id
(
id
);
let
scheme
=
scx
.tcx
()
.lookup_item_type
(
def_id
);
scheme
.generics.types
.is_empty
()
}
_
=>
false
}
...
...
@@ -2686,6 +2685,19 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
check_overflow
,
check_dropflag
);
let
reachable_symbol_ids
=
filter_reachable_ids
(
&
shared_ccx
);
// Translate the metadata.
let
metadata
=
time
(
tcx
.sess
.time_passes
(),
"write metadata"
,
||
{
write_metadata
(
&
shared_ccx
,
&
reachable_symbol_ids
)
});
let
metadata_module
=
ModuleTranslation
{
llcx
:
shared_ccx
.metadata_llcx
(),
llmod
:
shared_ccx
.metadata_llmod
(),
};
let
no_builtins
=
attr
::
contains_name
(
&
krate
.attrs
,
"no_builtins"
);
let
codegen_units
=
collect_and_partition_translation_items
(
&
shared_ccx
);
let
codegen_unit_count
=
codegen_units
.len
();
assert
!
(
tcx
.sess.opts.cg.codegen_units
==
codegen_unit_count
||
...
...
@@ -2693,6 +2705,24 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let
crate_context_list
=
CrateContextList
::
new
(
&
shared_ccx
,
codegen_units
);
let
modules
=
crate_context_list
.iter
()
.map
(|
ccx
|
ModuleTranslation
{
llcx
:
ccx
.llcx
(),
llmod
:
ccx
.llmod
()
})
.collect
();
// Skip crate items and just output metadata in -Z no-trans mode.
if
tcx
.sess.opts.no_trans
{
let
linker_info
=
LinkerInfo
::
new
(
&
shared_ccx
,
&
[]);
return
CrateTranslation
{
modules
:
modules
,
metadata_module
:
metadata_module
,
link
:
link_meta
,
metadata
:
metadata
,
reachable
:
vec!
[],
no_builtins
:
no_builtins
,
linker_info
:
linker_info
};
}
{
let
ccx
=
crate_context_list
.get_ccx
(
0
);
...
...
@@ -2722,13 +2752,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
let
reachable_symbol_ids
=
filter_reachable_ids
(
&
shared_ccx
);
// Translate the metadata.
let
metadata
=
time
(
tcx
.sess
.time_passes
(),
"write metadata"
,
||
{
write_metadata
(
&
shared_ccx
,
krate
,
&
reachable_symbol_ids
,
mir_map
)
});
if
shared_ccx
.sess
()
.trans_stats
()
{
let
stats
=
shared_ccx
.stats
();
println!
(
"--- trans stats ---"
);
...
...
@@ -2758,10 +2781,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
let
modules
=
crate_context_list
.iter
()
.map
(|
ccx
|
ModuleTranslation
{
llcx
:
ccx
.llcx
(),
llmod
:
ccx
.llmod
()
})
.collect
();
let
sess
=
shared_ccx
.sess
();
let
mut
reachable_symbols
=
reachable_symbol_ids
.iter
()
.map
(|
&
id
|
{
let
def_id
=
shared_ccx
.tcx
()
.map
.local_def_id
(
id
);
...
...
@@ -2802,12 +2821,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
create_imps
(
&
crate_context_list
);
}
let
metadata_module
=
ModuleTranslation
{
llcx
:
shared_ccx
.metadata_llcx
(),
llmod
:
shared_ccx
.metadata_llmod
(),
};
let
no_builtins
=
attr
::
contains_name
(
&
krate
.attrs
,
"no_builtins"
);
let
linker_info
=
LinkerInfo
::
new
(
&
shared_ccx
,
&
reachable_symbols
);
CrateTranslation
{
modules
:
modules
,
...
...
src/librustc_trans/context.rs
浏览文件 @
a619901e
...
...
@@ -502,6 +502,10 @@ pub fn symbol_hasher(&self) -> &RefCell<Sha256> {
&
self
.symbol_hasher
}
pub
fn
mir_map
(
&
self
)
->
&
MirMap
<
'tcx
>
{
&
self
.mir_map
}
pub
fn
metadata_symbol_name
(
&
self
)
->
String
{
format!
(
"rust_metadata_{}_{}"
,
self
.link_meta
()
.crate_name
,
...
...
src/tools/compiletest/src/runtest.rs
浏览文件 @
a619901e
...
...
@@ -371,9 +371,16 @@ fn make_typecheck_args(&self) -> ProcArgs {
}
else
{
&*
self
.config.target
};
let
out_dir
=
self
.output_base_name
()
.with_extension
(
"pretty-out"
);
let
_
=
fs
::
remove_dir_all
(
&
out_dir
);
self
.create_dir_racy
(
&
out_dir
);
// FIXME (#9639): This needs to handle non-utf8 paths
let
mut
args
=
vec!
(
"-"
.to_owned
(),
"-Zno-trans"
.to_owned
(),
"--out-dir"
.to_owned
(),
out_dir
.to_str
()
.unwrap
()
.to_owned
(),
format!
(
"--target={}"
,
target
),
"-L"
.to_owned
(),
self
.config.build_base
.to_str
()
.unwrap
()
.to_owned
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录