Oops, here is a corrected patch... the quotes are important for CFLAGS.

Andy


On Sat, Mar 12, 2016 at 12:51 AM, Andy Chu <[email protected]> wrote:
> single.sh is called when you do 'make test_$COMMAND'.  For example, you
> can now run tests under a Clang ASAN build like this:
>
> make CC=clang CFLAGS=-fsanitize=address test_sed
>
> Without this patch, the binary will fail with runtime errors.
>
> (ASAN and afl-fuzz sort of go together, since you can find inputs that
> access uninitialized memory but don't necessarily crash the process.
> And ASAN is useful without afl-fuzz by just running tests with it.)
>
> Andy
From 56cefa061c9d720ea222851aac71aeaf503787ce Mon Sep 17 00:00:00 2001
From: Andy Chu <[email protected]>
Date: Sat, 12 Mar 2016 00:43:04 -0800
Subject: [PATCH] Pass the parent make variables when invoking make in
 scripts/single.sh.

single.sh is called when you do 'make test_$COMMAND'.  For example, you
can now run tests under a Clang ASAN build like this:

make CC=clang CFLAGS=-fsanitize=address test_sed
---
 Makefile          | 2 ++
 scripts/single.sh | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 40e95b1..5142b16 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,8 @@
 
 HOSTCC?=cc
 
+# If the list of exported variables changes, also change the make invocation
+# in scripts/single.sh.
 export CROSS_COMPILE CFLAGS OPTIMIZE LDOPTIMIZE CC HOSTCC V
 
 all: toybox
diff --git a/scripts/single.sh b/scripts/single.sh
index 522a713..cdb756f 100755
--- a/scripts/single.sh
+++ b/scripts/single.sh
@@ -38,6 +38,8 @@ do
   echo "# CONFIG_TOYBOX is not set" >> "$KCONFIG_CONFIG" &&
   grep "CONFIG_TOYBOX_" .config >> "$KCONFIG_CONFIG" &&
 
-  make &&
+  # This list of variables matches the 'export' line in the Makefile.
+  make CROSS_COMPILE="$CROSS_COMPILE" CFLAGS="$CFLAGS" OPTIMIZE="$OPTIMIZE" \
+    LDOPTIMIZE="$LDOPTIMIZE" CC="$CC" HOSTCC="$HOSTCC" V="$V" &&
   mv -f toybox $PREFIX$i || exit 1
 done
-- 
1.9.1

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to