git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH 5/5] Makefile: disable unaligned loads with UBSan
Date: Sat, 15 Jul 2017 19:18:56 +0200	[thread overview]
Message-ID: <de9c876c-f018-ad6b-3813-576ea73dd49a@web.de> (raw)
In-Reply-To: <20170710132450.yxojk5cybejy7und@sigill.intra.peff.net>

Am 10.07.2017 um 15:24 schrieb Jeff King:
> The undefined behavior sanitizer complains about unaligned
> loads, even if they're OK for a particular platform in
> practice. It's possible that they _are_ a problem, of
> course, but since it's a known tradeoff the UBSan errors are
> just noise.
> 
> Let's quiet it automatically by building with
> NO_UNALIGNED_LOADS when SANITIZE=undefined is in use.
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>   Makefile | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index cc03b3c95..3c341b2a6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1015,6 +1015,9 @@ endif
>   ifdef SANITIZE
>   BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
>   BASIC_CFLAGS += -fno-omit-frame-pointer
> +ifeq ($(SANITIZE),undefined)
> +BASIC_CFLAGS += -DNO_UNALIGNED_LOADS
> +endif
>   endif
>   
>   ifndef sysconfdir

Nice, but let's be even nicer!

-- >8 --
Subject: [PATCH] Makefile: allow combining UBSan with other sanitizers

Multiple sanitizers can be specified as a comma-separated list.  Set
the flag NO_UNALIGNED_LOADS even if UndefinedBehaviorSanitizer is not
the only sanitizer to build with.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ba4359ef8d..9b98535a04 100644
--- a/Makefile
+++ b/Makefile
@@ -1022,10 +1022,15 @@ ifdef DEVELOPER
 CFLAGS += $(DEVELOPER_CFLAGS)
 endif
 
+comma := ,
+empty :=
+space := $(empty) $(empty)
+
 ifdef SANITIZE
+SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
 BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
 BASIC_CFLAGS += -fno-omit-frame-pointer
-ifeq ($(SANITIZE),undefined)
+ifneq ($(filter undefined,$(SANITIZERS)),)
 BASIC_CFLAGS += -DNO_UNALIGNED_LOADS
 endif
 endif
-- 
2.13.3

  reply	other threads:[~2017-07-15 17:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 13:24 [PATCH 0/5] building git with clang/gcc address sanitizer Jeff King
2017-07-10 13:24 ` [PATCH 1/5] test-lib: set ASAN_OPTIONS variable before we run git Jeff King
2017-07-10 13:24 ` [PATCH 2/5] test-lib: turn on ASan abort_on_error by default Jeff King
2017-07-10 17:18   ` Junio C Hamano
2017-07-10 13:24 ` [PATCH 3/5] Makefile: add helper for compiling with -fsanitize Jeff King
2017-07-10 17:35   ` Junio C Hamano
2017-07-10 17:44     ` Jeff King
2017-07-10 18:07       ` Junio C Hamano
2017-07-10 20:02       ` Ramsay Jones
2017-07-11  4:44         ` Jeff King
2017-07-10 13:24 ` [PATCH 4/5] Makefile: turn off -fomit-frame-pointer with sanitizers Jeff King
2017-07-10 13:24 ` [PATCH 5/5] Makefile: disable unaligned loads with UBSan Jeff King
2017-07-15 17:18   ` René Scharfe [this message]
2017-07-16 10:17     ` Jeff King
2017-07-16 11:02       ` René Scharfe
2017-07-10 13:30 ` [PATCH 0/5] building git with clang/gcc address sanitizer Jeff King
2017-07-10 14:40 ` Lars Schneider
2017-07-10 15:58   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de9c876c-f018-ad6b-3813-576ea73dd49a@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).