Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
205bc9a8
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
205bc9a8
编写于
8月 28, 2017
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Migrate `CStore::native_libraries` to a query
上级
98b74c58
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
27 addition
and
16 deletion
+27
-16
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+1
-0
src/librustc/middle/cstore.rs
src/librustc/middle/cstore.rs
+0
-3
src/librustc/ty/maps.rs
src/librustc/ty/maps.rs
+8
-1
src/librustc_metadata/cstore_impl.rs
src/librustc_metadata/cstore_impl.rs
+1
-5
src/librustc_trans/back/link.rs
src/librustc_trans/back/link.rs
+9
-6
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+2
-0
src/librustc_trans/lib.rs
src/librustc_trans/lib.rs
+6
-1
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
205bc9a8
...
...
@@ -536,6 +536,7 @@ pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode {
[]
IsNoBuiltins
(
CrateNum
),
[]
ImplDefaultness
(
DefId
),
[]
ExportedSymbols
(
CrateNum
),
[]
NativeLibraries
(
CrateNum
),
);
trait
DepNodeParams
<
'a
,
'gcx
:
'tcx
+
'a
,
'tcx
:
'a
>
:
fmt
::
Debug
{
...
...
src/librustc/middle/cstore.rs
浏览文件 @
205bc9a8
...
...
@@ -257,7 +257,6 @@ pub trait CrateStore {
fn
crate_disambiguator
(
&
self
,
cnum
:
CrateNum
)
->
Symbol
;
fn
plugin_registrar_fn
(
&
self
,
cnum
:
CrateNum
)
->
Option
<
DefId
>
;
fn
derive_registrar_fn
(
&
self
,
cnum
:
CrateNum
)
->
Option
<
DefId
>
;
fn
native_libraries
(
&
self
,
cnum
:
CrateNum
)
->
Vec
<
NativeLibrary
>
;
// resolve
fn
def_key
(
&
self
,
def
:
DefId
)
->
DefKey
;
...
...
@@ -364,8 +363,6 @@ fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
{
bug!
(
"plugin_registrar_fn"
)
}
fn
derive_registrar_fn
(
&
self
,
cnum
:
CrateNum
)
->
Option
<
DefId
>
{
bug!
(
"derive_registrar_fn"
)
}
fn
native_libraries
(
&
self
,
cnum
:
CrateNum
)
->
Vec
<
NativeLibrary
>
{
bug!
(
"native_libraries"
)
}
// resolve
fn
def_key
(
&
self
,
def
:
DefId
)
->
DefKey
{
bug!
(
"def_key"
)
}
...
...
src/librustc/ty/maps.rs
浏览文件 @
205bc9a8
...
...
@@ -15,7 +15,7 @@
use
hir
::{
self
,
TraitCandidate
,
HirId
};
use
lint
;
use
middle
::
const_val
;
use
middle
::
cstore
::{
ExternCrate
,
LinkagePreference
};
use
middle
::
cstore
::{
ExternCrate
,
LinkagePreference
,
NativeLibrary
};
use
middle
::
privacy
::
AccessLevels
;
use
middle
::
region
;
use
mir
;
...
...
@@ -593,6 +593,12 @@ fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
}
}
impl
<
'tcx
>
QueryDescription
for
queries
::
native_libraries
<
'tcx
>
{
fn
describe
(
_
tcx
:
TyCtxt
,
_
:
CrateNum
)
->
String
{
format!
(
"looking up the native libraries of a linked crate"
)
}
}
// If enabled, send a message to the profile-queries thread
macro_rules!
profq_msg
{
(
$tcx:expr
,
$msg:expr
)
=>
{
...
...
@@ -1170,6 +1176,7 @@ fn default() -> Self {
[]
fn
impl_defaultness
:
ImplDefaultness
(
DefId
)
->
hir
::
Defaultness
,
[]
fn
exported_symbols
:
ExportedSymbols
(
CrateNum
)
->
Rc
<
Vec
<
DefId
>>
,
[]
fn
native_libraries
:
NativeLibraries
(
CrateNum
)
->
Rc
<
Vec
<
NativeLibrary
>>
,
}
fn
type_param_predicates
<
'tcx
>
((
item_id
,
param_id
):
(
DefId
,
DefId
))
->
DepConstructor
<
'tcx
>
{
...
...
src/librustc_metadata/cstore_impl.rs
浏览文件 @
205bc9a8
...
...
@@ -164,6 +164,7 @@ fn into_def_id(self) -> DefId { self.as_def_id() }
is_no_builtins
=>
{
cdata
.is_no_builtins
(
&
tcx
.dep_graph
)
}
impl_defaultness
=>
{
cdata
.get_impl_defaultness
(
def_id
.index
)
}
exported_symbols
=>
{
Rc
::
new
(
cdata
.get_exported_symbols
(
&
tcx
.dep_graph
))
}
native_libraries
=>
{
Rc
::
new
(
cdata
.get_native_libraries
(
&
tcx
.dep_graph
))
}
}
pub
fn
provide_local
<
'tcx
>
(
providers
:
&
mut
Providers
<
'tcx
>
)
{
...
...
@@ -298,11 +299,6 @@ fn derive_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>
})
}
fn
native_libraries
(
&
self
,
cnum
:
CrateNum
)
->
Vec
<
NativeLibrary
>
{
self
.get_crate_data
(
cnum
)
.get_native_libraries
(
&
self
.dep_graph
)
}
/// Returns the `DefKey` for a given `DefId`. This indicates the
/// parent `DefId` as well as some idea of what kind of data the
/// `DefId` refers to.
...
...
src/librustc_trans/back/link.rs
浏览文件 @
205bc9a8
...
...
@@ -613,7 +613,7 @@ fn link_staticlib(sess: &Session,
let
res
=
each_linked_rlib
(
sess
,
&
mut
|
cnum
,
path
|
{
let
name
=
sess
.cstore
.crate_name
(
cnum
);
let
native_libs
=
sess
.cstore
.native_libraries
(
cnum
)
;
let
native_libs
=
&
trans
.crate_info.native_libraries
[
&
cnum
]
;
// Here when we include the rlib into our staticlib we need to make a
// decision whether to include the extra object files along the way.
...
...
@@ -637,7 +637,7 @@ fn link_staticlib(sess: &Session,
sess
.lto
()
&&
!
ignored_for_lto
(
&
trans
.crate_info
,
cnum
),
skip_object_files
)
.unwrap
();
all_native_libs
.extend
(
sess
.cstore
.native_libraries
(
cnum
));
all_native_libs
.extend
(
trans
.crate_info.native_libraries
[
&
cnum
]
.iter
()
.cloned
(
));
});
if
let
Err
(
e
)
=
res
{
sess
.fatal
(
&
e
);
...
...
@@ -1002,7 +1002,7 @@ fn link_args(cmd: &mut Linker,
// on other dylibs (e.g. other native deps).
add_local_native_libraries
(
cmd
,
sess
);
add_upstream_rust_crates
(
cmd
,
sess
,
trans
,
crate_type
,
tmpdir
);
add_upstream_native_libraries
(
cmd
,
sess
,
crate_type
);
add_upstream_native_libraries
(
cmd
,
sess
,
trans
,
crate_type
);
// Tell the linker what we're doing.
if
crate_type
!=
config
::
CrateTypeExecutable
{
...
...
@@ -1239,7 +1239,7 @@ fn add_static_crate(cmd: &mut Linker,
// See the comment above in `link_staticlib` and `link_rlib` for why if
// there's a static library that's not relevant we skip all object
// files.
let
native_libs
=
sess
.cstore
.native_libraries
(
cnum
)
;
let
native_libs
=
&
trans
.crate_info.native_libraries
[
&
cnum
]
;
let
skip_native
=
native_libs
.iter
()
.any
(|
lib
|
{
lib
.kind
==
NativeLibraryKind
::
NativeStatic
&&
!
relevant_lib
(
sess
,
lib
)
});
...
...
@@ -1352,7 +1352,10 @@ fn add_dynamic_crate(cmd: &mut Linker, sess: &Session, cratepath: &Path) {
// generic function calls a native function, then the generic function must
// be instantiated in the target crate, meaning that the native symbol must
// also be resolved in the target crate.
fn
add_upstream_native_libraries
(
cmd
:
&
mut
Linker
,
sess
:
&
Session
,
crate_type
:
config
::
CrateType
)
{
fn
add_upstream_native_libraries
(
cmd
:
&
mut
Linker
,
sess
:
&
Session
,
trans
:
&
CrateTranslation
,
crate_type
:
config
::
CrateType
)
{
// Be sure to use a topological sorting of crates because there may be
// interdependencies between native libraries. When passing -nodefaultlibs,
// for example, almost all native libraries depend on libc, so we have to
...
...
@@ -1367,7 +1370,7 @@ fn add_upstream_native_libraries(cmd: &mut Linker, sess: &Session, crate_type: c
let
crates
=
sess
.cstore
.used_crates
(
LinkagePreference
::
RequireStatic
);
for
(
cnum
,
_
)
in
crates
{
for
lib
in
sess
.cstore
.native_libraries
(
cnum
)
{
for
lib
in
trans
.crate_info.native_libraries
[
&
cnum
]
.iter
(
)
{
if
!
relevant_lib
(
sess
,
&
lib
)
{
continue
}
...
...
src/librustc_trans/base.rs
浏览文件 @
205bc9a8
...
...
@@ -1515,9 +1515,11 @@ pub fn new(tcx: TyCtxt) -> CrateInfo {
profiler_runtime
:
None
,
sanitizer_runtime
:
None
,
is_no_builtins
:
FxHashSet
(),
native_libraries
:
FxHashMap
(),
};
for
cnum
in
tcx
.sess.cstore
.crates
()
{
info
.native_libraries
.insert
(
cnum
,
tcx
.native_libraries
(
cnum
));
if
tcx
.is_panic_runtime
(
cnum
)
{
info
.panic_runtime
=
Some
(
cnum
);
}
...
...
src/librustc_trans/lib.rs
浏览文件 @
205bc9a8
...
...
@@ -65,8 +65,12 @@
pub
use
metadata
::
LlvmMetadataLoader
;
pub
use
llvm_util
::{
init
,
target_features
,
print_version
,
print_passes
,
print
,
enable_llvm_debug
};
use
std
::
rc
::
Rc
;
use
rustc
::
hir
::
def_id
::
CrateNum
;
use
rustc
::
util
::
nodemap
::
FxHashSet
;
use
rustc
::
util
::
nodemap
::{
FxHashSet
,
FxHashMap
};
use
rustc
::
middle
::
cstore
::
NativeLibrary
;
pub
mod
back
{
mod
archive
;
...
...
@@ -229,6 +233,7 @@ pub struct CrateInfo {
profiler_runtime
:
Option
<
CrateNum
>
,
sanitizer_runtime
:
Option
<
CrateNum
>
,
is_no_builtins
:
FxHashSet
<
CrateNum
>
,
native_libraries
:
FxHashMap
<
CrateNum
,
Rc
<
Vec
<
NativeLibrary
>>>
,
}
__
build_diagnostic_array!
{
librustc_trans
,
DIAGNOSTICS
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录