https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69329
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Mikhail Maltsev from comment #1) > I tried this patch: > > diff --git a/Makefile.in b/Makefile.in > index 2733c4d..31ee4c0 100644 > --- a/Makefile.in > +++ b/Makefile.in > @@ -789,7 +789,8 @@ BASE_FLAGS_TO_PASS = \ > $(CXX_FOR_TARGET_FLAG_TO_PASS) \ > "TFLAGS=$(TFLAGS)" \ > "CONFIG_SHELL=$(SHELL)" \ > - "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" > + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ > + "LSAN_OPTIONS=$(LSAN_OPTIONS)" > > # We leave this in just in case, but it is not needed anymore. > RECURSE_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) > diff --git a/Makefile.tpl b/Makefile.tpl > index f7bb77e..860175e 100644 > --- a/Makefile.tpl > +++ b/Makefile.tpl > @@ -590,7 +590,8 @@ BASE_FLAGS_TO_PASS =[+ FOR flags_to_pass +][+ IF > optional +] \ > $(CXX_FOR_TARGET_FLAG_TO_PASS) \ > "TFLAGS=$(TFLAGS)" \ > "CONFIG_SHELL=$(SHELL)" \ > - "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" > + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ > + "LSAN_OPTIONS=$(LSAN_OPTIONS)" > > # We leave this in just in case, but it is not needed anymore. > RECURSE_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) > > It fixes the issue but causes regressions for normal build (without ASAN > instrumentation): > > Running target unix/-m32 > FAIL: c-c++-common/asan/pr59063-2.c -O2 -flto -fno-use-linker-plugin > -flto-partition=none (test for excess errors) > UNRESOLVED: c-c++-common/asan/pr59063-2.c -O2 -flto -fno-use-linker-plugin > -flto-partition=none compilation failed to produce executable > FAIL: c-c++-common/asan/pr59063-2.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects (test for excess errors) > UNRESOLVED: c-c++-common/asan/pr59063-2.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects compilation failed to produce executable > > "compilation failed to produce executable" actually means link errors > (-lasan not found). That is just weird and I can't reproduce it. That said, perhaps it would be better to only propagate LSAN_OPTIONS down if it is set. So replace "LSAN_OPTIONS=$(LSAN_OPTIONS)" with "$(if $(LSAN_OPTIONS),LSAN_OPTIONS=$(LSAN_OPTIONS))" in both spots?