From 2b8d134be46071f6869ed45ebbf521d91c93fb66 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 8 Apr 2021 09:49:30 -0400 Subject: sim: set ASAN_OPTIONS=detect_leaks=0 when running igen and opc2c The igen/dgen and opc2c tools leak their heap-allocated memory (on purpose) at program exit, which makes AddressSanitizer fail the tool execution. This breaks the build, as it makes the tool return a non-zero exit code. Fix that by disabling leak detection through the setting of that environment variable. I also changed the opc2c rules for m32c to go through a temporary file. What happened is that the failing opc2c would produce an incomplete file (probably because ASan exits the process before stdout is flushed). This meant that further make attempts didn't try to re-create the file, as it already existed. A "clean" was therefore necessary. This can also happen in regular builds if the user interrupts the build (^C) in the middle of the opc2c execution and tries to resume it. Going to a temporary file avoids this issue. sim/m32c/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running opc2c. sim/mips/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/mn10300/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/ppc/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/v850/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. Change-Id: I00f21d4dc1aff0ef73471925d41ce7c23e83e082 --- sim/m32c/ChangeLog | 4 ++++ sim/m32c/Makefile.in | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'sim/m32c') diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog index 31e3523..458024c 100644 --- a/sim/m32c/ChangeLog +++ b/sim/m32c/ChangeLog @@ -1,3 +1,7 @@ +2021-04-08 Simon Marchi + + * Makefile.in: Set ASAN_OPTIONS when running opc2c. + 2021-04-07 Simon Marchi * opc2c.c (main): Remove vlist variable. diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in index 6bc5c5b..186c9c0 100644 --- a/sim/m32c/Makefile.in +++ b/sim/m32c/Makefile.in @@ -46,11 +46,17 @@ LIBS = $B/bfd/libbfd.a $B/libiberty/libiberty.a arch = m32c +# opc2c leaks memory, and therefore makes AddressSanitizer unhappy. Disable +# leak detection while running it. +OPC2C = ASAN_OPTIONS=detect_leaks=0 ./opc2c + r8c.c : r8c.opc opc2c - ./opc2c -l r8c.out $(srcdir)/r8c.opc > r8c.c + $(OPC2C) -l r8c.out $(srcdir)/r8c.opc > r8c.c.tmp + mv r8c.c.tmp r8c.c m32c.c : m32c.opc opc2c - ./opc2c -l m32c.out $(srcdir)/m32c.opc > m32c.c + $(OPC2C) -l m32c.out $(srcdir)/m32c.opc > m32c.c.tmp + mv m32c.c.tmp m32c.c opc2c : opc2c.o safe-fgets.o $(LINK_FOR_BUILD) $^ -- cgit v1.1