Re: [PATCH] Makefile: use CXXFLAGS for linking fuzzers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



steadmon@xxxxxxxxxx writes:

> OSS-Fuzz requires C++-specific flags to link fuzzers. Passing these in
> CFLAGS causes lots of build warnings. Using separate CXXFLAGS avoids
> this.

We are not a C++ shop, so allow me to show ignorance about how
projects that are OSS-Fuzz-enabled work.  Do they use one set of
CXXFLAGS when compiling the "real thing" and a separate set (perhaps
one is subset of the other, or perhaps these two just have overlap)
of CXXFLAGS when building to link with the fuzzer?

What I am trying to get at is if this should be CXXFLAGS or
CXX_FUZZER_FLAGS.  If the OSS-Fuzz-enabled C++ projects use one set
of flags for the "main" part of the project (to produce binaries to
be run by the end users) and then link with extra flags to work with
fuzzers, I would imagine that they won't call the latter CXXFLAGS
but call it something else, and we probably should follow suit if
that is the case.

Not that we plan to (re)write the maint part of Git in C++ ever, so
I am personally OK with sacrificing the most generic CXXFLAGS macro
for the sole use of OSS-Fuzz linkage, but I'd prefer to leave the
door open so that other things like OSS-Fuzz that require C++ can be
added like your work does to the project.

Thanks.


> Signed-off-by: Josh Steadmon <steadmon@xxxxxxxxxx>
> ---
>  Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index bbfbb4292d..5462bc4b6b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -497,6 +497,7 @@ GIT-VERSION-FILE: FORCE
>  # CFLAGS and LDFLAGS are for the users to override from the command line.
>  
>  CFLAGS = -g -O2 -Wall
> +CXXFLAGS ?= $(CFLAGS)
>  LDFLAGS =
>  ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
>  ALL_LDFLAGS = $(LDFLAGS)
> @@ -3098,14 +3099,14 @@ cover_db_html: cover_db
>  # An example command to build against libFuzzer from LLVM 4.0.0:
>  #
>  # make CC=clang CXX=clang++ \
> -#      CFLAGS="-fsanitize-coverage=trace-pc-guard -fsanitize=address" \
> +#      CXXFLAGS="-fsanitize-coverage=trace-pc-guard -fsanitize=address" \
>  #      LIB_FUZZING_ENGINE=/usr/lib/llvm-4.0/lib/libFuzzer.a \
>  #      fuzz-all
>  #
>  .PHONY: fuzz-all
>  
>  $(FUZZ_PROGRAMS): all
> -	$(QUIET_LINK)$(CXX) $(CFLAGS) $(LIB_OBJS) $(BUILTIN_OBJS) \
> +	$(QUIET_LINK)$(CXX) $(CXXFLAGS) $(LIB_OBJS) $(BUILTIN_OBJS) \
>  		$(XDIFF_OBJS) $(EXTLIBS) git.o $@.o $(LIB_FUZZING_ENGINE) -o $@
>  
>  fuzz-all: $(FUZZ_PROGRAMS)



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux