Conversation
Addresses various build failures when compiling with the latest Xcode. ``` % clang --version Apple clang version 21.0.0 (clang-2100.0.123.102) Target: arm64-apple-darwin25.4.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ```
|
Tagging subscribers to this area: @agocke |
There was a problem hiding this comment.
Pull request overview
Addresses build failures / new diagnostics when compiling dotnet/runtime native components with newer Clang/Xcode toolchains (e.g., Apple clang 21), primarily by tightening up pointer/CF type conversions and suppressing a new ICU-header warning.
Changes:
- Add explicit casts to satisfy newer Clang diagnostics around implicit
void*conversions and CoreFoundation type APIs. - Minor Objective-C formatting cleanups in Network.framework PAL.
- Suppress
-Wc++-keywordwarnings when buildingSystem.Globalization.Native(ICU headers).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509chain.c | Add explicit malloc cast to avoid new implicit void* conversion diagnostics. |
| src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c | Add casts for CF APIs (bytes pointer + CFArray element type). |
| src/native/libs/System.Security.Cryptography.Native.Apple/pal_networkframework.m | Formatting cleanups and cast to tls_ciphersuite_t for Clang strictness. |
| src/native/libs/System.Security.Cryptography.Native.Apple/pal_ecc.c | Cast CFDictionaryGetValue result to CFNumberRef for stricter compilation. |
| src/native/libs/System.Native/pal_networking.c | Add casts on calloc return to satisfy stricter pointer conversion rules (Darwin unlimited select path). |
| src/native/libs/System.Native/pal_environment.m | Add explicit malloc cast to avoid new implicit void* conversion diagnostics. |
| src/native/libs/System.Globalization.Native/CMakeLists.txt | Suppress Clang warning -Wc++-keyword likely triggered by ICU headers. |
src/native/libs/System.Security.Cryptography.Native.Apple/pal_networkframework.m
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c
Outdated
Show resolved
Hide resolved
|
FYI @am11 |
…meter type in SSLSetALPNProtocol
src/native/libs/System.Security.Cryptography.Native.Apple/pal_networkframework.m
Show resolved
Hide resolved
…acceptableIssuers in AppleCryptoNative_NwConnectionCreate
|
This gets us through the native build with Apple clang 21. There are two (non-fatal) warnings: When building src/tests native components: [372/376] Generating SwiftErrorHandling library
/Users/adeel/projects/runtime2/src/tests/Interop/Swift/SwiftErrorHandling/SwiftErrorHandling.swift:7:10: warning: associated value 'runtimeError(message:)' of 'Sendable'-conforming enum 'MyError' contains non-Sendable type 'NSString'
5 |
6 | public enum MyError: Error {
7 | case runtimeError(message: NSString)
| `- warning: associated value 'runtimeError(message:)' of 'Sendable'-conforming enum 'MyError' contains non-Sendable type 'NSString'
8 | }
9 |
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:103:12: note: class 'NSString' does not conform to the 'Sendable' protocol
101 |
102 |
103 | @interface NSString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
| `- note: class 'NSString' does not conform to the 'Sendable' protocol
104 |
105 | #pragma mark *** String funnel methods ***
[375/376] Install the project...
-- Install configuration: "DEBUG"When building libs.native: [141/288] Building C object System.Native/CMakeFiles/System.Native.dir/pal_memory.c.o
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:22:7: warning: function SystemNative_AlignedAlloc might be an allocator wrapper [-Wallocator-wrappers]
22 | void* SystemNative_AlignedAlloc(uintptr_t alignment, uintptr_t size)
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:26:5: note: value obtained from allocator call is returned here
26 | return aligned_alloc(alignment, size);
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:70:7: warning: function SystemNative_Calloc might be an allocator wrapper [-Wallocator-wrappers]
70 | void* SystemNative_Calloc(uintptr_t num, uintptr_t size)
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:72:5: note: value obtained from allocator call is returned here
72 | return calloc(num, size);
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:80:7: warning: function SystemNative_Malloc might be an allocator wrapper [-Wallocator-wrappers]
80 | void* SystemNative_Malloc(uintptr_t size)
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:82:5: note: value obtained from allocator call is returned here
82 | return malloc(size);
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:85:7: warning: function SystemNative_Realloc might be an allocator wrapper [-Wallocator-wrappers]
85 | void* SystemNative_Realloc(void* ptr, uintptr_t new_size)
| ^
/Users/adeel/projects/runtime2/src/native/libs/System.Native/pal_memory.c:87:5: note: value obtained from allocator call is returned here
87 | return realloc(ptr, new_size);
| ^
4 warnings generated.We can figure out best way to fix them in a follow-up. |
Forgot about the |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/tests/Interop/Swift/SwiftErrorHandling/SwiftErrorHandling.swift:35
getMyErrorMessagereturnsnilwhen the error is notMyError, but it never setsmessageLengthin that path. The C# P/Invoke uses anout int length, so this can surface as an uninitialized length value if the cast fails. SetmessageLength = 0before returningnil(or initialize it at function entry).
public func getMyErrorMessage(from error: Error, messageLength: inout Int32) -> UnsafePointer<unichar>? {
if let myError = error as? MyError {
switch myError {
case .runtimeError(let message):
let nsMessage = message as NSString
let buffer = UnsafeMutableBufferPointer<unichar>.allocate(capacity: nsMessage.length)
nsMessage.getCharacters(buffer.baseAddress!, range: NSRange(location: 0, length: nsMessage.length))
messageLength = Int32(nsMessage.length)
return UnsafePointer(buffer.baseAddress!)
}
}
return nil
…geLength in SwiftErrorHandling
Addresses various build failures when compiling with the latest Xcode.
See #119706 (comment)
Clang 21 changes for
-Wc++-keyword- https://releases.llvm.org/21.1.0/tools/clang/docs/ReleaseNotes.html#id11Partially related unicode-org/icu#2913