Skip to content

Commit 0ce26ab

Browse files
committed
Support thread sanitizer options
U504-028
1 parent ce9d763 commit 0ce26ab

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ GPROPTS = -XPRJ_BUILD=$(PRJ_BUILD) -XPRJ_SOCKLIB=$(PRJ_SOCKLIB) \
168168
-XPRJ_XMLADA=$(PRJ_XMLADA) -XPRJ_LAL=$(PRJ_LAL) \
169169
-XPROCESSORS=$(PROCESSORS) -XSOCKET=$(SOCKET) \
170170
-XPRJ_TARGET=$(PRJ_TARGET) -XTARGET=$(TARGET) \
171+
-XTHREAD_SANITIZER=$(THREAD_SANITIZER)
171172

172173
GPR_STATIC = -XLIBRARY_TYPE=static -XXMLADA_BUILD=static
173174
GPR_SHARED = -XLIBRARY_TYPE=relocatable -XXMLADA_BUILD=relocatable
@@ -344,6 +345,7 @@ gen_setup:
344345
echo "DEBUG=$(DEBUG)" >> makefile.setup
345346
echo "PROCESSORS=$(PROCESSORS)" >> makefile.setup
346347
echo "TARGET=$(TARGET)" >> makefile.setup
348+
echo "THREAD_SANITIZER=$(THREAD_SANITIZER)" >> makefile.setup
347349
echo "GSOAP=false" >> makefile.setup
348350

349351
setup: gen_setup setup_dir setup_modules setup_config setup_tp $(GEXT_MODULE)

shared.gpr

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ abstract project Shared is
2727

2828
Processors := External ("PROCESSORS", "0");
2929

30+
type Boolean is ("true", "false");
31+
32+
Thread_Sanitizer : Boolean := External ("THREAD_SANITIZER", "false");
33+
3034
-------------
3135
-- SOCKLIB --
3236
-------------
@@ -117,9 +121,19 @@ abstract project Shared is
117121
Global_Options := ();
118122
-- Options used for all Ada units in both Debug and Release modes
119123

124+
Instrument_Options := ();
125+
-- Instrumentation option
126+
127+
case Thread_Sanitizer is
128+
when "false" =>
129+
null;
130+
when "true" =>
131+
Instrument_Options := ("-fsanitize=thread");
132+
end case;
133+
120134
Common_Options :=
121135
("-gnat2012", "-gnatwcfijkmruv", "-gnaty3abBcdefhiIklmnoOprstx")
122-
& Global_Options;
136+
& Global_Options & Instrument_Options;
123137
-- Common options used for the Debug and Release modes
124138

125139
Debug_Options :=
@@ -184,7 +198,7 @@ abstract project Shared is
184198
------------
185199

186200
package Linker is
187-
for Default_Switches ("Ada") use Ldflags;
201+
for Default_Switches ("Ada") use Ldflags & Instrument_Options;
188202
end Linker;
189203

190204
-- LDFLAGS should come first so that command line settings

src/src.gpr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ library project Src is
8787
end case;
8888
end case;
8989

90+
for Library_Options use
91+
Project'Library_Options & Shared.Instrument_Options;
92+
9093
case Shared.LDAP is
9194
when "Installed" =>
9295
for Source_Dirs use Project'Source_Dirs & ("ldap");

0 commit comments

Comments
 (0)