Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ca2ff089
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,发现更多精彩内容 >>
提交
ca2ff089
编写于
3月 01, 2019
作者:
B
bjorn3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove MetadataOnlyCodegenBackend
上级
52e88562
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
2 addition
and
150 deletion
+2
-150
Cargo.lock
Cargo.lock
+0
-1
src/librustc_codegen_utils/Cargo.toml
src/librustc_codegen_utils/Cargo.toml
+0
-1
src/librustc_codegen_utils/codegen_backend.rs
src/librustc_codegen_utils/codegen_backend.rs
+2
-144
src/librustc_codegen_utils/lib.rs
src/librustc_codegen_utils/lib.rs
+0
-1
src/librustc_interface/util.rs
src/librustc_interface/util.rs
+0
-3
未找到文件。
Cargo.lock
浏览文件 @
ca2ff089
...
...
@@ -2650,7 +2650,6 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_incremental 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
...
...
src/librustc_codegen_utils/Cargo.toml
浏览文件 @
ca2ff089
...
...
@@ -21,4 +21,3 @@ rustc_target = { path = "../librustc_target" }
rustc_data_structures
=
{
path
=
"../librustc_data_structures"
}
rustc_metadata
=
{
path
=
"../librustc_metadata"
}
rustc_mir
=
{
path
=
"../librustc_mir"
}
rustc_incremental
=
{
path
=
"../librustc_incremental"
}
src/librustc_codegen_utils/codegen_backend.rs
浏览文件 @
ca2ff089
...
...
@@ -10,27 +10,16 @@
#![feature(box_syntax)]
use
std
::
any
::
Any
;
use
std
::
io
::
Write
;
use
std
::
fs
;
use
std
::
path
::
Path
;
use
std
::
sync
::{
mpsc
,
Arc
};
use
rustc_data_structures
::
owning_ref
::
OwningRef
;
use
flate2
::
Compression
;
use
flate2
::
write
::
DeflateEncoder
;
use
std
::
sync
::
mpsc
;
use
syntax
::
symbol
::
Symbol
;
use
rustc
::
hir
::
def_id
::
LOCAL_CRATE
;
use
rustc
::
session
::
Session
;
use
rustc
::
util
::
common
::
ErrorReported
;
use
rustc
::
session
::
config
::{
CrateType
,
OutputFilenames
,
PrintRequest
};
use
rustc
::
session
::
config
::{
OutputFilenames
,
PrintRequest
};
use
rustc
::
ty
::
TyCtxt
;
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
middle
::
cstore
::
EncodedMetadata
;
use
rustc
::
middle
::
cstore
::
MetadataLoader
;
use
rustc
::
dep_graph
::
DepGraph
;
use
rustc_target
::
spec
::
Target
;
use
crate
::
link
::
out_filename
;
pub
use
rustc_data_structures
::
sync
::
MetadataRef
;
...
...
@@ -64,134 +53,3 @@ fn join_codegen_and_link(
outputs
:
&
OutputFilenames
,
)
->
Result
<
(),
ErrorReported
>
;
}
pub
struct
NoLlvmMetadataLoader
;
impl
MetadataLoader
for
NoLlvmMetadataLoader
{
fn
get_rlib_metadata
(
&
self
,
_
:
&
Target
,
filename
:
&
Path
)
->
Result
<
MetadataRef
,
String
>
{
let
buf
=
fs
::
read
(
filename
)
.map_err
(|
e
|
format!
(
"metadata file open err: {:?}"
,
e
))
?
;
let
buf
:
OwningRef
<
Vec
<
u8
>
,
[
u8
]
>
=
OwningRef
::
new
(
buf
);
Ok
(
rustc_erase_owner!
(
buf
.map_owner_box
()))
}
fn
get_dylib_metadata
(
&
self
,
target
:
&
Target
,
filename
:
&
Path
)
->
Result
<
MetadataRef
,
String
>
{
self
.get_rlib_metadata
(
target
,
filename
)
}
}
pub
struct
MetadataOnlyCodegenBackend
(());
pub
struct
OngoingCodegen
{
metadata
:
EncodedMetadata
,
metadata_version
:
Vec
<
u8
>
,
crate_name
:
Symbol
,
}
impl
MetadataOnlyCodegenBackend
{
pub
fn
boxed
()
->
Box
<
dyn
CodegenBackend
>
{
box
MetadataOnlyCodegenBackend
(())
}
}
impl
CodegenBackend
for
MetadataOnlyCodegenBackend
{
fn
init
(
&
self
,
sess
:
&
Session
)
{
for
cty
in
sess
.opts.crate_types
.iter
()
{
match
*
cty
{
CrateType
::
Rlib
|
CrateType
::
Dylib
|
CrateType
::
Executable
=>
{},
_
=>
{
sess
.diagnostic
()
.warn
(
&
format!
(
"LLVM unsupported, so output type {} is not supported"
,
cty
)
);
},
}
}
}
fn
metadata_loader
(
&
self
)
->
Box
<
dyn
MetadataLoader
+
Sync
>
{
box
NoLlvmMetadataLoader
}
fn
provide
(
&
self
,
providers
:
&
mut
Providers
<
'_
>
)
{
crate
::
symbol_names
::
provide
(
providers
);
providers
.target_features_whitelist
=
|
_
tcx
,
_
cnum
|
{
Default
::
default
()
// Just a dummy
};
providers
.is_reachable_non_generic
=
|
_
tcx
,
_
defid
|
true
;
providers
.exported_symbols
=
|
_
tcx
,
_
crate
|
Arc
::
new
(
Vec
::
new
());
}
fn
provide_extern
(
&
self
,
providers
:
&
mut
Providers
<
'_
>
)
{
providers
.is_reachable_non_generic
=
|
_
tcx
,
_
defid
|
true
;
}
fn
codegen_crate
<
'a
,
'tcx
>
(
&
self
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
_
rx
:
mpsc
::
Receiver
<
Box
<
dyn
Any
+
Send
>>
)
->
Box
<
dyn
Any
>
{
use
rustc_mir
::
monomorphize
::
item
::
MonoItem
;
crate
::
check_for_rustc_errors_attr
(
tcx
);
crate
::
symbol_names_test
::
report_symbol_names
(
tcx
);
rustc_incremental
::
assert_dep_graph
(
tcx
);
rustc_incremental
::
assert_module_sources
::
assert_module_sources
(
tcx
);
// FIXME: Fix this
// rustc::middle::dependency_format::calculate(tcx);
let
_
=
tcx
.link_args
(
LOCAL_CRATE
);
let
_
=
tcx
.native_libraries
(
LOCAL_CRATE
);
let
(
_
,
cgus
)
=
tcx
.collect_and_partition_mono_items
(
LOCAL_CRATE
);
for
(
mono_item
,
_
)
in
cgus
.iter
()
.flat_map
(|
cgu
|
cgu
.items
()
.iter
())
{
if
let
MonoItem
::
Fn
(
inst
)
=
mono_item
{
let
def_id
=
inst
.def_id
();
if
def_id
.is_local
()
{
let
_
=
tcx
.codegen_fn_attrs
(
def_id
);
}
}
}
tcx
.sess
.abort_if_errors
();
let
metadata
=
tcx
.encode_metadata
();
box
OngoingCodegen
{
metadata
,
metadata_version
:
tcx
.metadata_encoding_version
()
.to_vec
(),
crate_name
:
tcx
.crate_name
(
LOCAL_CRATE
),
}
}
fn
join_codegen_and_link
(
&
self
,
ongoing_codegen
:
Box
<
dyn
Any
>
,
sess
:
&
Session
,
_
dep_graph
:
&
DepGraph
,
outputs
:
&
OutputFilenames
,
)
->
Result
<
(),
ErrorReported
>
{
let
ongoing_codegen
=
ongoing_codegen
.downcast
::
<
OngoingCodegen
>
()
.expect
(
"Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<dyn Any>"
);
for
&
crate_type
in
sess
.opts.crate_types
.iter
()
{
if
crate_type
!=
CrateType
::
Rlib
&&
crate_type
!=
CrateType
::
Dylib
{
continue
;
}
let
output_name
=
out_filename
(
sess
,
crate_type
,
&
outputs
,
&
ongoing_codegen
.crate_name
.as_str
());
let
mut
compressed
=
ongoing_codegen
.metadata_version
.clone
();
let
metadata
=
if
crate_type
==
CrateType
::
Dylib
{
DeflateEncoder
::
new
(
&
mut
compressed
,
Compression
::
fast
())
.write_all
(
&
ongoing_codegen
.metadata.raw_data
)
.unwrap
();
&
compressed
}
else
{
&
ongoing_codegen
.metadata.raw_data
};
fs
::
write
(
&
output_name
,
metadata
)
.unwrap
();
}
sess
.abort_if_errors
();
if
!
sess
.opts.crate_types
.contains
(
&
CrateType
::
Rlib
)
&&
!
sess
.opts.crate_types
.contains
(
&
CrateType
::
Dylib
)
{
sess
.fatal
(
"Executables are not supported by the metadata-only backend."
);
}
Ok
(())
}
}
src/librustc_codegen_utils/lib.rs
浏览文件 @
ca2ff089
...
...
@@ -19,7 +19,6 @@
#[macro_use]
extern
crate
rustc
;
#[macro_use]
extern
crate
rustc_data_structures
;
use
rustc
::
ty
::
TyCtxt
;
use
rustc
::
hir
::
def_id
::
LOCAL_CRATE
;
...
...
src/librustc_interface/util.rs
浏览文件 @
ca2ff089
...
...
@@ -266,9 +266,6 @@ pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
let
codegen_name
=
sess
.opts.debugging_opts.codegen_backend
.as_ref
()
.unwrap_or
(
&
sess
.target.target.options.codegen_backend
);
let
backend
=
match
&
codegen_name
[
..
]
{
"metadata_only"
=>
{
rustc_codegen_utils
::
codegen_backend
::
MetadataOnlyCodegenBackend
::
boxed
}
filename
if
filename
.contains
(
"."
)
=>
{
load_backend_from_dylib
(
filename
.as_ref
())
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录