Skip to content
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

Update for new LLVM pass manager #193

Merged
merged 2 commits into from
Oct 4, 2021
Merged

Conversation

taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Oct 1, 2021

Fixes #192

This drops support for the old nightly, but that should be fine. (See discussion in cargo-fuzz: rust-fuzz/cargo-fuzz#277)

@smoelius
Copy link
Member

smoelius commented Oct 2, 2021

So, as expected, this change breaks afl.rs on stable.

Steps to reproduce:

git submodule update --init
cargo install --path .
cargo new dummy
cd dummy
cargo afl build
mkdir in
head -c 1 /dev/zero > in/zero
cargo afl fuzz -i in -o out target/debug/dummy

So I am wondering what the best way to handle this is. Merge this once -C passes=sancov-module hits stable?

I'm not sure we want to support the latest nightly at the expense of stable.

Thanks for doing this, BTW, @taiki-e.

@taiki-e taiki-e force-pushed the newpm branch 2 times, most recently from 57554a7 to 32dcb7c Compare October 2, 2021 19:19
@frewsxcv
Copy link
Member

frewsxcv commented Oct 2, 2021

If the latest commit works, where we conditionally include the new flag with the right version, then this LGTM!

@taiki-e
Copy link
Contributor Author

taiki-e commented Oct 2, 2021

Updated PR to check for rustc and LLVM versions.

The new flag is used when Rust 1.57+ that rust-lang/rust#88243 is merged and LLVM13+.

Since rust-lang/rust#88243 is available on nightly-2021-09-26+, this drops support for the old 1.57-nightly, but I think it is fine because only nightly is affected.

(Using the way described by @smoelius, I confirmed that it works for stable(1.55.0), beta(1.56.0), and nightly(1.57.0).)

@smoelius
Copy link
Member

smoelius commented Oct 3, 2021

Hmm. I'm having some trouble with the new flag on Linux: https://github.com/smoelius/afl.rs/runs/3779272226?check_suite_focus=true

@smoelius
Copy link
Member

smoelius commented Oct 3, 2021

Adding -C lto=no seems to fix the problem, but I'm not sure that's the right way to fix this problem.

Adding -C link-dead-code=yes doesn't seem to be enough.

I'm curious as to why cargo-fuzz doesn't seem to be experiencing this problem.

@smoelius
Copy link
Member

smoelius commented Oct 4, 2021

I'm curious as to why cargo-fuzz doesn't seem to be experiencing this problem.

It appears cargo-fuzz doesn't have this problem because of -C codegen-units=1:
https://github.com/rust-fuzz/cargo-fuzz/blob/8c964bf183c93cd49ad655eb2f3faecf543d0012/src/project.rs#L204-L214

In particular, if you run the following in a temporary directory with the latest version of carg-fuzz, you will get link errors:

cargo init --lib
cargo fuzz init
cd fuzz
echo -e '\n[profile.dev]\nopt-level = 1' >> Cargo.toml
cargo fuzz build --dev

What's more, if you repeat #193 (comment) with -C codegen-units=1, the target will build: https://github.com/smoelius/afl.rs/runs/3792287661?check_suite_focus=true

@smoelius
Copy link
Member

smoelius commented Oct 4, 2021

@taiki-e, what do you think about adding -C codegen-units=1, perhaps also guarding it with the version_meta.semver.minor >= 57 check?

If you agree, could you also include a short comment about why the option is there?

Thank you again for going to this trouble.

@taiki-e
Copy link
Contributor Author

taiki-e commented Oct 4, 2021

@smoelius: Seems -C codegen-units=1 is the right solution. Thanks for finding it!

perhaps also guarding it with the version_meta.semver.minor >= 57 check?

I read a PR that forces 1 CGU and a related issue, and I feel it's fine to always force 1 CGU on release mode.

If you agree, could you also include a short comment about why the option is there?

Done in eb50593.

@smoelius
Copy link
Member

smoelius commented Oct 4, 2021

Perfect! Thanks, @taiki-e. I'll push a new release soon.

@smoelius smoelius merged commit f22da2d into rust-fuzz:master Oct 4, 2021
@taiki-e taiki-e deleted the newpm branch October 4, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unknown pass name 'sancov'
3 participants