Skip to content

Commit ff9c29c

Browse files
Merge pull request #684 from swiftlang/automerge/merge-main-2025-07-29_21-41
Merge `release/6.2` into `main`
2 parents 47030cc + b233171 commit ff9c29c

File tree

9 files changed

+918
-18
lines changed

9 files changed

+918
-18
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
name: Test
1414
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1515
with:
16-
linux_os_versions: '["noble", "jammy", "focal", "rhel-ubi9"]'
16+
linux_os_versions: '["noble", "jammy", "rhel-ubi9"]'
1717
linux_pre_build_command: |
18-
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
18+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy
1919
apt-get update -y
2020
2121
# Build dependencies

Sources/SWBCore/Specs/CoreBuildSystem.xcspec

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,6 +3545,33 @@ For more information on mergeable libraries, see [Configuring your project to us
35453545
Category = BuildOptions;
35463546
Description = "Enables building with code coverage instrumentation. This is only used when the build has code coverage enabled, which is typically done via the Xcode scheme or test plan settings.";
35473547
},
3548+
{ Name = ENABLE_ENHANCED_SECURITY;
3549+
Type = Boolean;
3550+
DefaultValue = NO;
3551+
Category = SecurityPolicy;
3552+
},
3553+
{ Name = ENABLE_POINTER_AUTHENTICATION;
3554+
Type = Boolean;
3555+
DefaultValue = "$(ENABLE_ENHANCED_SECURITY)";
3556+
Category = SecurityPolicy;
3557+
},
3558+
{ Name = ENABLE_SECURITY_COMPILER_WARNINGS;
3559+
Type = Boolean;
3560+
DefaultValue = "$(ENABLE_ENHANCED_SECURITY)";
3561+
Category = SecurityPolicy;
3562+
},
3563+
{
3564+
Name = "ENABLE_C_BOUNDS_SAFETY";
3565+
Type = Boolean;
3566+
DefaultValue = NO;
3567+
Category = Security;
3568+
},
3569+
{
3570+
Name = "ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS";
3571+
Type = Boolean;
3572+
DefaultValue = NO;
3573+
Category = Security;
3574+
},
35483575
{ Name = ENABLE_TESTABILITY;
35493576
Type = Boolean;
35503577
DefaultValue = NO;

Sources/SWBCore/Specs/en.lproj/CoreBuildSystem.strings

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,35 @@ Typically this path is not set per target, but is provided as an option on the c
672672
"[MODULE_STOP]-name" = "Module Stop Routine";
673673
"[MODULE_STOP]-description" = "This defines the name of the kernel module stop routine. This is only used when building kernel extensions.";
674674

675+
// Security Settings
676+
677+
"[SecurityPolicy]-category" = "Security";
678+
679+
"[ENABLE_ENHANCED_SECURITY]-name" = "Enable Enhanced Security";
680+
"[ENABLE_ENHANCED_SECURITY]-description" = "Enables a set of security build settings, including pointer authentication, typed allocator support, hardened C++ standard library, and security-related compiler warnings. These settings can be disabled individually.";
681+
"[ENABLE_ENHANCED_SECURITY]-value-[YES]" = "Yes";
682+
"[ENABLE_ENHANCED_SECURITY]-value-[NO]" = "No";
683+
684+
"[ENABLE_POINTER_AUTHENTICATION]-name" = "Enable Pointer Authentication";
685+
"[ENABLE_POINTER_AUTHENTICATION]-description" = "Builds the target with pointer authentication enabled. Adds an additional architectural slice (arm64e) with pointer authentication instructions.";
686+
"[ENABLE_POINTER_AUTHENTICATION]-value-[YES]" = "Yes";
687+
"[ENABLE_POINTER_AUTHENTICATION]-value-[NO]" = "No";
688+
689+
"[ENABLE_SECURITY_COMPILER_WARNINGS]-name" = "Enable Security-Relevant Compiler Warnings";
690+
"[ENABLE_SECURITY_COMPILER_WARNINGS]-description" = "Enables a set of security-relevant compiler warnings that check for common bounds-safety and lifetime-safety issues.";
691+
"[ENABLE_SECURITY_COMPILER_WARNINGS]-value-[YES]" = "Yes";
692+
"[ENABLE_SECURITY_COMPILER_WARNINGS]-value-[NO]" = "No";
693+
694+
"[ENABLE_C_BOUNDS_SAFETY]-name" = "Enable Language Extension for Bounds Safety in C";
695+
"[ENABLE_C_BOUNDS_SAFETY]-description" = "Enables the -fbounds-safety language extension, which guarantees bounds safety for C";
696+
"[ENABLE_C_BOUNDS_SAFETY]-value-[NO]" = "No";
697+
"[ENABLE_C_BOUNDS_SAFETY]-value-[YES]" = "Yes";
698+
699+
"[ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS]-name" = "Enforce Bounds-Safe Buffer Usage in C++";
700+
"[ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS]-description" = "Enables a strict programming model that guarantees bounds safety in C++ by rejecting raw pointer arithmetic (enabling the -Wunsafe-buffer-usage warning as an error) and requiring the use of hardened C++ Standard Library APIs for buffer manipulation.";
701+
"[ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS]-value-[NO]" = "No";
702+
"[ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS]-value-[YES]" = "Yes";
703+
675704
// Compiler Version
676705

677706
"[GCC_VERSION]-name" = "Compiler for C/C++/Objective-C";

Sources/SWBUniversalPlatform/Specs/Clang.xcspec

Lines changed: 154 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@
536536
FileTypes = (
537537
"sourcecode.c.c",
538538
);
539-
DefaultValue = NO;
539+
DefaultValue = "$(ENABLE_C_BOUNDS_SAFETY)";
540540
CommandLineArgs = {
541541
YES = ( "-fbounds-safety" );
542542
NO = ();
@@ -640,14 +640,74 @@
640640
Category = LanguageCXX;
641641
},
642642
{
643-
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_0;
643+
Name = __ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES_YES;
644+
Type = String;
645+
DefaultValue = "YES";
646+
},
647+
{
648+
Name = __ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES_NO;
649+
Type = String;
650+
DefaultValue = "YES";
651+
},
652+
{
653+
Name = __ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_NO_YES;
654+
Type = String;
655+
DefaultValue = "YES";
656+
},
657+
{
658+
Name = __ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_NO_NO;
659+
Type = String;
660+
DefaultValue = "NO";
661+
},
662+
{
663+
Name = __ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS;
664+
Type = String;
665+
DefaultValue = "$(__ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_$(ENABLE_ENHANCED_SECURITY)_$(ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS))";
666+
},
667+
{
668+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_0_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
669+
Type = String;
670+
DefaultValue = "debug";
671+
},
672+
{
673+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_0_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_NO;
644674
Type = String;
645675
DefaultValue = "debug";
646676
},
677+
{
678+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_1_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
679+
Type = String;
680+
DefaultValue = "fast";
681+
},
682+
{
683+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_2_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
684+
Type = String;
685+
DefaultValue = "fast";
686+
},
687+
{
688+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_3_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
689+
Type = String;
690+
DefaultValue = "fast";
691+
},
692+
{
693+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_s_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
694+
Type = String;
695+
DefaultValue = "fast";
696+
},
697+
{
698+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_fast_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
699+
Type = String;
700+
DefaultValue = "fast";
701+
},
702+
{
703+
Name = __LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_z_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_YES;
704+
Type = String;
705+
DefaultValue = "fast";
706+
},
647707
{
648708
Name = __LIBRARY_HARDENING_DEFAULT_VALUE;
649709
Type = String;
650-
DefaultValue = "$(__LIBRARY_HARDENING_DEFAULT_VALUE_$(GCC_OPTIMIZATION_LEVEL))";
710+
DefaultValue = "$(__LIBRARY_HARDENING_DEFAULT_VALUE_OPT_LEVEL_$(GCC_OPTIMIZATION_LEVEL)_ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS_$(__ENHANCED_SECURITY_OR_BOUNDS_SAFE_BUFFERS))";
651711
},
652712
{
653713
Name = "CLANG_CXX_STANDARD_LIBRARY_HARDENING";
@@ -736,11 +796,26 @@
736796
);
737797
Category = LanguageCXX;
738798
},
799+
{
800+
Name = "_UNSAFE_BUFFER_USAGE_DEFAULT_ENABLE_SAFE_BUFFERS_NO";
801+
Type = String;
802+
DefaultValue = "DEFAULT";
803+
},
804+
{
805+
Name = "_UNSAFE_BUFFER_USAGE_DEFAULT_ENABLE_SAFE_BUFFERS_YES";
806+
Type = String;
807+
DefaultValue = "YES_ERROR";
808+
},
809+
{
810+
Name = "_UNSAFE_BUFFER_USAGE_DEFAULT";
811+
Type = String;
812+
DefaultValue = "$(_UNSAFE_BUFFER_USAGE_DEFAULT_ENABLE_SAFE_BUFFERS_$(ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS))";
813+
},
739814
{
740815
Name = "CLANG_WARN_UNSAFE_BUFFER_USAGE";
741816
Type = Enumeration;
742817
Values = ( DEFAULT, YES, YES_ERROR, NO );
743-
DefaultValue = DEFAULT;
818+
DefaultValue = "$(_UNSAFE_BUFFER_USAGE_DEFAULT)";
744819
CommandLineArgs = {
745820
DEFAULT = ();
746821
NO = ( "-Wno-unsafe-buffer-usage" );
@@ -801,7 +876,7 @@
801876
{
802877
Name = "GCC_OPTIMIZATION_LEVEL";
803878
Type = Enumeration;
804-
// NOTE: Updating these values requires updating LLVM_OPTIMIZATION_LEVEL_VAL_X.
879+
// NOTE: Updating these values requires updating LLVM_OPTIMIZATION_LEVEL_VAL_X and CLANG_CXX_STANDARD_LIBRARY_HARDENING.
805880
Values = (
806881
0,
807882
1,
@@ -945,6 +1020,22 @@
9451020
};
9461021
Category = WarningsPolicy;
9471022
},
1023+
{ Name = CLANG_ENABLE_SECURITY_COMPILER_WARNINGS;
1024+
Type = Boolean;
1025+
DefaultValue = "$(ENABLE_SECURITY_COMPILER_WARNINGS)";
1026+
CommandLineArgs = {
1027+
YES = ("-Wbuiltin-memcpy-chk-size",
1028+
"-Wformat-nonliteral",
1029+
"-Warray-bounds",
1030+
"-Warray-bounds-pointer-arithmetic",
1031+
"-Wsuspicious-memaccess",
1032+
"-Wsizeof-array-div",
1033+
"-Wsizeof-pointer-div",
1034+
"-Wreturn-stack-address");
1035+
NO = ();
1036+
};
1037+
// Hidden.
1038+
},
9481039
{
9491040
Name = "GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS";
9501041
Type = Boolean;
@@ -1381,7 +1472,7 @@
13811472
{
13821473
Name = "CLANG_WARN_EMPTY_BODY";
13831474
Type = Boolean;
1384-
DefaultValue = NO;
1475+
DefaultValue = "$(CLANG_ENABLE_SECURITY_COMPILER_WARNINGS)";
13851476
CommandLineArgs = {
13861477
YES = ( "-Wempty-body" );
13871478
NO = ( "-Wno-empty-body" );
@@ -1447,7 +1538,7 @@
14471538
{
14481539
Name = "GCC_WARN_SHADOW";
14491540
Type = Boolean;
1450-
DefaultValue = NO;
1541+
DefaultValue = "$(CLANG_ENABLE_SECURITY_COMPILER_WARNINGS)";
14511542
CommandLineArgs = {
14521543
YES = (
14531544
"-Wshadow",
@@ -1800,6 +1891,27 @@
18001891
};
18011892
Category = Warnings;
18021893
},
1894+
{
1895+
Name = "CLANG_ENABLE_STACK_ZERO_INIT";
1896+
Type = Boolean;
1897+
DefaultValue = "$(ENABLE_ENHANCED_SECURITY)";
1898+
Category = Security;
1899+
},
1900+
{
1901+
Name = "_CLANG_TRIVIAL_AUTO_VAR_INIT_DEFAULT_ENABLE_ZERO_INIT_YES";
1902+
Type = Boolean;
1903+
DefaultValue = "zero";
1904+
},
1905+
{
1906+
Name = "_CLANG_TRIVIAL_AUTO_VAR_INIT_DEFAULT_ENABLE_ZERO_INIT_NO";
1907+
Type = Boolean;
1908+
DefaultValue = "default";
1909+
},
1910+
{
1911+
Name = "_CLANG_TRIVIAL_AUTO_VAR_INIT_DEFAULT";
1912+
Type = String;
1913+
DefaultValue = "$(_CLANG_TRIVIAL_AUTO_VAR_INIT_DEFAULT_ENABLE_ZERO_INIT_$(CLANG_ENABLE_STACK_ZERO_INIT))";
1914+
},
18031915
{
18041916
Name = "CLANG_TRIVIAL_AUTO_VAR_INIT";
18051917
Type = Enumeration;
@@ -1809,7 +1921,7 @@
18091921
zero,
18101922
pattern,
18111923
);
1812-
DefaultValue = default;
1924+
DefaultValue = "$(_CLANG_TRIVIAL_AUTO_VAR_INIT_DEFAULT)";
18131925
CommandLineArgs = {
18141926
default = ( );
18151927
uninitialized = ( "-ftrivial-auto-var-init=uninitialized" );
@@ -2900,19 +3012,50 @@
29003012
Condition = "$(CLANG_UNDEFINED_BEHAVIOR_SANITIZER_TRAP_ON_SECURITY_ISSUES) && $(GCC_OPTIMIZATION_LEVEL) != 0";
29013013
},
29023014
{
2903-
Name = "CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT";
3015+
Name = "_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT_ENHANCED_SECURITY_YES";
3016+
Type = Enumeration;
3017+
Values = (
3018+
compiler-default,
3019+
YES,
3020+
NO,
3021+
);
3022+
DefaultValue = YES;
3023+
},
3024+
{
3025+
Name = "_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT_ENHANCED_SECURITY_NO";
29043026
Type = Enumeration;
29053027
Values = (
29063028
compiler-default,
29073029
YES,
29083030
NO,
29093031
);
29103032
DefaultValue = compiler-default;
3033+
},
3034+
{
3035+
Name = "_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT";
3036+
Type = Enumeration;
3037+
Values = (
3038+
compiler-default,
3039+
YES,
3040+
NO,
3041+
);
3042+
DefaultValue = "$(_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT_ENHANCED_SECURITY_$(ENABLE_ENHANCED_SECURITY))";
3043+
},
3044+
{
3045+
Name = "CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT";
3046+
Type = Enumeration;
3047+
Values = (
3048+
compiler-default,
3049+
YES,
3050+
NO,
3051+
);
3052+
DefaultValue = "$(_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT)";
29113053
CommandLineArgs = {
29123054
compiler-default = ();
29133055
YES = ("-ftyped-memory-operations");
29143056
NO = ("-fno-typed-memory-operations");
29153057
};
3058+
Category = Language;
29163059
},
29173060
{
29183061
Name = "CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT";
@@ -2922,7 +3065,7 @@
29223065
YES,
29233066
NO,
29243067
);
2925-
DefaultValue = compiler-default;
3068+
DefaultValue = "$(_CLANG_ENABLE_TYPED_ALLOCATOR_SUPPORT_DEFAULT)";
29263069
CommandLineArgs = {
29273070
compiler-default = ();
29283071
YES = ("-ftyped-cxx-new-delete", "-ftyped-cxx-delete");
@@ -2933,6 +3076,7 @@
29333076
YES = ("-ftyped-cxx-new-delete", "-ftyped-cxx-delete");
29343077
NO = ();
29353078
};
3079+
Category = LanguageCXX;
29363080
},
29373081
{
29383082
Name = "CLANG_OMIT_FRAME_POINTERS";

Sources/SWBUniversalPlatform/Specs/Ld.xcspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@
739739
);
740740
};
741741
},
742-
743742
{
744743
Name = "__CREATE_INFOPLIST_SECTION_IN_BINARY";
745744
Type = Boolean;

Sources/SWBUniversalPlatform/Specs/en.lproj/Apple Clang.strings

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,23 @@ The restrictions on `offsetof` may be relaxed in a future version of the C++ sta
695695
"[CLANG_ENABLE_MODULES]-value-[YES]" = "Yes";
696696
"[CLANG_ENABLE_MODULES]-value-[NO]" = "No";
697697

698+
"[CLANG_ENABLE_STACK_ZERO_INIT]-name" = "Enable Stack Zero Initialization";
699+
"[CLANG_ENABLE_STACK_ZERO_INIT]-description" = "Automatically initializes stack variables to zero as a security protection.";
700+
"[CLANG_ENABLE_STACK_ZERO_INIT]-value-[YES]" = "Yes";
701+
"[CLANG_ENABLE_STACK_ZERO_INIT]-value-[NO]" = "No";
702+
703+
"[CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT]-name" = "Enable Typed Allocator in C";
704+
"[CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT]-description" = "Enables compiler rewriting of allocation calls in C to provide type information to the allocator. Mitigates use-after-free security vulnerabilities.";
705+
"[CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT]-value-[YES]" = "Yes";
706+
"[CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT]-value-[NO]" = "No";
707+
"[CLANG_ENABLE_C_TYPED_ALLOCATOR_SUPPORT]-value-[compiler-default]" = "Compiler Default";
708+
709+
"[CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT]-name" = "Enable Typed Allocator in C++";
710+
"[CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT]-description" = "Enables compiler rewriting of allocation calls in C++ to provide type information to the allocator. Mitigates use-after-free security vulnerabilities.";
711+
"[CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT]-value-[YES]" = "Yes";
712+
"[CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT]-value-[NO]" = "No";
713+
"[CLANG_ENABLE_CPLUSPLUS_TYPED_ALLOCATOR_SUPPORT]-value-[compiler-default]" = "Compiler Default";
714+
698715
"[CLANG_MODULES_AUTOLINK]-name" = "Link Frameworks Automatically";
699716
"[CLANG_MODULES_AUTOLINK]-description" = "Automatically link SDK frameworks that are referenced using `#import` or `#include`. This feature requires also enabling support for modules. This build setting only applies to C-family languages.";
700717
"[CLANG_MODULES_AUTOLINK]-value-[YES]" = "Yes (when modules are enabled)";

Sources/SWBUtil/Signatures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public struct CodeSignatureInfo: Codable, Sendable {
191191

192192
let result2 = SecCodeCopySigningInformation(code!, [SecCSFlags(rawValue: kSecCSSigningInformation)], &info)
193193
if result2 != 0 {
194-
throw MacError(result)
194+
throw MacError(result2)
195195
}
196196

197197
if !skipValidation {

0 commit comments

Comments
 (0)