]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: set ASAN_OPTIONS=detect_leaks=0 when running igen and opc2c
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 8 Apr 2021 13:49:30 +0000 (09:49 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 8 Apr 2021 13:49:30 +0000 (09:49 -0400)
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/common/Make-common.in
sim/m32c/ChangeLog
sim/m32c/Makefile.in
sim/mips/ChangeLog
sim/mips/Makefile.in
sim/mn10300/ChangeLog
sim/mn10300/Makefile.in
sim/ppc/ChangeLog
sim/ppc/Makefile.in
sim/v850/ChangeLog
sim/v850/Makefile.in

index c8445bce59eac58208209f99b109bd1db5c37fa0..28f50abb22053c39c67f818b69dbc025736d3faf 100644 (file)
@@ -111,6 +111,10 @@ COMPILE.post = -c -o $@
 COMPILE = $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post)
 POSTCOMPILE = @true
 
+# igen leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running it.
+IGEN = ASAN_OPTIONS=detect_leaks=0 ../igen/igen
+
 # Each simulator's Makefile.in defines one or more of these variables
 # to override our settings as necessary.  There is no need to define these
 # in the simulator's Makefile.in if one is using the default value.  In fact
index 31e3523bd533b3ad73e68c412d41390ae680aeee..458024c575fcd9583d86d8c90144f64e369a0040 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-08  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * Makefile.in: Set ASAN_OPTIONS when running opc2c.
+
 2021-04-07  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * opc2c.c (main): Remove vlist variable.
index 6bc5c5b743d9aee3e75154daca4ce959c63c0b9f..186c9c063d329fe4517db6b587c4b36eaf7398be 100644 (file)
@@ -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) $^
index 8c2bc70336fad78c8b0208166fa827e2a6e86219..6d515f80486c4af2daaf67459dc3a6cc9c36cbc1 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-08  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * Makefile.in: Set ASAN_OPTIONS when running igen.
+
 2021-04-04  Steve Ellcey  <sellcey@mips.com>
            Faraz Shahbazker  <fshahbazker@wavecomp.com>
 
index c66c6e839782a98b3421e252a4476cb6daf69681..00906451c4cc379d5376c15cdc36e149cd531f65 100644 (file)
@@ -149,7 +149,7 @@ BUILT_SRC_FROM_IGEN = \
 $(BUILT_SRC_FROM_IGEN): tmp-igen
 
 tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -220,7 +220,7 @@ BUILT_SRC_FROM_M16 = \
 $(BUILT_SRC_FROM_M16): tmp-m16
 
 tmp-m16: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -255,7 +255,7 @@ tmp-m16: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
        $(SHELL) $(srcdir)/../../move-if-change tmp-model.c m16_model.c
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.h m16_support.h
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.c m16_support.c
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -292,7 +292,7 @@ tmp-m16: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
        $(SHELL) $(srcdir)/../../move-if-change tmp-model.c m32_model.c
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.h m32_support.h
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.c m32_support.c
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -346,7 +346,7 @@ BUILT_SRC_FROM_MICROMIPS = \
 $(BUILT_SRC_FROM_MICROMIPS): tmp-micromips
 
 tmp-micromips: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -391,7 +391,7 @@ tmp-micromips: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
                                                micromips16_support.h
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.c \
                                                micromips16_support.c
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -436,7 +436,7 @@ tmp-micromips: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
                                                micromips32_support.h
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.c \
                                                micromips32_support.c
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -481,7 +481,7 @@ tmp-micromips: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
                                                micromips_m32_support.h
        $(SHELL) $(srcdir)/../../move-if-change tmp-support.c \
                                                micromips_m32_support.c
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
@@ -521,7 +521,7 @@ tmp-mach-multi: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
            m16*) e="-B 16 -H 15 -o $(M16_DC) -F 16" ;; \
            *) e="-B 32 -H 31 -o $(IGEN_DC) -F $${f}" ;; \
          esac; \
-         ../igen/igen \
+         $(IGEN) \
                $(IGEN_TRACE) \
                $${e} \
                -I $(srcdir) \
@@ -574,7 +574,7 @@ tmp-mach-multi: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
        done
        touch tmp-mach-multi
 tmp-itable-multi: $(IGEN_INSN) $(IGEN_DC) ../igen/igen $(IGEN_INCLUDE)
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -I $(srcdir) \
                -Werror \
index 4a2d2b3f65e2a5fd5488a5471fa0e98ad7012c0e..9b3a9c581342c5f26c54e096cfa6b37be22ea355 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-08  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * Makefile.in: Set ASAN_OPTIONS when running igen.
+
 2021-04-02  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (../igen/igen): Delete rule.
index 6cdf9712882bd1965fe4bc960c2135b25354be70..773b7f9a0c593907293af7beeba9bebe6e2cec23 100644 (file)
@@ -69,7 +69,7 @@ IGEN_TRACE= # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejec
 IGEN_INSN=$(srcdir)/mn10300.igen $(srcdir)/am33.igen $(srcdir)/am33-2.igen
 IGEN_DC=$(srcdir)/mn10300.dc
 tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -G gen-direct-access \
                 -M mn10300,am33 -G gen-multi-sim=am33 \
index 539d3179ef8b83b7c422578f9b5ea085de36a033..910996fe3460aa8e478ef49617f4e6ae5fc90252 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-08  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * Makefile.in: Set ASAN_OPTIONS when running igen.
+
 2021-04-03  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (install): Install as run-ppc when not the primary arch.
index d2bd1d317754d25022f4860bbecc98ff74e9af9f..d9d01985404b697f14367ccd5de92166a3692940 100644 (file)
@@ -133,6 +133,12 @@ IGEN_FLAGS = \
        $(IGEN_SMP) \
        $(IGEN_LINE_NR)
 
+# igen/dgen leak memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running them.
+
+IGEN = ASAN_OPTIONS=detect_leaks=0 ./igen
+DGEN = ASAN_OPTIONS=detect_leaks=0 ./dgen
+
 .NOEXPORT:
 MAKEOVERRIDES=
 
@@ -666,7 +672,7 @@ ppc-config.h: $(CONFIG_FILE)
 
 
 tmp-dgen: dgen ppc-spr-table $(srcdir)/../../move-if-change
-       ./dgen $(DGEN_FLAGS) \
+       $(DGEN) $(DGEN_FLAGS) \
                -r $(srcdir)/ppc-spr-table \
                -n spreg.h -hp tmp-spreg.h \
                -n spreg.c -p  tmp-spreg.c
@@ -675,7 +681,7 @@ tmp-dgen: dgen ppc-spr-table $(srcdir)/../../move-if-change
        touch tmp-dgen
 
 tmp-igen: igen $(srcdir)/ppc-instructions $(srcdir)/altivec.igen $(srcdir)/e500.igen $(IGEN_OPCODE_RULES) $(srcdir)/../../move-if-change tmp-ld-decode tmp-ld-cache tmp-ld-insn tmp-filter
-       ./igen  $(IGEN_FLAGS) \
+       $(IGEN) $(IGEN_FLAGS) \
                -o $(srcdir)/$(IGEN_OPCODE_RULES) \
                -I $(srcdir) -i $(srcdir)/ppc-instructions \
                -n icache.h    -hc tmp-icache.h \
index 27af3c305d0a18aa9296f7585da9be3c0a8b7f8f..4488b2eb7723b8a88e9db5e9c188d2ec8d8156ab 100644 (file)
@@ -1,3 +1,7 @@
+2021-04-08  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * Makefile.in: Set ASAN_OPTIONS when running igen.
+
 2021-04-02  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (../igen/igen): Delete rule.
index 983fc79f93a73318846e3ec5c274ead340c5290a..250129c549f7d029627ab75473a5581b43be58ff 100644 (file)
@@ -69,7 +69,7 @@ IGEN_TRACE= # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejec
 IGEN_INSN=$(srcdir)/v850.igen
 IGEN_DC=$(srcdir)/v850-dc
 tmp-igen: $(IGEN_INSN) $(IGEN_DC) ../igen/igen
-       ../igen/igen \
+       $(IGEN) \
                $(IGEN_TRACE) \
                -G gen-direct-access \
                -G gen-zero-r0 \