Skip to content

Support thread sanitizer options #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 16 additions & 2 deletions shared.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
-------------
Expand Down Expand Up @@ -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 :=
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/src.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down