diff mbox

[ubsan] Add bootstrap-ubsan.mk

Message ID 20130730143414.GL17022@redhat.com
State New
Headers show

Commit Message

Marek Polacek July 30, 2013, 2:34 p.m. UTC
This adds the bootstrap-ubsan.mk file so that
--with-build-config=bootstrap-ubsan be possible.  I doesn't work yet,
though :(.

Tested x86_64-pc-linux-gnu, applying to ubsan branch.

+
-B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/ubsan/.libs

	Marek

Comments

Marek Polacek July 30, 2013, 4:56 p.m. UTC | #1
On Tue, Jul 30, 2013 at 04:34:14PM +0200, Marek Polacek wrote:
> This adds the bootstrap-ubsan.mk file so that
> --with-build-config=bootstrap-ubsan be possible.  I doesn't work yet,
> though :(.

One of the reasons is that we use -Werror and e.g. on the following
testcase

static int x;
void
foo (void)
{
  int o = 1;
  x = x >> o;
}

with -O -fsanitize=undefined we generate:
c.c:6:9: warning: ‘x.2’ is used uninitialized in this function [-Wuninitialized]
   x = x >> o;
while with -O -fno-sanitize=undefined there isn't such warning.  When sanitizing,
in .uninit1 we have
  int x.3;
  int x.2;

  <bb 2>: 
  x.3_3 = x.2_1(D) >> 1;
  x = x.3_3;
and when no sanitizing
  int x.1;
  int x.0;

  <bb 2>:
  x.0_2 = x;
  x.1_3 = x.0_2 >> 1;
  x = x.1_3;

The warning comes from warn_uninitialized_vars.  The warning here seems
incorrect, but I'm afraid there isn't much to do about this on the
ubsan side of things.

	Marek
diff mbox

Patch

diff --git a/config/ChangeLog.ubsan b/config/ChangeLog.ubsan
new file mode 100644
index 0000000..f7a2125
--- /dev/null
+++ b/config/ChangeLog.ubsan
@@ -0,0 +1,3 @@ 
+2013-07-30  Marek Polacek  <polacek@redhat.com>
+
+	* bootstrap-ubsan.mk: New.
diff --git a/config/bootstrap-ubsan.mk b/config/bootstrap-ubsan.mk
new file mode 100644
index 0000000..10543f6
--- /dev/null
+++ b/config/bootstrap-ubsan.mk
@@ -0,0 +1,7 @@ 
+# This option enables -fsanitize=undefined for stage2 and stage3.
+
+STAGE2_CFLAGS += -fsanitize=undefined
+STAGE3_CFLAGS += -fsanitize=undefined
+POSTSTAGE1_LDFLAGS += -fsanitize=undefined -static-libubsan \
+		      -B$$r/prev-$(TARGET_SUBDIR)/libsanitizer/ubsan/
\