Skip to content

Commit e6d0420

Browse files
committed
Sanitizers: Address and thread sanitizers config changes
Update the Address and Thread sanitizers XCspect properties to support using clang and swiftc as a linker.
1 parent 3a9a8f6 commit e6d0420

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

Sources/SWBUniversalPlatform/Specs/Clang.xcspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@
29022902
};
29032903
AdditionalLinkerArgs = {
29042904
YES = (
2905-
"-fsanitize=address",
2905+
"$(LD_ADDRESS_SANITIZER)",
29062906
);
29072907
NO = ();
29082908
};

Sources/SWBUniversalPlatform/Specs/Ld.xcspec

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,17 +582,38 @@
582582
DefaultValue = YES;
583583
},
584584

585+
// Address Sanitizer options
586+
{
587+
Name = LD_ADDRESS_SANITIZER;
588+
DefaultValue = "$(LD_OBJC_RUNTIME_ARGS_$(LINKER_DRIVER))";
589+
},
590+
{
591+
Name = LD_ADDRESS_SANITIZER_clang;
592+
DefaultValue = "--fsanitize=address";
593+
},
594+
{
595+
Name = LD_ADDRESS_SANITIZER_swiftc;
596+
DefaultValue = "-sanitize=address";
597+
},
598+
599+
585600
// Thread Sanitizer options
586601
{
587602
Name = "LD_THREAD_SANITIZER";
588603
Type = Boolean;
589604
DefaultValue = "$(ENABLE_THREAD_SANITIZER)";
605+
},
606+
{
607+
Name = "CLANG_LD_THREAD_SANITIZER";
608+
Type = Boolean;
609+
DefaultValue = "$(LD_THREAD_SANITIZER)";
590610
Architectures = (
591611
x86_64,
592612
x86_64h,
593613
arm64,
594614
arm64e,
595615
);
616+
Condition = "$(LINKER_DRIVER) == clang";
596617
CommandLineArgs = {
597618
YES = (
598619
"-fsanitize=thread",
@@ -601,6 +622,25 @@
601622
};
602623
// Not visible in the build settings editor
603624
},
625+
{
626+
Name = "SWIFTC_LD_THREAD_SANITIZER";
627+
Type = Boolean;
628+
DefaultValue = "$(LD_THREAD_SANITIZER)";
629+
Architectures = (
630+
x86_64,
631+
x86_64h,
632+
arm64,
633+
arm64e,
634+
);
635+
Condition = "$(LINKER_DRIVER) == swiftc";
636+
CommandLineArgs = {
637+
YES = (
638+
"-sanitize=thread",
639+
);
640+
NO = ();
641+
};
642+
// Not visible in the build settings editor
643+
},
604644

605645
{
606646
Name = "LD_DEBUG_VARIANT";

Sources/SWBUniversalPlatform/Specs/Swift.xcspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@
12251225
};
12261226
AdditionalLinkerArgs = {
12271227
YES = (
1228-
"-fsanitize=address",
1228+
"$(LD_ADDRESS_SANITIZER)",
12291229
);
12301230
NO = ();
12311231
};

0 commit comments

Comments
 (0)