From bf598775315d75218acedf0f9ebafa2e1dc2483d Mon Sep 17 00:00:00 2001 From: Dmitriy Anisimkov Date: Thu, 24 Jun 2021 20:15:40 +0600 Subject: [PATCH] Support thread sanitizer options U504-028 --- Makefile | 2 ++ shared.gpr | 18 ++++++++++++++++-- src/src.gpr | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 03bd41c64e..e75e8b425f 100644 --- a/Makefile +++ b/Makefile @@ -168,6 +168,7 @@ GPROPTS = -XPRJ_BUILD=$(PRJ_BUILD) -XPRJ_SOCKLIB=$(PRJ_SOCKLIB) \ -XPRJ_XMLADA=$(PRJ_XMLADA) -XPRJ_LAL=$(PRJ_LAL) \ -XPROCESSORS=$(PROCESSORS) -XSOCKET=$(SOCKET) \ -XPRJ_TARGET=$(PRJ_TARGET) -XTARGET=$(TARGET) \ + -XTHREAD_SANITIZER=$(THREAD_SANITIZER) GPR_STATIC = -XLIBRARY_TYPE=static -XXMLADA_BUILD=static GPR_SHARED = -XLIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable @@ -344,6 +345,7 @@ gen_setup: echo "DEBUG=$(DEBUG)" >> makefile.setup echo "PROCESSORS=$(PROCESSORS)" >> makefile.setup echo "TARGET=$(TARGET)" >> makefile.setup + echo "THREAD_SANITIZER=$(THREAD_SANITIZER)" >> makefile.setup echo "GSOAP=false" >> makefile.setup setup: gen_setup setup_dir setup_modules setup_config setup_tp $(GEXT_MODULE) diff --git a/shared.gpr b/shared.gpr index 6b658bcd37..7a67f5ab32 100644 --- a/shared.gpr +++ b/shared.gpr @@ -27,6 +27,10 @@ abstract project Shared is Processors := External ("PROCESSORS", "0"); + type Boolean is ("true", "false"); + + Thread_Sanitizer : Boolean := External ("THREAD_SANITIZER", "false"); + ------------- -- SOCKLIB -- ------------- @@ -117,9 +121,19 @@ abstract project Shared is Global_Options := (); -- Options used for all Ada units in both Debug and Release modes + Instrument_Options := (); + -- Instrumentation option + + case Thread_Sanitizer is + when "false" => + null; + when "true" => + Instrument_Options := ("-fsanitize=thread"); + end case; + Common_Options := ("-gnat2012", "-gnatwcfijkmruv", "-gnaty3abBcdefhiIklmnoOprstx") - & Global_Options; + & Global_Options & Instrument_Options; -- Common options used for the Debug and Release modes Debug_Options := @@ -184,7 +198,7 @@ abstract project Shared is ------------ package Linker is - for Default_Switches ("Ada") use Ldflags; + for Default_Switches ("Ada") use Ldflags & Instrument_Options; end Linker; -- LDFLAGS should come first so that command line settings diff --git a/src/src.gpr b/src/src.gpr index 3c8f4850a0..befbc17925 100644 --- a/src/src.gpr +++ b/src/src.gpr @@ -87,6 +87,9 @@ library project Src is end case; end case; + for Library_Options use + Project'Library_Options & Shared.Instrument_Options; + case Shared.LDAP is when "Installed" => for Source_Dirs use Project'Source_Dirs & ("ldap");