Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1bec962f
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,发现更多精彩内容 >>
提交
1bec962f
编写于
8月 15, 2019
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bootstrap: Remove need for `RUSTC_RPATH` variable
上级
b82d86ed
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
49 deletion
+48
-49
src/bootstrap/bin/rustc.rs
src/bootstrap/bin/rustc.rs
+0
-48
src/bootstrap/builder.rs
src/bootstrap/builder.rs
+48
-1
未找到文件。
src/bootstrap/bin/rustc.rs
浏览文件 @
1bec962f
...
...
@@ -184,54 +184,6 @@ fn main() {
cmd
.arg
(
"-C"
)
.arg
(
format!
(
"codegen-units={}"
,
s
));
}
// Dealing with rpath here is a little special, so let's go into some
// detail. First off, `-rpath` is a linker option on Unix platforms
// which adds to the runtime dynamic loader path when looking for
// dynamic libraries. We use this by default on Unix platforms to ensure
// that our nightlies behave the same on Windows, that is they work out
// of the box. This can be disabled, of course, but basically that's why
// we're gated on RUSTC_RPATH here.
//
// Ok, so the astute might be wondering "why isn't `-C rpath` used
// here?" and that is indeed a good question to task. This codegen
// option is the compiler's current interface to generating an rpath.
// Unfortunately it doesn't quite suffice for us. The flag currently
// takes no value as an argument, so the compiler calculates what it
// should pass to the linker as `-rpath`. This unfortunately is based on
// the **compile time** directory structure which when building with
// Cargo will be very different than the runtime directory structure.
//
// All that's a really long winded way of saying that if we use
// `-Crpath` then the executables generated have the wrong rpath of
// something like `$ORIGIN/deps` when in fact the way we distribute
// rustc requires the rpath to be `$ORIGIN/../lib`.
//
// So, all in all, to set up the correct rpath we pass the linker
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
// to change a flag in a binary?
if
env
::
var
(
"RUSTC_RPATH"
)
==
Ok
(
"true"
.to_string
())
{
let
rpath
=
if
target
.contains
(
"apple"
)
{
// Note that we need to take one extra step on macOS to also pass
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
// do that we pass a weird flag to the compiler to get it to do
// so. Note that this is definitely a hack, and we should likely
// flesh out rpath support more fully in the future.
cmd
.arg
(
"-Z"
)
.arg
(
"osx-rpath-install-name"
);
Some
(
"-Wl,-rpath,@loader_path/../lib"
)
}
else
if
!
target
.contains
(
"windows"
)
&&
!
target
.contains
(
"wasm32"
)
&&
!
target
.contains
(
"fuchsia"
)
{
Some
(
"-Wl,-rpath,$ORIGIN/../lib"
)
}
else
{
None
};
if
let
Some
(
rpath
)
=
rpath
{
cmd
.arg
(
"-C"
)
.arg
(
format!
(
"link-args={}"
,
rpath
));
}
}
if
let
Ok
(
map
)
=
env
::
var
(
"RUSTC_DEBUGINFO_MAP"
)
{
cmd
.arg
(
"--remap-path-prefix"
)
.arg
(
&
map
);
}
...
...
src/bootstrap/builder.rs
浏览文件 @
1bec962f
...
...
@@ -908,7 +908,6 @@ pub fn cargo(
)
.env
(
"RUSTC_SYSROOT"
,
&
sysroot
)
.env
(
"RUSTC_LIBDIR"
,
&
libdir
)
.env
(
"RUSTC_RPATH"
,
self
.config.rust_rpath
.to_string
())
.env
(
"RUSTDOC"
,
self
.out
.join
(
"bootstrap/debug/rustdoc"
))
.env
(
"RUSTDOC_REAL"
,
...
...
@@ -921,6 +920,54 @@ pub fn cargo(
.env
(
"RUSTC_ERROR_METADATA_DST"
,
self
.extended_error_dir
())
.env
(
"RUSTC_BREAK_ON_ICE"
,
"1"
);
// Dealing with rpath here is a little special, so let's go into some
// detail. First off, `-rpath` is a linker option on Unix platforms
// which adds to the runtime dynamic loader path when looking for
// dynamic libraries. We use this by default on Unix platforms to ensure
// that our nightlies behave the same on Windows, that is they work out
// of the box. This can be disabled, of course, but basically that's why
// we're gated on RUSTC_RPATH here.
//
// Ok, so the astute might be wondering "why isn't `-C rpath` used
// here?" and that is indeed a good question to task. This codegen
// option is the compiler's current interface to generating an rpath.
// Unfortunately it doesn't quite suffice for us. The flag currently
// takes no value as an argument, so the compiler calculates what it
// should pass to the linker as `-rpath`. This unfortunately is based on
// the **compile time** directory structure which when building with
// Cargo will be very different than the runtime directory structure.
//
// All that's a really long winded way of saying that if we use
// `-Crpath` then the executables generated have the wrong rpath of
// something like `$ORIGIN/deps` when in fact the way we distribute
// rustc requires the rpath to be `$ORIGIN/../lib`.
//
// So, all in all, to set up the correct rpath we pass the linker
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
// to change a flag in a binary?
if
self
.config.rust_rpath
{
let
rpath
=
if
target
.contains
(
"apple"
)
{
// Note that we need to take one extra step on macOS to also pass
// `-Wl,-instal_name,@rpath/...` to get things to work right. To
// do that we pass a weird flag to the compiler to get it to do
// so. Note that this is definitely a hack, and we should likely
// flesh out rpath support more fully in the future.
rustflags
.arg
(
"-Zosx-rpath-install-name"
);
Some
(
"-Wl,-rpath,@loader_path/../lib"
)
}
else
if
!
target
.contains
(
"windows"
)
&&
!
target
.contains
(
"wasm32"
)
&&
!
target
.contains
(
"fuchsia"
)
{
Some
(
"-Wl,-rpath,$ORIGIN/../lib"
)
}
else
{
None
};
if
let
Some
(
rpath
)
=
rpath
{
rustflags
.arg
(
&
format!
(
"-Clink-args={}"
,
rpath
));
}
}
if
let
Some
(
host_linker
)
=
self
.linker
(
compiler
.host
)
{
cargo
.env
(
"RUSTC_HOST_LINKER"
,
host_linker
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录