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

Remove flags that may escalate warnings to errors #12116

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Conversation

DonggeLiu
Copy link
Contributor

@DonggeLiu DonggeLiu commented Jun 24, 2024

Some projects failed to compile because its compilation command escalates warnings into errors (e.g., bind9). This is particularly problematic for C projects because JCC assumes these errors are due to C/C++ compatibility issues and then compiles these projects with clang++, which causes different failures that LLM cannot fix (e.g., in bind9, the error is caused by other files using C symbols that are not available in C++).

This PR removes all flags that may cause this problem in all compilation commands.
When tested locally, it fixed the compilation error in bind9 (with some manual fix on the fuzz target).


Here is the command that contains -Werror* and causes this problem in bind9:

clang -DHAVE_CONFIG_H -I. -I..  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DISC_MEM_DEFAULTFILL=1 -DISC_MEM_TRACKLINES=1 -DISC_LIST_CHECKINIT=1 -DISC_STATS_CHECKUNDERFLOW=1 -DDNS_RBTDB_STRONG_RWLOCK_CHECK=1 -DISC_MUTEX_ERROR_CHECK=1 -include ../config.h -I./include -I../include -I../lib/isc/include -I../lib/isc/include -I../lib/dns/include -I../lib/dns/include -I/usr/include/x86_64-linux-gnu  -DFUZZDIR=\"/src/bind9/fuzz\" -I../lib/dns -I../lib/isc -I../tests/include  -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-initializers -Wformat -Wshadow -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla -fno-strict-aliasing -fno-delete-null-pointer-checks -fdiagnostics-show-option -Werror -Wno-vla -O1 -fno-omit-frame-pointer -gline-tables-only -Wno-error=enum-constexpr-conversion -Wno-error=incompatible-function-pointer-types -Wno-error=int-conversion -Wno-error=deprecated-declarations -Wno-error=implicit-function-declaration -Wno-error=implicit-int -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -I/usr/include/x86_64-linux-gnu -pthread -MT isc_lex_gettoken.o -MD -MP -MF $depbase.Tpo -c -o isc_lex_gettoken.o isc_lex_gettoken.c

@DonggeLiu
Copy link
Contributor Author

/gcbrun

Comment on lines 50 to 53
if strings.HasPrefix(arg, "-Werror") ||
arg == "-pedantic-errors" ||
arg == "-Wfatal-errors" ||
arg == "-Weverything" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be just -Werror and -Wfatal-errors instead? The other two (at least -Weverything) should not result in a compilation error when they trigger, afaik

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mihai!
Yes, I should remove -Weverything. I was under the (incorrect) impression that too many warnings would somehow cause the command to fail.

I add -pedantic-errors here because I reckon it will generate errors for any code that does not strictly adhere to the ISO C or ISO C++ standards.
Please let me know if I misinterpreted it : )

if retcode == 0 {
WriteStdErrOut(fullCmdArgs, out, errstr)
os.Exit(0)
}
Copy link
Contributor Author

@DonggeLiu DonggeLiu Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are identical to the original except for their indentations.
The original lines are misaligned with others, likely due to space/tab.

Copy link
Member

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you.

Need to experiment with this to see if the way Bazel detects compiler features is impacted (it compiles a default .cc file for each feature under test, it can test for example if -Werror is supported by looking at what gets compiled when the flag is passed). Also, one extra compilation might increase number of times we see the same error message, so confuse the error parser, the prompter fixer.

But for now, let's go with this, if nothing breaks we're good

Copy link
Contributor

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DonggeLiu DonggeLiu merged commit c36da73 into master Jun 26, 2024
18 of 19 checks passed
@DonggeLiu DonggeLiu deleted the jcc-warn-not-err branch June 26, 2024 00:44
@DonggeLiu
Copy link
Contributor Author

Need to experiment with this to see if the way Bazel detects compiler features is impacted

Thanks! I conducted an experiment with C projects last night, here is the result:
https://llm-exp.oss-fuzz.com/Result-reports/scheduled/2024-06-26-weekly-all/

I will look into them today and pay extra attention to Bazel projects.

DonggeLiu added a commit to google/oss-fuzz-gen that referenced this pull request Jun 26, 2024
Observing many compatibility issues caused by building a C++ fuzz target
with C projects, I want to test whether separating them can lead to a
higher compilation rate.

This PR experiment uses C-specific prompts and examples for C projects.
It also uses the fix in google/oss-fuzz#12116
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.

None yet

3 participants