Bump bpf-tools to v1.19 (#21256) (#21264)

Toolchain upgrade to rust 1.56.0 and clang 13.0.

(cherry picked from commit 3f4f05865d)

Co-authored-by: Dmitri Makarov <dmakarov@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2021-11-15 20:59:58 +00:00
committed by GitHub
parent 6a6dd86262
commit a05c08e711
3 changed files with 75 additions and 32 deletions

View File

@ -1369,19 +1369,19 @@ fn assert_instruction_count() {
#[cfg(feature = "bpf_c")] #[cfg(feature = "bpf_c")]
{ {
programs.extend_from_slice(&[ programs.extend_from_slice(&[
("alloc", 1137), ("alloc", 1237),
("bpf_to_bpf", 13), ("bpf_to_bpf", 96),
("multiple_static", 8), ("multiple_static", 52),
("noop", 42), ("noop", 5),
("noop++", 42), ("noop++", 5),
("relative_call", 10), ("relative_call", 26),
("return_data", 480), ("return_data", 980),
("sanity", 174), ("sanity", 1255),
("sanity++", 174), ("sanity++", 1260),
("secp256k1_recover", 357), ("secp256k1_recover", 25383),
("sha", 694), ("sha", 1328),
("struct_pass", 8), ("struct_pass", 108),
("struct_ret", 22), ("struct_ret", 28),
]); ]);
} }
#[cfg(feature = "bpf_rust")] #[cfg(feature = "bpf_rust")]

View File

@ -92,7 +92,7 @@ if [[ ! -e criterion-$version.md || ! -e criterion ]]; then
fi fi
# Install Rust-BPF # Install Rust-BPF
version=v1.12 version=v1.19
if [[ ! -e bpf-tools-$version.md || ! -e bpf-tools ]]; then if [[ ! -e bpf-tools-$version.md || ! -e bpf-tools ]]; then
( (
set -e set -e

View File

@ -58,7 +58,7 @@ where
S: AsRef<OsStr>, S: AsRef<OsStr>,
{ {
let args = args.into_iter().collect::<Vec<_>>(); let args = args.into_iter().collect::<Vec<_>>();
print!("Running: {}", program.display()); print!("cargo-build-bpf child: {}", program.display());
for arg in args.iter() { for arg in args.iter() {
print!(" {}", arg.as_ref().to_str().unwrap_or("?")); print!(" {}", arg.as_ref().to_str().unwrap_or("?"));
} }
@ -92,19 +92,24 @@ fn install_if_missing(
version: &str, version: &str,
url: &str, url: &str,
download_file_name: &str, download_file_name: &str,
target_path: &Path,
) -> Result<(), String> { ) -> Result<(), String> {
// Check whether the target path is an empty directory. This can
// happen if package download failed on previous run of
// cargo-build-bpf. Remove the target_path directory in this
// case.
if target_path.is_dir()
&& target_path
.read_dir()
.map_err(|err| err.to_string())?
.next()
.is_none()
{
fs::remove_dir(&target_path).map_err(|err| err.to_string())?;
}
// Check whether the package is already in ~/.cache/solana. // Check whether the package is already in ~/.cache/solana.
// Download it and place in the proper location if not found. // Download it and place in the proper location if not found.
let home_dir = PathBuf::from(env::var("HOME").unwrap_or_else(|err| {
eprintln!("Can't get home directory path: {}", err);
exit(1);
}));
let target_path = home_dir
.join(".cache")
.join("solana")
.join(version)
.join(package);
if !target_path.is_dir() if !target_path.is_dir()
&& !target_path && !target_path
.symlink_metadata() .symlink_metadata()
@ -142,7 +147,7 @@ fn install_if_missing(
let source_path = source_base.join(package); let source_path = source_base.join(package);
// Check whether the correct symbolic link exists. // Check whether the correct symbolic link exists.
let invalid_link = if let Ok(link_target) = source_path.read_link() { let invalid_link = if let Ok(link_target) = source_path.read_link() {
if link_target != target_path { if link_target.ne(target_path) {
fs::remove_file(&source_path).map_err(|err| err.to_string())?; fs::remove_file(&source_path).map_err(|err| err.to_string())?;
true true
} else { } else {
@ -430,14 +435,41 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m
} else { } else {
"solana-bpf-tools-linux.tar.bz2" "solana-bpf-tools-linux.tar.bz2"
}; };
let home_dir = PathBuf::from(env::var("HOME").unwrap_or_else(|err| {
eprintln!("Can't get home directory path: {}", err);
exit(1);
}));
let version = "v1.19";
let package = "bpf-tools";
let target_path = home_dir
.join(".cache")
.join("solana")
.join(version)
.join(package);
install_if_missing( install_if_missing(
config, config,
"bpf-tools", package,
"v1.12", version,
"https://github.com/solana-labs/bpf-tools/releases/download", "https://github.com/solana-labs/bpf-tools/releases/download",
bpf_tools_download_file_name, bpf_tools_download_file_name,
&target_path,
) )
.expect("Failed to install bpf-tools"); .unwrap_or_else(|err| {
// The package version directory doesn't contain a valid
// installation, and it should be removed.
let target_path_parent = target_path.parent().expect("Invalid package path");
fs::remove_dir_all(&target_path_parent).unwrap_or_else(|err| {
eprintln!(
"Failed to remove {} while recovering from installation failure: {}",
target_path_parent.to_string_lossy(),
err,
);
exit(1);
});
eprintln!("Failed to install bpf-tools: {}", err);
exit(1);
});
link_bpf_toolchain(config); link_bpf_toolchain(config);
let llvm_bin = config let llvm_bin = config
@ -450,9 +482,20 @@ fn build_bpf_package(config: &Config, target_directory: &Path, package: &cargo_m
env::set_var("AR", llvm_bin.join("llvm-ar")); env::set_var("AR", llvm_bin.join("llvm-ar"));
env::set_var("OBJDUMP", llvm_bin.join("llvm-objdump")); env::set_var("OBJDUMP", llvm_bin.join("llvm-objdump"));
env::set_var("OBJCOPY", llvm_bin.join("llvm-objcopy")); env::set_var("OBJCOPY", llvm_bin.join("llvm-objcopy"));
let mut rust_flags = String::from("-C lto=no"); let rustflags = match env::var("RUSTFLAGS") {
rust_flags.push_str(" -C opt-level=2"); Ok(rf) => {
env::set_var("RUSTFLAGS", rust_flags); if rf.contains("-C lto=no") {
rf
} else {
rf + &" -C lto=no".to_string()
}
}
_ => "-C lto=no".to_string(),
};
if config.verbose {
println!("RUSTFLAGS={}", rustflags);
}
env::set_var("RUSTFLAGS", rustflags);
let cargo_build = PathBuf::from("cargo"); let cargo_build = PathBuf::from("cargo");
let mut cargo_build_args = vec![ let mut cargo_build_args = vec![
"+bpf", "+bpf",