Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a4199b45
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,发现更多精彩内容 >>
提交
a4199b45
编写于
4月 24, 2020
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc-book: Document `-C relocation-model`
上级
76d85de2
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
41 addition
and
5 deletion
+41
-5
src/doc/rustc/src/codegen-options/index.md
src/doc/rustc/src/codegen-options/index.md
+39
-4
src/librustc_session/options.rs
src/librustc_session/options.rs
+2
-1
未找到文件。
src/doc/rustc/src/codegen-options/index.md
浏览文件 @
a4199b45
...
...
@@ -319,11 +319,46 @@ to a valid `.profdata` file. See the chapter on
## relocation-model
This option lets you choose which
[
relocation
](
https://en.wikipedia.org/wiki/Relocation_\(computing\
)
) model to
use.
This option controls generation of
[
position-independent code (PIC)
](
https://en.wikipedia.org/wiki/Position-independent_code
)
.
To find the valid options for this flag, run
`rustc --print relocation-models`
.
Supported values for this option are:
#### Primary relocation models
-
`static`
- non-relocatable code, machine instructions may use absolute addressing modes.
-
`pic`
- fully relocatable position independent code,
machine instructions need to use relative addressing modes.
Equivalent to the "uppercase"
`-fPIC`
or
`-fPIE`
options in other compilers,
depending on the produced crate types.
This is the default model for majority of supported targets.
#### Special relocation models
-
`dynamic-no-pic`
- relocatable external references, non-relocatable code.
Only makes sense on Darwin and is rarely used.
If StackOverflow tells you to use this as an opt-out of PIC or PIE, don't believe it,
use
`-C relocation-model=static`
instead.
-
`ropi`
,
`rwpi`
and
`ropi-rwpi`
- relocatable code and read-only data, relocatable read-write data,
and combination of both, respectively.
Only makes sense for certain embedded ARM targets.
-
`default`
- relocation model default to the current target.
Only makes sense as an override for some other explicitly specified relocation model
previously set on the command line.
Supported values can also be discovered by running
`rustc --print relocation-models`
.
#### Linking effects
In addition to codegen effects,
`relocation-model`
has effects during linking.
If the relocation model is
`pic`
and the current target supports position-independent executables
(PIE), the linker will be instructed (
`-pie`
) to produce one.
If the target doesn't support both position-independent and statically linked executables,
then
`-C target-feature=+crt-static`
"wins" over
`-C relocation-model=pic`
,
and the linker is instructed (
`-static`
) to produce a statically linked
but not position-independent executable.
## remark
...
...
src/librustc_session/options.rs
浏览文件 @
a4199b45
...
...
@@ -706,7 +706,8 @@ fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&st
profile_use
:
Option
<
PathBuf
>
=
(
None
,
parse_opt_pathbuf
,
[
TRACKED
],
"use the given `.profdata` file for profile-guided optimization"
),
relocation_model
:
Option
<
RelocModel
>
=
(
None
,
parse_relocation_model
,
[
TRACKED
],
"choose the relocation model to use (`rustc --print relocation-models` for details)"
),
"control generation of position-independent code (PIC)
\
(`rustc --print relocation-models` for details)"
),
remark
:
Passes
=
(
Passes
::
Some
(
Vec
::
new
()),
parse_passes
,
[
UNTRACKED
],
"print remarks for these optimization passes (space separated, or
\"
all
\"
)"
),
rpath
:
bool
=
(
false
,
parse_bool
,
[
UNTRACKED
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录