Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
95f06887
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
95f06887
编写于
9月 07, 2021
作者:
B
bjorn3
浏览文件
操作
浏览文件
下载
差异文件
Sync from rust
73641cd2
上级
ddaa7459
0167838a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
85 deletion
+40
-85
src/archive.rs
src/archive.rs
+20
-62
src/common.rs
src/common.rs
+15
-17
src/debuginfo/mod.rs
src/debuginfo/mod.rs
+1
-1
src/driver/aot.rs
src/driver/aot.rs
+1
-2
src/lib.rs
src/lib.rs
+3
-3
未找到文件。
src/archive.rs
浏览文件 @
95f06887
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
use
std
::
io
::{
self
,
Read
,
Seek
};
use
std
::
io
::{
self
,
Read
,
Seek
};
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
path
::{
Path
,
PathBuf
};
use
rustc_codegen_ssa
::
back
::
archive
::{
find_library
,
ArchiveBuilder
};
use
rustc_codegen_ssa
::
back
::
archive
::
ArchiveBuilder
;
use
rustc_codegen_ssa
::
METADATA_FILENAME
;
use
rustc_session
::
Session
;
use
rustc_session
::
Session
;
use
object
::
read
::
archive
::
ArchiveFile
;
use
object
::
read
::
archive
::
ArchiveFile
;
...
@@ -22,7 +21,6 @@ enum ArchiveEntry {
...
@@ -22,7 +21,6 @@ enum ArchiveEntry {
pub
(
crate
)
struct
ArArchiveBuilder
<
'a
>
{
pub
(
crate
)
struct
ArArchiveBuilder
<
'a
>
{
sess
:
&
'a
Session
,
sess
:
&
'a
Session
,
dst
:
PathBuf
,
dst
:
PathBuf
,
lib_search_paths
:
Vec
<
PathBuf
>
,
use_gnu_style_archive
:
bool
,
use_gnu_style_archive
:
bool
,
no_builtin_ranlib
:
bool
,
no_builtin_ranlib
:
bool
,
...
@@ -34,8 +32,6 @@ pub(crate) struct ArArchiveBuilder<'a> {
...
@@ -34,8 +32,6 @@ pub(crate) struct ArArchiveBuilder<'a> {
impl
<
'a
>
ArchiveBuilder
<
'a
>
for
ArArchiveBuilder
<
'a
>
{
impl
<
'a
>
ArchiveBuilder
<
'a
>
for
ArArchiveBuilder
<
'a
>
{
fn
new
(
sess
:
&
'a
Session
,
output
:
&
Path
,
input
:
Option
<&
Path
>
)
->
Self
{
fn
new
(
sess
:
&
'a
Session
,
output
:
&
Path
,
input
:
Option
<&
Path
>
)
->
Self
{
use
rustc_codegen_ssa
::
back
::
link
::
archive_search_paths
;
let
(
src_archives
,
entries
)
=
if
let
Some
(
input
)
=
input
{
let
(
src_archives
,
entries
)
=
if
let
Some
(
input
)
=
input
{
let
read_cache
=
ReadCache
::
new
(
File
::
open
(
input
)
.unwrap
());
let
read_cache
=
ReadCache
::
new
(
File
::
open
(
input
)
.unwrap
());
let
archive
=
ArchiveFile
::
parse
(
&
read_cache
)
.unwrap
();
let
archive
=
ArchiveFile
::
parse
(
&
read_cache
)
.unwrap
();
...
@@ -57,7 +53,6 @@ fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self {
...
@@ -57,7 +53,6 @@ fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self {
ArArchiveBuilder
{
ArArchiveBuilder
{
sess
,
sess
,
dst
:
output
.to_path_buf
(),
dst
:
output
.to_path_buf
(),
lib_search_paths
:
archive_search_paths
(
sess
),
use_gnu_style_archive
:
sess
.target.archive_format
==
"gnu"
,
use_gnu_style_archive
:
sess
.target.archive_format
==
"gnu"
,
// FIXME fix builtin ranlib on macOS
// FIXME fix builtin ranlib on macOS
no_builtin_ranlib
:
sess
.target.is_like_osx
,
no_builtin_ranlib
:
sess
.target.is_like_osx
,
...
@@ -87,40 +82,29 @@ fn add_file(&mut self, file: &Path) {
...
@@ -87,40 +82,29 @@ fn add_file(&mut self, file: &Path) {
));
));
}
}
fn
add_native_library
(
&
mut
self
,
name
:
rustc_span
::
symbol
::
Symbol
,
verbatim
:
bool
)
{
fn
add_archive
<
F
>
(
&
mut
self
,
archive_path
:
&
Path
,
mut
skip
:
F
)
->
std
::
io
::
Result
<
()
>
let
location
=
find_library
(
name
,
verbatim
,
&
self
.lib_search_paths
,
self
.sess
);
where
self
.add_archive
(
location
.clone
(),
|
_
|
false
)
.unwrap_or_else
(|
e
|
{
F
:
FnMut
(
&
str
)
->
bool
+
'static
,
panic!
(
"failed to add native library {}: {}"
,
location
.to_string_lossy
(),
e
);
{
});
let
read_cache
=
ReadCache
::
new
(
std
::
fs
::
File
::
open
(
&
archive_path
)
?
);
}
let
archive
=
ArchiveFile
::
parse
(
&
read_cache
)
.unwrap
();
let
archive_index
=
self
.src_archives
.len
();
fn
add_rlib
(
&
mut
self
,
rlib
:
&
Path
,
name
:
&
str
,
lto
:
bool
,
skip_objects
:
bool
,
)
->
io
::
Result
<
()
>
{
self
.add_archive
(
rlib
.to_owned
(),
move
|
fname
:
&
str
|
{
// Ignore metadata files, no matter the name.
if
fname
==
METADATA_FILENAME
{
return
true
;
}
// Don't include Rust objects if LTO is enabled
for
entry
in
archive
.members
()
{
if
lto
&&
fname
.starts_with
(
name
)
&&
fname
.ends_with
(
".o"
)
{
let
entry
=
entry
.map_err
(|
err
|
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
err
))
?
;
return
true
;
let
file_name
=
String
::
from_utf8
(
entry
.name
()
.to_vec
())
.map_err
(|
err
|
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
err
))
?
;
if
!
skip
(
&
file_name
)
{
self
.entries
.push
((
file_name
.into_bytes
(),
ArchiveEntry
::
FromArchive
{
archive_index
,
file_range
:
entry
.file_range
()
},
));
}
}
}
// Otherwise if this is *not* a rust object and we're skipping
self
.src_archives
.push
(
read_cache
.into_inner
());
// objects then skip this file
Ok
(())
if
skip_objects
&&
(
!
fname
.starts_with
(
name
)
||
!
fname
.ends_with
(
".o"
))
{
return
true
;
}
// ok, don't skip this
false
})
}
}
fn
update_symbols
(
&
mut
self
)
{}
fn
update_symbols
(
&
mut
self
)
{}
...
@@ -265,29 +249,3 @@ fn inject_dll_import_lib(
...
@@ -265,29 +249,3 @@ fn inject_dll_import_lib(
bug!
(
"injecting dll imports is not supported"
);
bug!
(
"injecting dll imports is not supported"
);
}
}
}
}
impl
<
'a
>
ArArchiveBuilder
<
'a
>
{
fn
add_archive
<
F
>
(
&
mut
self
,
archive_path
:
PathBuf
,
mut
skip
:
F
)
->
io
::
Result
<
()
>
where
F
:
FnMut
(
&
str
)
->
bool
,
{
let
read_cache
=
ReadCache
::
new
(
std
::
fs
::
File
::
open
(
&
archive_path
)
?
);
let
archive
=
ArchiveFile
::
parse
(
&
read_cache
)
.unwrap
();
let
archive_index
=
self
.src_archives
.len
();
for
entry
in
archive
.members
()
{
let
entry
=
entry
.map_err
(|
err
|
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
err
))
?
;
let
file_name
=
String
::
from_utf8
(
entry
.name
()
.to_vec
())
.map_err
(|
err
|
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidData
,
err
))
?
;
if
!
skip
(
&
file_name
)
{
self
.entries
.push
((
file_name
.into_bytes
(),
ArchiveEntry
::
FromArchive
{
archive_index
,
file_range
:
entry
.file_range
()
},
));
}
}
self
.src_archives
.push
(
read_cache
.into_inner
());
Ok
(())
}
}
src/common.rs
浏览文件 @
95f06887
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_middle
::
ty
::
layout
::{
LayoutError
,
LayoutOfHelpers
};
use
rustc_middle
::
ty
::
SymbolName
;
use
rustc_middle
::
ty
::
SymbolName
;
use
rustc_target
::
abi
::
call
::
FnAbi
;
use
rustc_target
::
abi
::
call
::
FnAbi
;
use
rustc_target
::
abi
::{
Integer
,
Primitive
};
use
rustc_target
::
abi
::{
Integer
,
Primitive
};
...
@@ -256,12 +257,12 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
...
@@ -256,12 +257,12 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
pub
(
crate
)
inline_asm_index
:
u32
,
pub
(
crate
)
inline_asm_index
:
u32
,
}
}
impl
<
'tcx
>
LayoutOf
<
'tcx
>
for
FunctionCx
<
'_
,
'_
,
'tcx
>
{
impl
<
'tcx
>
LayoutOfHelpers
<
'tcx
>
for
FunctionCx
<
'_
,
'_
,
'tcx
>
{
type
Ty
=
Ty
<
'tcx
>
;
type
LayoutOfResult
=
TyAndLayout
<
'tcx
>
;
type
TyAndLayout
=
TyAndLayout
<
'tcx
>
;
fn
layout_of
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
TyAndLayout
<
'tcx
>
{
#[inline]
RevealAllLayoutCx
(
self
.tcx
)
.layout_of
(
ty
)
fn
handle_layout_err
(
&
self
,
err
:
LayoutError
<
'tcx
>
,
span
:
Span
,
ty
:
Ty
<
'tcx
>
)
->
!
{
RevealAllLayoutCx
(
self
.tcx
)
.handle_layout_err
(
err
,
span
,
ty
)
}
}
}
}
...
@@ -364,19 +365,16 @@ pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
...
@@ -364,19 +365,16 @@ pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
pub
(
crate
)
struct
RevealAllLayoutCx
<
'tcx
>
(
pub
(
crate
)
TyCtxt
<
'tcx
>
);
pub
(
crate
)
struct
RevealAllLayoutCx
<
'tcx
>
(
pub
(
crate
)
TyCtxt
<
'tcx
>
);
impl
<
'tcx
>
LayoutOf
<
'tcx
>
for
RevealAllLayoutCx
<
'tcx
>
{
impl
<
'tcx
>
LayoutOfHelpers
<
'tcx
>
for
RevealAllLayoutCx
<
'tcx
>
{
type
Ty
=
Ty
<
'tcx
>
;
type
LayoutOfResult
=
TyAndLayout
<
'tcx
>
;
type
TyAndLayout
=
TyAndLayout
<
'tcx
>
;
fn
layout_of
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
TyAndLayout
<
'tcx
>
{
#[inline]
assert
!
(
!
ty
.still_further_specializable
());
fn
handle_layout_err
(
&
self
,
err
:
LayoutError
<
'tcx
>
,
span
:
Span
,
ty
:
Ty
<
'tcx
>
)
->
!
{
self
.0
.layout_of
(
ParamEnv
::
reveal_all
()
.and
(
&
ty
))
.unwrap_or_else
(|
e
|
{
if
let
layout
::
LayoutError
::
SizeOverflow
(
_
)
=
err
{
if
let
layout
::
LayoutError
::
SizeOverflow
(
_
)
=
e
{
self
.0
.sess
.span_fatal
(
span
,
&
err
.to_string
())
self
.0
.sess
.fatal
(
&
e
.to_string
())
}
else
{
}
else
{
span_bug!
(
span
,
"failed to get layout for `{}`: {}"
,
ty
,
err
)
bug!
(
"failed to get layout for `{}`: {}"
,
ty
,
e
)
}
}
})
}
}
}
}
...
...
src/debuginfo/mod.rs
浏览文件 @
95f06887
...
@@ -67,7 +67,7 @@ pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self {
...
@@ -67,7 +67,7 @@ pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self {
rustc_interface
::
util
::
version_str
()
.unwrap_or
(
"unknown version"
),
rustc_interface
::
util
::
version_str
()
.unwrap_or
(
"unknown version"
),
cranelift_codegen
::
VERSION
,
cranelift_codegen
::
VERSION
,
);
);
let
comp_dir
=
tcx
.sess.opts.working_dir
.to_string_lossy
(
false
)
.into_owned
();
let
comp_dir
=
tcx
.sess.opts.working_dir
.to_string_lossy
(
FileNameDisplayPreference
::
Remapped
)
.into_owned
();
let
(
name
,
file_info
)
=
match
tcx
.sess.local_crate_source_file
.clone
()
{
let
(
name
,
file_info
)
=
match
tcx
.sess.local_crate_source_file
.clone
()
{
Some
(
path
)
=>
{
Some
(
path
)
=>
{
let
name
=
path
.to_string_lossy
()
.into_owned
();
let
name
=
path
.to_string_lossy
()
.into_owned
();
...
...
src/driver/aot.rs
浏览文件 @
95f06887
...
@@ -80,14 +80,13 @@ fn reuse_workproduct_for_cgu(
...
@@ -80,14 +80,13 @@ fn reuse_workproduct_for_cgu(
cgu
:
&
CodegenUnit
<
'_
>
,
cgu
:
&
CodegenUnit
<
'_
>
,
work_products
:
&
mut
FxHashMap
<
WorkProductId
,
WorkProduct
>
,
work_products
:
&
mut
FxHashMap
<
WorkProductId
,
WorkProduct
>
,
)
->
CompiledModule
{
)
->
CompiledModule
{
let
incr_comp_session_dir
=
tcx
.sess
.incr_comp_session_dir
();
let
mut
object
=
None
;
let
mut
object
=
None
;
let
work_product
=
cgu
.work_product
(
tcx
);
let
work_product
=
cgu
.work_product
(
tcx
);
if
let
Some
(
saved_file
)
=
&
work_product
.saved_file
{
if
let
Some
(
saved_file
)
=
&
work_product
.saved_file
{
let
obj_out
=
let
obj_out
=
tcx
.output_filenames
(())
.temp_path
(
OutputType
::
Object
,
Some
(
&
cgu
.name
()
.as_str
()));
tcx
.output_filenames
(())
.temp_path
(
OutputType
::
Object
,
Some
(
&
cgu
.name
()
.as_str
()));
object
=
Some
(
obj_out
.clone
());
object
=
Some
(
obj_out
.clone
());
let
source_file
=
rustc_incremental
::
in_incr_comp_dir
(
&
incr_comp_session_dir
,
&
saved_file
);
let
source_file
=
rustc_incremental
::
in_incr_comp_dir
_sess
(
&
tcx
.sess
,
&
saved_file
);
if
let
Err
(
err
)
=
rustc_fs_util
::
link_or_copy
(
&
source_file
,
&
obj_out
)
{
if
let
Err
(
err
)
=
rustc_fs_util
::
link_or_copy
(
&
source_file
,
&
obj_out
)
{
tcx
.sess
.err
(
&
format!
(
tcx
.sess
.err
(
&
format!
(
"unable to copy {} to {}: {}"
,
"unable to copy {} to {}: {}"
,
...
...
src/lib.rs
浏览文件 @
95f06887
...
@@ -74,17 +74,17 @@
...
@@ -74,17 +74,17 @@
mod
prelude
{
mod
prelude
{
pub
(
crate
)
use
std
::
convert
::{
TryFrom
,
TryInto
};
pub
(
crate
)
use
std
::
convert
::{
TryFrom
,
TryInto
};
pub
(
crate
)
use
rustc_span
::
Span
;
pub
(
crate
)
use
rustc_span
::
{
Span
,
FileNameDisplayPreference
}
;
pub
(
crate
)
use
rustc_hir
::
def_id
::{
DefId
,
LOCAL_CRATE
};
pub
(
crate
)
use
rustc_hir
::
def_id
::{
DefId
,
LOCAL_CRATE
};
pub
(
crate
)
use
rustc_middle
::
bug
;
pub
(
crate
)
use
rustc_middle
::
bug
;
pub
(
crate
)
use
rustc_middle
::
mir
::{
self
,
*
};
pub
(
crate
)
use
rustc_middle
::
mir
::{
self
,
*
};
pub
(
crate
)
use
rustc_middle
::
ty
::
layout
::{
self
,
TyAndLayout
};
pub
(
crate
)
use
rustc_middle
::
ty
::
layout
::{
self
,
LayoutOf
,
TyAndLayout
};
pub
(
crate
)
use
rustc_middle
::
ty
::{
pub
(
crate
)
use
rustc_middle
::
ty
::{
self
,
FloatTy
,
Instance
,
InstanceDef
,
IntTy
,
ParamEnv
,
Ty
,
TyCtxt
,
TypeAndMut
,
self
,
FloatTy
,
Instance
,
InstanceDef
,
IntTy
,
ParamEnv
,
Ty
,
TyCtxt
,
TypeAndMut
,
TypeFoldable
,
UintTy
,
TypeFoldable
,
UintTy
,
};
};
pub
(
crate
)
use
rustc_target
::
abi
::{
Abi
,
LayoutOf
,
Scalar
,
Size
,
VariantIdx
};
pub
(
crate
)
use
rustc_target
::
abi
::{
Abi
,
Scalar
,
Size
,
VariantIdx
};
pub
(
crate
)
use
rustc_data_structures
::
fx
::
FxHashMap
;
pub
(
crate
)
use
rustc_data_structures
::
fx
::
FxHashMap
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录