Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a26f0035
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,发现更多精彩内容 >>
提交
a26f0035
编写于
6月 04, 2021
作者:
L
Luqman Aden
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}.
上级
f434217a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
3 addition
and
90 deletion
+3
-90
compiler/rustc_codegen_cranelift/src/toolchain.rs
compiler/rustc_codegen_cranelift/src/toolchain.rs
+1
-89
compiler/rustc_codegen_ssa/src/back/link.rs
compiler/rustc_codegen_ssa/src/back/link.rs
+2
-1
未找到文件。
compiler/rustc_codegen_cranelift/src/toolchain.rs
浏览文件 @
a26f0035
...
...
@@ -2,9 +2,8 @@
use
std
::
path
::
PathBuf
;
use
rustc_
middle
::
bug
;
use
rustc_
codegen_ssa
::
back
::
link
::
linker_and_flavor
;
use
rustc_session
::
Session
;
use
rustc_target
::
spec
::
LinkerFlavor
;
/// Tries to infer the path of a binary for the target toolchain from the linker name.
pub
(
crate
)
fn
get_toolchain_binary
(
sess
:
&
Session
,
tool
:
&
str
)
->
PathBuf
{
...
...
@@ -30,90 +29,3 @@ pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str) -> PathBuf {
linker
}
// Adapted from https://github.com/rust-lang/rust/blob/5db778affee7c6600c8e7a177c48282dab3f6292/src/librustc_codegen_ssa/back/link.rs#L848-L931
fn
linker_and_flavor
(
sess
:
&
Session
)
->
(
PathBuf
,
LinkerFlavor
)
{
fn
infer_from
(
sess
:
&
Session
,
linker
:
Option
<
PathBuf
>
,
flavor
:
Option
<
LinkerFlavor
>
,
)
->
Option
<
(
PathBuf
,
LinkerFlavor
)
>
{
match
(
linker
,
flavor
)
{
(
Some
(
linker
),
Some
(
flavor
))
=>
Some
((
linker
,
flavor
)),
// only the linker flavor is known; use the default linker for the selected flavor
(
None
,
Some
(
flavor
))
=>
Some
((
PathBuf
::
from
(
match
flavor
{
LinkerFlavor
::
Em
=>
{
if
cfg!
(
windows
)
{
"emcc.bat"
}
else
{
"emcc"
}
}
LinkerFlavor
::
Gcc
=>
{
if
cfg!
(
any
(
target_os
=
"solaris"
,
target_os
=
"illumos"
))
{
// On historical Solaris systems, "cc" may have
// been Sun Studio, which is not flag-compatible
// with "gcc". This history casts a long shadow,
// and many modern illumos distributions today
// ship GCC as "gcc" without also making it
// available as "cc".
"gcc"
}
else
{
"cc"
}
}
LinkerFlavor
::
Ld
=>
"ld"
,
LinkerFlavor
::
Msvc
=>
"link.exe"
,
LinkerFlavor
::
Lld
(
_
)
=>
"lld"
,
LinkerFlavor
::
PtxLinker
=>
"rust-ptx-linker"
,
LinkerFlavor
::
BpfLinker
=>
"bpf-linker"
,
}),
flavor
,
)),
(
Some
(
linker
),
None
)
=>
{
let
stem
=
linker
.file_stem
()
.and_then
(|
stem
|
stem
.to_str
())
.unwrap_or_else
(||
{
sess
.fatal
(
"couldn't extract file stem from specified linker"
)
});
let
flavor
=
if
stem
==
"emcc"
{
LinkerFlavor
::
Em
}
else
if
stem
==
"gcc"
||
stem
.ends_with
(
"-gcc"
)
||
stem
==
"clang"
||
stem
.ends_with
(
"-clang"
)
{
LinkerFlavor
::
Gcc
}
else
if
stem
==
"ld"
||
stem
==
"ld.lld"
||
stem
.ends_with
(
"-ld"
)
{
LinkerFlavor
::
Ld
}
else
if
stem
==
"link"
||
stem
==
"lld-link"
{
LinkerFlavor
::
Msvc
}
else
if
stem
==
"lld"
||
stem
==
"rust-lld"
{
LinkerFlavor
::
Lld
(
sess
.target.lld_flavor
)
}
else
{
// fall back to the value in the target spec
sess
.target.linker_flavor
};
Some
((
linker
,
flavor
))
}
(
None
,
None
)
=>
None
,
}
}
// linker and linker flavor specified via command line have precedence over what the target
// specification specifies
if
let
Some
(
ret
)
=
infer_from
(
sess
,
sess
.opts.cg.linker
.clone
(),
sess
.opts.cg.linker_flavor
)
{
return
ret
;
}
if
let
Some
(
ret
)
=
infer_from
(
sess
,
sess
.target.linker
.clone
()
.map
(
PathBuf
::
from
),
Some
(
sess
.target.linker_flavor
),
)
{
return
ret
;
}
bug!
(
"Not enough information provided to determine how to invoke the linker"
);
}
compiler/rustc_codegen_ssa/src/back/link.rs
浏览文件 @
a26f0035
...
...
@@ -1089,7 +1089,8 @@ pub fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool
&&
(
info
.compiler_builtins
==
Some
(
cnum
)
||
info
.is_no_builtins
.contains
(
&
cnum
))
}
fn
linker_and_flavor
(
sess
:
&
Session
)
->
(
PathBuf
,
LinkerFlavor
)
{
// This functions tries to determine the appropriate linker (and corresponding LinkerFlavor) to use
pub
fn
linker_and_flavor
(
sess
:
&
Session
)
->
(
PathBuf
,
LinkerFlavor
)
{
fn
infer_from
(
sess
:
&
Session
,
linker
:
Option
<
PathBuf
>
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录