add AFL_NOOPT
MODIFY
README.md
README.md
@@ -399,11 +399,20 @@ How to do this is described below.
Then build the target. (Usually with `make`)
-**NOTE**: sometimes configure and build systems are fickle and do not like
+**NOTES**
+
+1. sometimes configure and build systems are fickle and do not like
stderr output (and think this means a test failure) - which is something
afl++ like to do to show statistics. It is recommended to disable them via
`export AFL_QUIET=1`.
+2. sometimes configure and build systems error on warnings - these should be
+ disabled (e.g. `--disable-werror` for some configure scripts`
+
+3. in case the configure/build system complains about afl++'s compiler and
+ aborts then set `export AFL_NOOPT=1` which will then just behave like the
+ real compiler. This option has to be unset again before building the target!
+
##### configure
For `configure` build systems this is usually done by:

MODIFY
docs/env_variables.md
docs/env_variables.md
@@ -26,6 +26,17 @@ Because (with the exception of the --afl-MODE command line option) the
compile-time tools do not accept afl specific command-line options, they
make fairly broad use of environmental variables instead:
+ - Some build/configure scripts break with afl++ compilers. To be able to
+ pass them, do:
+```
+ export CC=afl-cc
+ export CXX=afl-c++
+ export AFL_NOOPT=1
+ ./configure --disable-shared --disabler-werror
+ unset AFL_NOOPT
+ make
+```
+
- Most afl tools do not print any output if stdout/stderr are redirected.
If you want to get the output into a file then set the `AFL_DEBUG`
environment variable.

MODIFY
include/envs.h
include/envs.h
@@ -119,10 +119,12 @@ static char *afl_environment_variables[] = {
"AFL_NO_PYTHON",
"AFL_UNTRACER_FILE",
"AFL_LLVM_USE_TRACE_PC",
- "AFL_NO_X86", // not really an env but we dont want to warn on it
"AFL_MAP_SIZE",
"AFL_MAPSIZE",
"AFL_MAX_DET_EXTRAS",
+ "AFL_NO_X86", // not really an env but we dont want to warn on it
+ "AFL_NOOPT",
+ "AFL_PASSTHROUGH",
"AFL_PATH",
"AFL_PERFORMANCE_FILE",
"AFL_PRELOAD",

MODIFY
src/afl-cc.c
src/afl-cc.c
@@ -1025,7 +1025,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
int main(int argc, char **argv, char **envp) {
- int i;
+ int i, passthrough = 0;
char *callname = argv[0], *ptr = NULL;
if (getenv("AFL_DEBUG")) {
@@ -1045,6 +1045,13 @@ int main(int argc, char **argv, char **envp) {
}
+ if (getenv("AFL_PASSTHROUGH") || getenv("AFL_NOOPT")) {
+
+ passthrough = 1;
+ if (!debug) { be_quiet = 1; }
+
+ }
+
if ((ptr = strrchr(callname, '/')) != NULL) callname = ptr + 1;
argvnull = (u8 *)argv[0];
check_environment_vars(envp);
@@ -1665,6 +1672,7 @@ int main(int argc, char **argv, char **envp) {
" AFL_DONT_OPTIMIZE: disable optimization instead of -O3\n"
" AFL_NO_BUILTIN: no builtins for string compare functions (for "
"libtokencap.so)\n"
+ " AFL_NOOP: behave lik a normal compiler (to pass configure tests)\n"
" AFL_PATH: path to instrumenting pass and runtime "
"(afl-compiler-rt.*o)\n"
" AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n"
@@ -1977,8 +1985,17 @@ int main(int argc, char **argv, char **envp) {
}
+ if (passthrough) {
+
+ argv[0] = cc_params[0];
+ execvp(cc_params[0], (char **)argv);
+
+ } else {
+
execvp(cc_params[0], (char **)cc_params);
+ }
+
FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
return 0;

MODIFY
src/afl-common.c
src/afl-common.c
@@ -682,6 +682,7 @@ void check_environment_vars(char **envp) {
env[strlen(afl_environment_variables[i])] == '=') {
match = 1;
+
if ((val = getenv(afl_environment_variables[i])) && !*val) {
WARNF(

add AFL_NOOPT