-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Enable zstd for debug compression. #125642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Change this file to make users of the `download-ci-llvm` configuration download | ||
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. | ||
|
||
Last change is for: https://github.com/rust-lang/rust/pull/126298 | ||
Last change is for: https://github.com/rust-lang/rust/pull/125642 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
hide_output() { | ||
set +x | ||
on_err=" | ||
echo ERROR: An error was encountered with the build. | ||
cat /tmp/zstd_build.log | ||
exit 1 | ||
" | ||
trap "$on_err" ERR | ||
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & | ||
PING_LOOP_PID=$! | ||
"$@" &> /tmp/zstd_build.log | ||
trap - ERR | ||
kill $PING_LOOP_PID | ||
rm /tmp/zstd_build.log | ||
set -x | ||
} | ||
|
||
ZSTD=1.5.6 | ||
curl -L https://github.com/facebook/zstd/releases/download/v$ZSTD/zstd-$ZSTD.tar.gz | tar xzf - | ||
|
||
cd zstd-$ZSTD | ||
CFLAGS=-fPIC hide_output make -j$(nproc) VERBOSE=1 | ||
hide_output make install | ||
|
||
cd .. | ||
rm -rf zstd-$ZSTD |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Checks the `compress-debug-sections` option on rust-lld. | ||
|
||
//@ needs-rust-lld | ||
//@ only-linux | ||
//@ ignore-cross-compile | ||
|
||
// FIXME: This test isn't comprehensive and isn't covering all possible combinations. | ||
|
||
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc}; | ||
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @khuey To elaborate a bit why it might be desirable to extend compiletest a bit here: Currently, this test doesn't guarantee we actually test that zstd and zlib compression works, as noted in this FIXME. We could at least test both positive cases if the necessary case recognition was added to compiletest's headers, so that we can implement what you currently do using a runtime There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Unfortunately, revisions are only supported by a subset of test suites (ui, codegen, and maybe a couple more), it is not supported in run-make tests. However, we could try to pass info from compiletest about whether zstd/zlib is available in the environment (or I'm not sure if it's possible, prevent a sub test case from finding zstd/zlib in the environment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, I keep forgetting the arbitrary limitations compiletest has, my mistake. |
||
|
||
fn check_compression(compression: &str, to_find: &str) { | ||
run_in_tmpdir(|| { | ||
let out = rustc() | ||
.arg("-Zlinker-features=+lld") | ||
.arg("-Clink-self-contained=+linker") | ||
.arg("-Zunstable-options") | ||
.arg("-Cdebuginfo=full") | ||
.link_arg(&format!("-Wl,--compress-debug-sections={compression}")) | ||
.input("main.rs") | ||
.run_unchecked(); | ||
let stderr = out.stderr_utf8(); | ||
if stderr.is_empty() { | ||
llvm_readobj().arg("-t").arg("main").run().assert_stdout_contains(to_find); | ||
jieyouxu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
assert_contains( | ||
stderr, | ||
format!( | ||
"LLVM was not built with LLVM_ENABLE_{to_find} \ | ||
or did not find {compression} at build time" | ||
), | ||
); | ||
} | ||
}); | ||
} | ||
|
||
fn main() { | ||
check_compression("zlib", "ZLIB"); | ||
check_compression("zstd", "ZSTD"); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.