-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add initial support for i386 builds #2347
Conversation
I've only tested this with skcms so far I need to do more. Once that patch lands it is unclear if we will simply roll clang forward early or if we will need to wait for Chromium's clang to be updated. |
The runner needs a 32-bit compatible version of ld-linux.so and other basic libraries (including libgcc for some strange reason?) for this to work. That can be done by installing libc6-dev-i386 on the runner. |
I do this now by installing libc6-dev-i386 to the runner (as well as the runner). With dependencies it adds about 50 MB to the image size. It pulls in a lot that is potentially not needed on the runner so reducing that might be worth exploring. |
@jonathanmetzman I think it's a great idea but having opened google/sanitizers#778 (which was closed as a duplicate of google/sanitizers#628) I was under the impression that i386 wasn't the most popular platform among the developers of sanitizers. I'm wondering if this has changed. |
What I was trying to say is that it would be great if there was a way to turn it off completely when (if?) it's merged because after I peppered the code with kludges to get around MSan false positives nobody is willing to fix I'd wait for someone else to test how stable sanitizers on i386 are. |
It isn't the most popular but we've had Chrome's libFuzzer targets running on i386 for months now without any issues. I don't know enough to say it will work but I think it will. CC @kcc @morehouse
There will be an easy way to turn it off. Initially it will be off by default, projects will need to opt-in to it by adding something to project.yaml.
MSAN is totally unsupported on i386. We only plan on using ASAN for now. |
We're not opposed to sanitizers on 32-bit, we just don't have the resources to support them ourselves. We have similar stories for sanitizers on Mac, Windows, etc., but many of those platforms have other interested parties that support them (e.g., Apple). |
I thought you were going to roll it out globally. Looks like it doesn't seem to be the case and I could wait for more issues found by ASan on i386 to be opened to the public (or as a last resort to experiment with it locally) before turning it on. Sorry for the noise. I also went through issues at https://bugs.chromium.org/p/chromium/issues/list?can=1&q=description%3Ax86_libfuzzer_chrome_asan%2Cx86_libfuzzer_chrome_asan_debug and I'm wondering what is going to happen when ASan finds a memory leak for example on i386 and x86_64 with AFL and libFuzzer. Is my understanding correct that it will open 3 different issues? |
No problem. This is a fine approach to take.
Good sleuthing!
No. It will be deduplicated and only one issue should be filed (this will make it harder to determine which bugs are x86 only but iirc there are definitely some clear cases of this). Also we will only use libFuzzer on x86 (AFL doesn't use LSAN btw). |
Need to roll clang past r359802 to support this. |
Chrome rolled to 360094 so this can land even if my OSS-Fuzz clang roll doesn't stick. |
This PR won't contain any documentation changes as I want to land this change before I fully support its use by OSS-Fuzz users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. this will need changes to CF images as well for 32-bit libs right?
Yep. Will change that with my CF-repo changes. |
@@ -22,6 +22,10 @@ if [ -z "${SANITIZER_FLAGS-}" ]; then | |||
export SANITIZER_FLAGS=${!FLAGS_VAR-} | |||
fi | |||
|
|||
if [[ $ARCHITECTURE == "i386" ]]; then | |||
export CFLAGS="-m32 $CFLAGS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make this a CFLAGS_EXTRA and then add support for that similar to
infra/base-images/base-clang/Dockerfile:ENV CXXFLAGS "$CFLAGS $CXXFLAGS_EXTRA"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? as far as I can tell CXXFLAGS_EXTRA is to have "extra" flags to append to CFLAGS to get CXXFLAGS instead of having to repeat the flags. I don't think I understand the benefits having CFLAGS_EXTRA provides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah my bad, this is flags itself, so appending to CFLAGS directly is fine.
--architecture is fine. |
Thanks. I'm not opposed to arch, we can discuss before we make this feature supported. |
Add initial support for i386 (ie: 32 bit/x86) builds.
Build + install i386 versions of clang libraries.
Build + install an i386 version of libc++.
Create a new build option ARCHITECTURE (that defaults to x86_64).
Use the correct CFLAGS and CXXFLAGS (to compile for i386 and use the right libc++) when ARCHITECTURE is i386.