[1.7.0] Fix Stat MemberImportVisibility regression and add test (#320)

* Fix Stat MemberImportVisibility regression and add test

* Remove Android from the MIV test
This commit is contained in:
Jonathan Flat authored and GitHub committed 2026-06-12 18:21:14 -04:00
1 parent 666fba77fc
commit 0a3460f369
3 files changed
+51 -2

No files matched your search

+6
View File
@@ -141,6 +141,12 @@ let package = Package(
exclude: testsToExclude,
cSettings: cSettings,
swiftSettings: swiftSettings),
// Builds a SystemPackage consumer with MemberImportVisibility enabled.
// Fails if a C member of a vended type is attributed to the CSystem module.
.testTarget(
name: "MemberImportVisibility",
dependencies: ["SystemPackage"],
swiftSettings: [.enableUpcomingFeature("MemberImportVisibility")]),
],
swiftLanguageModes: [.v5]
)
-2
View File
@@ -11,13 +11,11 @@
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/sysinfo.h>
#include <sys/timerfd.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <sched.h>
#include <unistd.h>
+45
View File
@@ -0,0 +1,45 @@
/*
This source file is part of the Swift System open source project
Copyright (c) 2026 Apple Inc. and the Swift System project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See https://swift.org/LICENSE.txt for license information
*/
// Compile-only canary for MemberImportVisibility regressions: this file fails
// to build if a C member of a type SystemPackage vends is attributed to the
// private CSystem module.
//
// For new type wrappers introduced to System, access their C members here:
// - Import the platform overlay (Glibc/Musl), as consumers do.
// - Access raw C members of vended types (e.g. CInterop.Stat) as a downstream
// consumer would. Don't go through the Swift (e.g. Stat) wrapper since its
// accesses happen inside System, where importing CSystem is fine.
// - Touch every direct member the public API exposes. One field is not always
// a safe proxy for the rest.
#if canImport(Glibc) || canImport(Musl)
#if canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#endif
import SystemPackage
func _mivProbe(_ s: CInterop.Stat) {
_ = s.st_dev
_ = s.st_ino
_ = s.st_mode
_ = s.st_nlink
_ = s.st_uid
_ = s.st_gid
_ = s.st_rdev
_ = s.st_size
_ = s.st_blksize
_ = s.st_blocks
_ = s.st_atim
_ = s.st_mtim
_ = s.st_ctim
}
#endif