Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
78403f4e
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,发现更多精彩内容 >>
未验证
提交
78403f4e
编写于
7月 29, 2023
作者:
J
Jakub Beránek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove BOLT from bootstrap
上级
a16925d5
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
61 addition
and
294 deletion
+61
-294
src/bootstrap/bolt.rs
src/bootstrap/bolt.rs
+0
-62
src/bootstrap/config.rs
src/bootstrap/config.rs
+0
-9
src/bootstrap/dist.rs
src/bootstrap/dist.rs
+1
-126
src/bootstrap/lib.rs
src/bootstrap/lib.rs
+0
-1
src/bootstrap/llvm.rs
src/bootstrap/llvm.rs
+0
-6
src/etc/completions/x.py.fish
src/etc/completions/x.py.fish
+15
-30
src/etc/completions/x.py.ps1
src/etc/completions/x.py.ps1
+15
-30
src/etc/completions/x.py.sh
src/etc/completions/x.py.sh
+30
-30
未找到文件。
src/bootstrap/bolt.rs
已删除
100644 → 0
浏览文件 @
a16925d5
use
std
::
path
::
Path
;
use
std
::
process
::
Command
;
/// Uses the `llvm-bolt` binary to instrument the artifact at the given `path` with BOLT.
/// When the instrumented artifact is executed, it will generate BOLT profiles into
/// `/tmp/prof.fdata.<pid>.fdata`.
/// Creates the instrumented artifact at `output_path`.
pub
fn
instrument_with_bolt
(
path
:
&
Path
,
output_path
:
&
Path
)
{
let
status
=
Command
::
new
(
"llvm-bolt"
)
.arg
(
"-instrument"
)
.arg
(
&
path
)
// Make sure that each process will write its profiles into a separate file
.arg
(
"--instrumentation-file-append-pid"
)
.arg
(
"-o"
)
.arg
(
output_path
)
.status
()
.expect
(
"Could not instrument artifact using BOLT"
);
if
!
status
.success
()
{
panic!
(
"Could not instrument {} with BOLT, exit code {:?}"
,
path
.display
(),
status
.code
());
}
}
/// Uses the `llvm-bolt` binary to optimize the artifact at the given `path` with BOLT,
/// using merged profiles from `profile_path`.
///
/// The recorded profiles have to be merged using the `merge-fdata` tool from LLVM and the merged
/// profile path should be then passed to this function.
///
/// Creates the optimized artifact at `output_path`.
pub
fn
optimize_with_bolt
(
path
:
&
Path
,
profile_path
:
&
Path
,
output_path
:
&
Path
)
{
let
status
=
Command
::
new
(
"llvm-bolt"
)
.arg
(
&
path
)
.arg
(
"-data"
)
.arg
(
&
profile_path
)
.arg
(
"-o"
)
.arg
(
output_path
)
// Reorder basic blocks within functions
.arg
(
"-reorder-blocks=ext-tsp"
)
// Reorder functions within the binary
.arg
(
"-reorder-functions=hfsort+"
)
// Split function code into hot and code regions
.arg
(
"-split-functions"
)
// Split as many basic blocks as possible
.arg
(
"-split-all-cold"
)
// Move jump tables to a separate section
.arg
(
"-jump-tables=move"
)
// Fold functions with identical code
.arg
(
"-icf=1"
)
// Update DWARF debug info in the final binary
.arg
(
"-update-debug-sections"
)
// Try to reuse old text segments to reduce binary size
.arg
(
"--use-old-text"
)
// Print optimization statistics
.arg
(
"-dyno-stats"
)
.status
()
.expect
(
"Could not optimize artifact using BOLT"
);
if
!
status
.success
()
{
panic!
(
"Could not optimize {} with BOLT, exit code {:?}"
,
path
.display
(),
status
.code
());
}
}
src/bootstrap/config.rs
浏览文件 @
78403f4e
...
...
@@ -1127,15 +1127,6 @@ fn parse_inner(args: &[String], get_toml: impl Fn(&Path) -> TomlConfig) -> Confi
config
.free_args
=
std
::
mem
::
take
(
&
mut
flags
.free_args
);
config
.llvm_profile_use
=
flags
.llvm_profile_use
;
config
.llvm_profile_generate
=
flags
.llvm_profile_generate
;
config
.llvm_bolt_profile_generate
=
flags
.llvm_bolt_profile_generate
;
config
.llvm_bolt_profile_use
=
flags
.llvm_bolt_profile_use
;
if
config
.llvm_bolt_profile_generate
&&
config
.llvm_bolt_profile_use
.is_some
()
{
eprintln!
(
"Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time"
);
exit!
(
1
);
}
// Infer the rest of the configuration.
...
...
src/bootstrap/dist.rs
浏览文件 @
78403f4e
...
...
@@ -18,9 +18,7 @@
use
object
::
read
::
archive
::
ArchiveFile
;
use
object
::
BinaryFormat
;
use
sha2
::
Digest
;
use
crate
::
bolt
::{
instrument_with_bolt
,
optimize_with_bolt
};
use
crate
::
builder
::{
Builder
,
Kind
,
RunConfig
,
ShouldRun
,
Step
};
use
crate
::
cache
::{
Interned
,
INTERNER
};
use
crate
::
channel
;
...
...
@@ -1941,19 +1939,7 @@ fn install_llvm_file(builder: &Builder<'_>, source: &Path, destination: &Path) {
return
;
}
// After LLVM is built, we modify (instrument or optimize) the libLLVM.so library file.
// This is not done in-place so that the built LLVM files are not "tainted" with BOLT.
// We perform the instrumentation/optimization here, on the fly, just before they are being
// packaged into some destination directory.
let
postprocessed
=
if
builder
.config.llvm_bolt_profile_generate
{
builder
.ensure
(
BoltInstrument
::
new
(
source
.to_path_buf
()))
}
else
if
let
Some
(
path
)
=
&
builder
.config.llvm_bolt_profile_use
{
builder
.ensure
(
BoltOptimize
::
new
(
source
.to_path_buf
(),
path
.into
()))
}
else
{
source
.to_path_buf
()
};
builder
.install
(
&
postprocessed
,
destination
,
0o644
);
builder
.install
(
&
source
,
destination
,
0o644
);
}
/// Maybe add LLVM object files to the given destination lib-dir. Allows either static or dynamic linking.
...
...
@@ -2038,117 +2024,6 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
}
}
/// Creates an output path to a BOLT-manipulated artifact for the given `file`.
/// The hash of the file is used to make sure that we don't mix BOLT artifacts amongst different
/// files with the same name.
///
/// We need to keep the file-name the same though, to make sure that copying the manipulated file
/// to a directory will not change the final file path.
fn
create_bolt_output_path
(
builder
:
&
Builder
<
'_
>
,
file
:
&
Path
,
hash
:
&
str
)
->
PathBuf
{
let
directory
=
builder
.out
.join
(
"bolt"
)
.join
(
hash
);
t!
(
fs
::
create_dir_all
(
&
directory
));
directory
.join
(
file
.file_name
()
.unwrap
())
}
/// Instrument the provided file with BOLT.
/// Returns a path to the instrumented artifact.
#[derive(Clone,
Debug,
Eq,
Hash,
PartialEq)]
pub
struct
BoltInstrument
{
file
:
PathBuf
,
hash
:
String
,
}
impl
BoltInstrument
{
fn
new
(
file
:
PathBuf
)
->
Self
{
let
mut
hasher
=
sha2
::
Sha256
::
new
();
hasher
.update
(
t!
(
fs
::
read
(
&
file
)));
let
hash
=
hex
::
encode
(
hasher
.finalize
()
.as_slice
());
Self
{
file
,
hash
}
}
}
impl
Step
for
BoltInstrument
{
type
Output
=
PathBuf
;
const
ONLY_HOSTS
:
bool
=
false
;
const
DEFAULT
:
bool
=
false
;
fn
should_run
(
run
:
ShouldRun
<
'_
>
)
->
ShouldRun
<
'_
>
{
run
.never
()
}
fn
run
(
self
,
builder
:
&
Builder
<
'_
>
)
->
PathBuf
{
if
builder
.build.config
.dry_run
()
{
return
self
.file
.clone
();
}
if
builder
.build.config.llvm_from_ci
{
println!
(
"warning: trying to use BOLT with LLVM from CI, this will probably not work"
);
}
println!
(
"Instrumenting {} with BOLT"
,
self
.file
.display
());
let
output_path
=
create_bolt_output_path
(
builder
,
&
self
.file
,
&
self
.hash
);
if
!
output_path
.is_file
()
{
instrument_with_bolt
(
&
self
.file
,
&
output_path
);
}
output_path
}
}
/// Optimize the provided file with BOLT.
/// Returns a path to the optimized artifact.
///
/// The hash is stored in the step to make sure that we don't optimize the same file
/// twice (even under different file paths).
#[derive(Clone,
Debug,
Eq,
Hash,
PartialEq)]
pub
struct
BoltOptimize
{
file
:
PathBuf
,
profile
:
PathBuf
,
hash
:
String
,
}
impl
BoltOptimize
{
fn
new
(
file
:
PathBuf
,
profile
:
PathBuf
)
->
Self
{
let
mut
hasher
=
sha2
::
Sha256
::
new
();
hasher
.update
(
t!
(
fs
::
read
(
&
file
)));
hasher
.update
(
t!
(
fs
::
read
(
&
profile
)));
let
hash
=
hex
::
encode
(
hasher
.finalize
()
.as_slice
());
Self
{
file
,
profile
,
hash
}
}
}
impl
Step
for
BoltOptimize
{
type
Output
=
PathBuf
;
const
ONLY_HOSTS
:
bool
=
false
;
const
DEFAULT
:
bool
=
false
;
fn
should_run
(
run
:
ShouldRun
<
'_
>
)
->
ShouldRun
<
'_
>
{
run
.never
()
}
fn
run
(
self
,
builder
:
&
Builder
<
'_
>
)
->
PathBuf
{
if
builder
.build.config
.dry_run
()
{
return
self
.file
.clone
();
}
if
builder
.build.config.llvm_from_ci
{
println!
(
"warning: trying to use BOLT with LLVM from CI, this will probably not work"
);
}
println!
(
"Optimizing {} with BOLT"
,
self
.file
.display
());
let
output_path
=
create_bolt_output_path
(
builder
,
&
self
.file
,
&
self
.hash
);
if
!
output_path
.is_file
()
{
optimize_with_bolt
(
&
self
.file
,
&
self
.profile
,
&
output_path
);
}
output_path
}
}
#[derive(Clone,
Debug,
Eq,
Hash,
PartialEq)]
pub
struct
LlvmTools
{
pub
target
:
TargetSelection
,
...
...
src/bootstrap/lib.rs
浏览文件 @
78403f4e
...
...
@@ -39,7 +39,6 @@
dir_is_empty
,
exe
,
libdir
,
mtime
,
output
,
run
,
run_suppressed
,
symlink_dir
,
try_run_suppressed
,
};
mod
bolt
;
mod
builder
;
mod
cache
;
mod
cc_detect
;
...
...
src/bootstrap/llvm.rs
浏览文件 @
78403f4e
...
...
@@ -342,12 +342,6 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
if
let
Some
(
path
)
=
builder
.config.llvm_profile_use
.as_ref
()
{
cfg
.define
(
"LLVM_PROFDATA_FILE"
,
&
path
);
}
if
builder
.config.llvm_bolt_profile_generate
||
builder
.config.llvm_bolt_profile_use
.is_some
()
{
// Relocations are required for BOLT to work.
ldflags
.push_all
(
"-Wl,-q"
);
}
// Disable zstd to avoid a dependency on libzstd.so.
cfg
.define
(
"LLVM_ENABLE_ZSTD"
,
"OFF"
);
...
...
src/etc/completions/x.py.fish
浏览文件 @
78403f4e
此差异已折叠。
点击以展开。
src/etc/completions/x.py.ps1
浏览文件 @
78403f4e
此差异已折叠。
点击以展开。
src/etc/completions/x.py.sh
浏览文件 @
78403f4e
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录