Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7720cf02
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,发现更多精彩内容 >>
提交
7720cf02
编写于
12月 23, 2016
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change --crate-type metadata to --emit=metadata
上级
4ecc85be
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
61 addition
and
56 deletion
+61
-56
src/librustc/middle/dependency_format.rs
src/librustc/middle/dependency_format.rs
+5
-1
src/librustc/middle/reachable.rs
src/librustc/middle/reachable.rs
+1
-1
src/librustc/middle/weak_lang_items.rs
src/librustc/middle/weak_lang_items.rs
+1
-2
src/librustc/session/config.rs
src/librustc/session/config.rs
+8
-6
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+0
-3
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+2
-1
src/librustc_metadata/creader.rs
src/librustc_metadata/creader.rs
+1
-2
src/librustc_trans/back/link.rs
src/librustc_trans/back/link.rs
+27
-22
src/librustc_trans/back/lto.rs
src/librustc_trans/back/lto.rs
+0
-1
src/librustc_trans/back/symbol_export.rs
src/librustc_trans/back/symbol_export.rs
+0
-1
src/librustc_trans/back/write.rs
src/librustc_trans/back/write.rs
+6
-4
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+2
-3
src/test/compile-fail/auxiliary/rmeta_meta.rs
src/test/compile-fail/auxiliary/rmeta_meta.rs
+2
-1
src/test/compile-fail/rmeta-lib-pass.rs
src/test/compile-fail/rmeta-lib-pass.rs
+1
-2
src/test/compile-fail/rmeta-pass.rs
src/test/compile-fail/rmeta-pass.rs
+1
-2
src/test/compile-fail/rmeta.rs
src/test/compile-fail/rmeta.rs
+1
-2
src/test/compile-fail/rmeta_meta_main.rs
src/test/compile-fail/rmeta_meta_main.rs
+1
-1
src/test/run-pass/auxiliary/rmeta_rmeta.rs
src/test/run-pass/auxiliary/rmeta_rmeta.rs
+2
-1
未找到文件。
src/librustc/middle/dependency_format.rs
浏览文件 @
7720cf02
...
...
@@ -103,6 +103,10 @@ pub fn calculate(sess: &session::Session) {
fn
calculate_type
(
sess
:
&
session
::
Session
,
ty
:
config
::
CrateType
)
->
DependencyList
{
if
sess
.opts.output_types
.contains_key
(
&
config
::
OutputType
::
Metadata
)
{
return
Vec
::
new
();
}
match
ty
{
// If the global prefer_dynamic switch is turned off, first attempt
// static linkage (this can fail).
...
...
@@ -114,7 +118,7 @@ fn calculate_type(sess: &session::Session,
// No linkage happens with rlibs, we just needed the metadata (which we
// got long ago), so don't bother with anything.
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
=>
return
Vec
::
new
(),
config
::
CrateTypeRlib
=>
return
Vec
::
new
(),
// Staticlibs and cdylibs must have all static dependencies. If any fail
// to be found, we generate some nice pretty errors.
...
...
src/librustc/middle/reachable.rs
浏览文件 @
7720cf02
...
...
@@ -139,7 +139,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
fn
new
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
ReachableContext
<
'a
,
'tcx
>
{
let
any_library
=
tcx
.sess.crate_types
.borrow
()
.iter
()
.any
(|
ty
|
{
*
ty
==
config
::
CrateTypeRlib
||
*
ty
==
config
::
CrateTypeDylib
||
*
ty
==
config
::
CrateTypeProcMacro
||
*
ty
==
config
::
CrateTypeMetadata
*
ty
==
config
::
CrateTypeProcMacro
});
ReachableContext
{
tcx
:
tcx
,
...
...
src/librustc/middle/weak_lang_items.rs
浏览文件 @
7720cf02
...
...
@@ -75,8 +75,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
config
::
CrateTypeCdylib
|
config
::
CrateTypeExecutable
|
config
::
CrateTypeStaticlib
=>
true
,
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
=>
false
,
config
::
CrateTypeRlib
=>
false
,
}
});
if
!
needs_check
{
...
...
src/librustc/session/config.rs
浏览文件 @
7720cf02
...
...
@@ -73,6 +73,7 @@ pub enum OutputType {
Bitcode
,
Assembly
,
LlvmAssembly
,
Metadata
,
Object
,
Exe
,
DepInfo
,
...
...
@@ -86,7 +87,8 @@ fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
OutputType
::
Bitcode
|
OutputType
::
Assembly
|
OutputType
::
LlvmAssembly
|
OutputType
::
Object
=>
false
,
OutputType
::
Object
|
OutputType
::
Metadata
=>
false
,
}
}
...
...
@@ -96,6 +98,7 @@ fn shorthand(&self) -> &'static str {
OutputType
::
Assembly
=>
"asm"
,
OutputType
::
LlvmAssembly
=>
"llvm-ir"
,
OutputType
::
Object
=>
"obj"
,
OutputType
::
Metadata
=>
"metadata"
,
OutputType
::
Exe
=>
"link"
,
OutputType
::
DepInfo
=>
"dep-info"
,
}
...
...
@@ -107,6 +110,7 @@ pub fn extension(&self) -> &'static str {
OutputType
::
Assembly
=>
"s"
,
OutputType
::
LlvmAssembly
=>
"ll"
,
OutputType
::
Object
=>
"o"
,
OutputType
::
Metadata
=>
"rmeta"
,
OutputType
::
DepInfo
=>
"d"
,
OutputType
::
Exe
=>
""
,
}
...
...
@@ -482,7 +486,6 @@ pub enum CrateType {
CrateTypeStaticlib
,
CrateTypeCdylib
,
CrateTypeProcMacro
,
CrateTypeMetadata
,
}
#[derive(Clone,
Hash)]
...
...
@@ -1159,12 +1162,12 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
assumed."
,
"[KIND=]NAME"
),
opt
::
multi_s
(
""
,
"crate-type"
,
"Comma separated list of types of crates
for the compiler to emit"
,
"[bin|lib|rlib|dylib|cdylib|staticlib
|metadata
]"
),
"[bin|lib|rlib|dylib|cdylib|staticlib]"
),
opt
::
opt_s
(
""
,
"crate-name"
,
"Specify the name of the crate being built"
,
"NAME"
),
opt
::
multi_s
(
""
,
"emit"
,
"Comma separated list of types of output for
\
the compiler to emit"
,
"[asm|llvm-bc|llvm-ir|obj|link|dep-info]"
),
"[asm|llvm-bc|llvm-ir|obj|
metadata|
link|dep-info]"
),
opt
::
multi_s
(
""
,
"print"
,
"Comma separated list of compiler information to
\
print on stdout"
,
&
print_opts
.join
(
"|"
)),
opt
::
flagmulti_s
(
"g"
,
""
,
"Equivalent to -C debuginfo=2"
),
...
...
@@ -1327,6 +1330,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
"llvm-ir"
=>
OutputType
::
LlvmAssembly
,
"llvm-bc"
=>
OutputType
::
Bitcode
,
"obj"
=>
OutputType
::
Object
,
"metadata"
=>
OutputType
::
Metadata
,
"link"
=>
OutputType
::
Exe
,
"dep-info"
=>
OutputType
::
DepInfo
,
part
=>
{
...
...
@@ -1553,7 +1557,6 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
"cdylib"
=>
CrateTypeCdylib
,
"bin"
=>
CrateTypeExecutable
,
"proc-macro"
=>
CrateTypeProcMacro
,
"metadata"
=>
CrateTypeMetadata
,
_
=>
{
return
Err
(
format!
(
"unknown crate type: `{}`"
,
part
));
...
...
@@ -1638,7 +1641,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
CrateTypeStaticlib
=>
"staticlib"
.fmt
(
f
),
CrateTypeCdylib
=>
"cdylib"
.fmt
(
f
),
CrateTypeProcMacro
=>
"proc-macro"
.fmt
(
f
),
CrateTypeMetadata
=>
"metadata"
.fmt
(
f
),
}
}
}
...
...
src/librustc_driver/driver.rs
浏览文件 @
7720cf02
...
...
@@ -1182,9 +1182,6 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
Some
(
ref
n
)
if
*
n
==
"rlib"
=>
{
Some
(
config
::
CrateTypeRlib
)
}
Some
(
ref
n
)
if
*
n
==
"metadata"
=>
{
Some
(
config
::
CrateTypeMetadata
)
}
Some
(
ref
n
)
if
*
n
==
"dylib"
=>
{
Some
(
config
::
CrateTypeDylib
)
}
...
...
src/librustc_driver/lib.rs
浏览文件 @
7720cf02
...
...
@@ -493,7 +493,8 @@ fn build_controller(&mut self,
control
.after_hir_lowering.stop
=
Compilation
::
Stop
;
}
if
!
sess
.opts.output_types
.keys
()
.any
(|
&
i
|
i
==
OutputType
::
Exe
)
{
if
!
sess
.opts.output_types
.keys
()
.any
(|
&
i
|
i
==
OutputType
::
Exe
||
i
==
OutputType
::
Metadata
)
{
control
.after_llvm.stop
=
Compilation
::
Stop
;
}
...
...
src/librustc_metadata/creader.rs
浏览文件 @
7720cf02
...
...
@@ -799,8 +799,7 @@ fn inject_allocator_crate(&mut self) {
config
::
CrateTypeProcMacro
|
config
::
CrateTypeCdylib
|
config
::
CrateTypeStaticlib
=>
need_lib_alloc
=
true
,
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
=>
{}
config
::
CrateTypeRlib
=>
{}
}
}
if
!
need_lib_alloc
&&
!
need_exe_alloc
{
return
}
...
...
src/librustc_trans/back/link.rs
浏览文件 @
7720cf02
...
...
@@ -191,7 +191,8 @@ 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.debugging_opts.no_trans
&&
if
(
sess
.opts.debugging_opts.no_trans
||
sess
.opts.output_types
.contains_key
(
&
OutputType
::
Metadata
))
&&
crate_type
==
config
::
CrateTypeExecutable
{
continue
;
}
...
...
@@ -200,15 +201,16 @@ pub fn link_binary(sess: &Session,
bug!
(
"invalid output type `{:?}` for target os `{}`"
,
crate_type
,
sess
.opts.target_triple
);
}
let
out_file
=
link_binary_output
(
sess
,
trans
,
crate_type
,
outputs
,
crate_name
);
let
out_file
=
link_binary_output
(
sess
,
trans
,
crate_type
,
outputs
,
crate_name
);
out_filenames
.push
(
out_file
);
}
// Remove the temporary object file and metadata if we aren't saving temps
if
!
sess
.opts.cg.save_temps
{
for
obj
in
object_filenames
(
trans
,
outputs
)
{
remove
(
sess
,
&
obj
);
if
!
sess
.opts.output_types
.contains_key
(
&
OutputType
::
Metadata
)
{
for
obj
in
object_filenames
(
trans
,
outputs
)
{
remove
(
sess
,
&
obj
);
}
}
remove
(
sess
,
&
outputs
.with_extension
(
"metadata.o"
));
}
...
...
@@ -259,13 +261,15 @@ pub fn filename_for_input(sess: &Session,
crate_name
:
&
str
,
outputs
:
&
OutputFilenames
)
->
PathBuf
{
let
libname
=
format!
(
"{}{}"
,
crate_name
,
sess
.opts.cg.extra_filename
);
if
outputs
.outputs
.contains_key
(
&
OutputType
::
Metadata
)
{
return
outputs
.out_directory
.join
(
&
format!
(
"lib{}.rmeta"
,
libname
));
}
match
crate_type
{
config
::
CrateTypeRlib
=>
{
outputs
.out_directory
.join
(
&
format!
(
"lib{}.rlib"
,
libname
))
}
config
::
CrateTypeMetadata
=>
{
outputs
.out_directory
.join
(
&
format!
(
"lib{}.rmeta"
,
libname
))
}
config
::
CrateTypeCdylib
|
config
::
CrateTypeProcMacro
|
config
::
CrateTypeDylib
=>
{
...
...
@@ -351,20 +355,21 @@ fn link_binary_output(sess: &Session,
Err
(
err
)
=>
sess
.fatal
(
&
format!
(
"couldn't create a temp dir: {}"
,
err
)),
};
match
crate_type
{
config
::
CrateTypeRlib
=>
{
link_rlib
(
sess
,
Some
(
trans
),
&
objects
,
&
out_filename
,
tmpdir
.path
())
.build
();
}
config
::
CrateTypeStaticlib
=>
{
link_staticlib
(
sess
,
&
objects
,
&
out_filename
,
tmpdir
.path
());
}
config
::
CrateTypeMetadata
=>
{
emit_metadata
(
sess
,
trans
,
&
out_filename
);
}
_
=>
{
link_natively
(
sess
,
crate_type
,
&
objects
,
&
out_filename
,
trans
,
outputs
,
tmpdir
.path
());
if
outputs
.outputs
.contains_key
(
&
OutputType
::
Metadata
)
{
emit_metadata
(
sess
,
trans
,
&
out_filename
);
}
else
{
match
crate_type
{
config
::
CrateTypeRlib
=>
{
link_rlib
(
sess
,
Some
(
trans
),
&
objects
,
&
out_filename
,
tmpdir
.path
())
.build
();
}
config
::
CrateTypeStaticlib
=>
{
link_staticlib
(
sess
,
&
objects
,
&
out_filename
,
tmpdir
.path
());
}
_
=>
{
link_natively
(
sess
,
crate_type
,
&
objects
,
&
out_filename
,
trans
,
outputs
,
tmpdir
.path
());
}
}
}
...
...
src/librustc_trans/back/lto.rs
浏览文件 @
7720cf02
...
...
@@ -34,7 +34,6 @@ pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
config
::
CrateTypeDylib
|
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
|
config
::
CrateTypeProcMacro
=>
false
,
}
}
...
...
src/librustc_trans/back/symbol_export.rs
浏览文件 @
7720cf02
...
...
@@ -149,7 +149,6 @@ pub fn crate_export_threshold(crate_type: config::CrateType)
config
::
CrateTypeProcMacro
|
config
::
CrateTypeCdylib
=>
SymbolExportLevel
::
C
,
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
|
config
::
CrateTypeDylib
=>
SymbolExportLevel
::
Rust
,
}
}
...
...
src/librustc_trans/back/write.rs
浏览文件 @
7720cf02
...
...
@@ -701,8 +701,8 @@ pub fn run_passes(sess: &Session,
for
output_type
in
output_types
.keys
()
{
match
*
output_type
{
OutputType
::
Bitcode
=>
{
modules_config
.emit_bc
=
true
;
}
,
OutputType
::
LlvmAssembly
=>
{
modules_config
.emit_ir
=
true
;
}
,
OutputType
::
Bitcode
=>
{
modules_config
.emit_bc
=
true
;
}
OutputType
::
LlvmAssembly
=>
{
modules_config
.emit_ir
=
true
;
}
OutputType
::
Assembly
=>
{
modules_config
.emit_asm
=
true
;
// If we're not using the LLVM assembler, this function
...
...
@@ -711,8 +711,9 @@ pub fn run_passes(sess: &Session,
if
!
sess
.opts.output_types
.contains_key
(
&
OutputType
::
Assembly
)
{
metadata_config
.emit_obj
=
true
;
}
},
OutputType
::
Object
=>
{
modules_config
.emit_obj
=
true
;
},
}
OutputType
::
Object
=>
{
modules_config
.emit_obj
=
true
;
}
OutputType
::
Metadata
=>
{
metadata_config
.emit_obj
=
true
;
}
OutputType
::
Exe
=>
{
modules_config
.emit_obj
=
true
;
metadata_config
.emit_obj
=
true
;
...
...
@@ -853,6 +854,7 @@ pub fn run_passes(sess: &Session,
user_wants_objects
=
true
;
copy_if_one_unit
(
OutputType
::
Object
,
true
);
}
OutputType
::
Metadata
|
OutputType
::
Exe
|
OutputType
::
DepInfo
=>
{}
}
...
...
src/librustc_trans/base.rs
浏览文件 @
7720cf02
...
...
@@ -807,8 +807,7 @@ enum MetadataKind {
config
::
CrateTypeStaticlib
|
config
::
CrateTypeCdylib
=>
MetadataKind
::
None
,
config
::
CrateTypeRlib
|
config
::
CrateTypeMetadata
=>
MetadataKind
::
Uncompressed
,
config
::
CrateTypeRlib
=>
MetadataKind
::
Uncompressed
,
config
::
CrateTypeDylib
|
config
::
CrateTypeProcMacro
=>
MetadataKind
::
Compressed
,
...
...
@@ -1191,7 +1190,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Skip crate items and just output metadata in -Z no-trans mode.
if
tcx
.sess.opts.debugging_opts.no_trans
||
tcx
.sess.
crate_types
.borrow
()
.iter
()
.all
(|
ct
|
ct
==
&
config
::
CrateType
Metadata
)
{
tcx
.sess.
opts.output_types
.contains_key
(
&
config
::
OutputType
::
Metadata
)
{
let
linker_info
=
LinkerInfo
::
new
(
&
shared_ccx
,
&
ExportedSymbols
::
empty
());
return
CrateTranslation
{
modules
:
modules
,
...
...
src/test/compile-fail/auxiliary/rmeta_meta.rs
浏览文件 @
7720cf02
...
...
@@ -9,8 +9,9 @@
// except according to those terms.
// no-prefer-dynamic
// compile-flags: --emit=metadata
#![crate_type=
"
metadata
"
]
#![crate_type=
"
rlib
"
]
pub
struct
Foo
{
pub
field
:
i32
,
...
...
src/test/compile-fail/rmeta-lib-pass.rs
浏览文件 @
7720cf02
...
...
@@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: --emit=metadata
// aux-build:rmeta_rlib.rs
// no-prefer-dynamic
// must-compile-successfully
...
...
@@ -15,8 +16,6 @@
// Check that building a metadata crate works with a dependent, rlib crate.
// This is a cfail test since there is no executable to run.
#![crate_type=
"metadata"
]
extern
crate
rmeta_rlib
;
use
rmeta_rlib
::
Foo
;
...
...
src/test/compile-fail/rmeta-pass.rs
浏览文件 @
7720cf02
...
...
@@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: --emit=metadata
// aux-build:rmeta_meta.rs
// no-prefer-dynamic
// must-compile-successfully
...
...
@@ -16,8 +17,6 @@
// crate.
// This is a cfail test since there is no executable to run.
#![crate_type=
"metadata"
]
extern
crate
rmeta_meta
;
use
rmeta_meta
::
Foo
;
...
...
src/test/compile-fail/rmeta.rs
浏览文件 @
7720cf02
...
...
@@ -9,11 +9,10 @@
// except according to those terms.
// no-prefer-dynamic
// compile-flags: --emit=metadata
// Check that building a metadata crate finds an error.
#![crate_type=
"metadata"
]
fn
main
()
{
let
_
=
Foo
;
//~ ERROR unresolved value `Foo`
}
src/test/compile-fail/rmeta_meta_main.rs
浏览文件 @
7720cf02
...
...
@@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: --emit=metadata
// aux-build:rmeta_meta.rs
// no-prefer-dynamic
// Check that building a metadata crate finds an error with a dependent,
// metadata-only crate.
#![crate_type=
"metadata"
]
extern
crate
rmeta_meta
;
use
rmeta_meta
::
Foo
;
...
...
src/test/run-pass/auxiliary/rmeta_rmeta.rs
浏览文件 @
7720cf02
...
...
@@ -9,8 +9,9 @@
// except according to those terms.
// no-prefer-dynamic
// compile-flags: --emit=metadata
#![crate_type=
"
metadata
"
]
#![crate_type=
"
rlib
"
]
#![crate_name=
"rmeta_aux"
]
pub
struct
Foo
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录