Skip to content

Commit 324951d

Browse files
Enable TAPI_VERIFY_MODE=Pedantic.
This ensures that the symbols we export are all declared in our headers. Some symbols we were exporting we should stop exporting, hence the MTR_HIDDEN. For the darwin-framework-tool build we were ending up exporting a bunch of C symbols from libCHIP.a; Joshua Villasenor figured out that we should -Wl,-hidden-lCHIP to avoid that. The existing -Wl,-unexported_symbol,\"__Z*\" cannot be removed, because we include Matter headers, which declare various symbols. So we need either this, or changing our default visibility, but that (1) would need MTR_EXPORT on a bunch of stuff and (2) would affect testability. The VERSION_INFO_EXPORT_DECL is to stop exporting MatterVersionNumber and MatterVersionString symbols. The new -Wl,-unexported_symbol patterns are to deal with symbols that get pulled in when building with "is_asan=true is_clang=true": unwinding and stack-dumping functions, that we should not be exporting. We hide everything starting with "___" because that's never going to be public API.
1 parent 875c577 commit 324951d

15 files changed

+55
-1
lines changed

src/darwin/Framework/CHIP/MTRBaseDevice.mm

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
#import <Matter/MTRDefines.h>
1718

1819
#import "MTRAttributeTLVValueDecoder_Internal.h"
1920
#import "MTRBaseDevice_Internal.h"
@@ -86,6 +87,7 @@
8687

8788
class MTRDataValueDictionaryCallbackBridge;
8889

90+
MTR_HIDDEN
8991
@interface MTRReadClientContainer : NSObject
9092
@property (nonatomic, readwrite) app::ReadClient * readClientPtr;
9193
@property (nonatomic, readwrite) app::AttributePathParams * pathParams;

src/darwin/Framework/CHIP/MTRCommissionableBrowser.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
*/
1717

1818
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDefines.h>
1920

2021
NS_ASSUME_NONNULL_BEGIN
2122

2223
@protocol MTRCommissionableBrowserDelegate;
2324

25+
MTR_HIDDEN
2426
@interface MTRCommissionableBrowser : NSObject
2527
- (instancetype)init NS_UNAVAILABLE;
2628
+ (instancetype)new NS_UNAVAILABLE;

src/darwin/Framework/CHIP/MTRCommissionableBrowserResult_Internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
*/
1717

1818
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDefines.h>
1920

2021
#import "MTRCommissionableBrowserResult.h"
2122

2223
#include <controller/SetUpCodePairer.h>
2324

2425
NS_ASSUME_NONNULL_BEGIN
2526

27+
MTR_HIDDEN
2628
@interface MTRCommissionableBrowserResultInterfaces : NSObject
2729

2830
@property (nonatomic, readwrite) chip::Optional<chip::Dnssd::CommonResolutionData> resolutionData;

src/darwin/Framework/CHIP/MTRControllerAccessControl.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#pragma once
1717

1818
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDefines.h>
1920

2021
NS_ASSUME_NONNULL_BEGIN
2122

23+
MTR_HIDDEN
2224
@interface MTRControllerAccessControl : NSObject
2325

2426
- (instancetype)init NS_UNAVAILABLE;

src/darwin/Framework/CHIP/MTRDefines.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#define MTR_EXPORT __attribute__((visibility("default")))
2323

24+
#define MTR_HIDDEN __attribute__((visibility("hidden")))
25+
2426
#ifdef __cplusplus
2527
#define MTR_EXTERN extern "C" MTR_EXPORT
2628
#else

src/darwin/Framework/CHIP/MTRDevice.mm

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
#import <Matter/MTRDefines.h>
1819
#import <os/lock.h>
1920

2021
#import "MTRAsyncCallbackWorkQueue_Internal.h"
@@ -44,6 +45,7 @@
4445
// Consider moving utility classes to their own file
4546
#pragma mark - Utility Classes
4647
// This class is for storing weak references in a container
48+
MTR_HIDDEN
4749
@interface MTRWeakReference<ObjectType> : NSObject
4850
+ (instancetype)weakReferenceWithObject:(ObjectType)object;
4951
- (instancetype)initWithObject:(ObjectType)object;

src/darwin/Framework/CHIP/MTRDeviceController.mm

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
#import <Matter/MTRDefines.h>
18+
1719
#import "MTRDeviceController_Internal.h"
1820

1921
#import "MTRBaseDevice_Internal.h"
@@ -1021,6 +1023,7 @@ - (void)operationalInstanceAdded:(chip::NodeId)nodeID
10211023
* Shim to allow us to treat an MTRDevicePairingDelegate as an
10221024
* MTRDeviceControllerDelegate.
10231025
*/
1026+
MTR_HIDDEN
10241027
@interface MTRDevicePairingDelegateShim : NSObject <MTRDeviceControllerDelegate>
10251028
@property (nonatomic, readonly) id<MTRDevicePairingDelegate> delegate;
10261029
- (instancetype)initWithDelegate:(id<MTRDevicePairingDelegate>)delegate;
@@ -1078,6 +1081,7 @@ - (void)onPairingDeleted:(NSError * _Nullable)error
10781081
* Shim to allow us to treat an MTRNOCChainIssuer as an
10791082
* MTROperationalCertificateIssuer.
10801083
*/
1084+
MTR_HIDDEN
10811085
@interface MTROperationalCertificateChainIssuerShim : NSObject <MTROperationalCertificateIssuer>
10821086
@property (nonatomic, readonly) id<MTRNOCChainIssuer> nocChainIssuer;
10831087
@property (nonatomic, readonly) BOOL shouldSkipAttestationCertificateValidation;

src/darwin/Framework/CHIP/MTRDeviceControllerOverXPC.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
#import <Matter/MTRDefines.h>
1819
#import <Matter/MTRDeviceController.h>
1920

2021
NS_ASSUME_NONNULL_BEGIN
@@ -23,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
2324

2425
typedef NSXPCConnection * _Nonnull (^MTRXPCConnectBlock)(void);
2526

27+
MTR_HIDDEN
2628
@interface MTRDeviceControllerOverXPC : MTRDeviceController
2729

2830
- (instancetype)init NS_UNAVAILABLE;

src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#import "MTRDeviceControllerStartupParams.h"
2020
#import <Foundation/Foundation.h>
21+
#import <Matter/MTRDefines.h>
2122

2223
#include <crypto/CHIPCryptoPAL.h>
2324
#include <lib/core/DataModelTypes.h>
@@ -42,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
4243
- (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params;
4344
@end
4445

46+
MTR_HIDDEN
4547
@interface MTRDeviceControllerStartupParamsInternal : MTRDeviceControllerStartupParams
4648

4749
// Fabric table we can use to do things like allocate operational keys.

src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.h

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#import <Matter/MTRDefines.h>
19+
1820
#import "MTRDeviceController+XPC.h"
1921

2022
NS_ASSUME_NONNULL_BEGIN
@@ -27,6 +29,7 @@ typedef void (^MTRXPCReportHandler)(id _Nullable values, NSError * _Nullable err
2729
* Releasing the handle may cause invalidating the XPC connection. Hence, in order to retain the connection, the handle must not be
2830
* released.
2931
*/
32+
MTR_HIDDEN
3033
@interface MTRDeviceControllerXPCProxyHandle : NSObject
3134

3235
@property (nonatomic, readonly, getter=proxy) id<MTRDeviceControllerServerProtocol> proxy;
@@ -40,6 +43,7 @@ typedef void (^MTRGetProxyHandleHandler)(dispatch_queue_t queue, MTRDeviceContro
4043
*
4144
* This class is in charge of making a new XPC connection and disconnecting as needed by the clients and by the report handlers.
4245
*/
46+
MTR_HIDDEN
4347
@interface MTRDeviceControllerXPCConnection<MTRDeviceControllerClientProtocol> : NSObject
4448

4549
/**

src/darwin/Framework/CHIP/MTRDeviceOverXPC.h

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#import <Matter/MTRDefines.h>
19+
1820
#import "MTRBaseDevice.h"
1921
#import "MTRCluster.h" // For MTRSubscriptionEstablishedHandler
2022
#import "MTRDeviceControllerXPCConnection.h"
@@ -23,6 +25,7 @@
2325

2426
NS_ASSUME_NONNULL_BEGIN
2527

28+
MTR_HIDDEN
2629
@interface MTRDeviceOverXPC : MTRBaseDevice
2730

2831
- (instancetype)init NS_UNAVAILABLE;

src/darwin/Framework/CHIP/MTRError.mm

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
#import <Matter/MTRDefines.h>
19+
1820
#import "MTRError.h"
1921
#import "MTRError_Internal.h"
2022

@@ -32,6 +34,7 @@
3234

3335
// Class for holding on to a CHIP_ERROR that we can use as the value
3436
// in a dictionary.
37+
MTR_HIDDEN
3538
@interface MTRErrorHolder : NSObject
3639
@property (nonatomic, readonly) CHIP_ERROR error;
3740

src/darwin/Framework/CHIP/MTRError_Internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
*/
1717

1818
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDefines.h>
1920
#import <Matter/MTRError.h>
2021

2122
#include <app/MessageDef/StatusIB.h>
2223
#include <lib/core/CHIPError.h>
2324

2425
NS_ASSUME_NONNULL_BEGIN
2526

27+
MTR_HIDDEN
2628
@interface MTRError : NSObject
2729
+ (NSError * _Nullable)errorForCHIPErrorCode:(CHIP_ERROR)errorCode;
2830
+ (NSError * _Nullable)errorForIMStatus:(const chip::app::StatusIB &)status;

src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm

+3-1
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,11 @@ CHIP_ERROR ConfigureState(chip::FabricIndex fabricIndex, chip::NodeId nodeId)
492492
uint64_t mTransferGeneration = 0;
493493
};
494494

495+
namespace {
495496
BdxOTASender gOtaSender;
496497

497-
static NSInteger const kOtaProviderEndpoint = 0;
498+
NSInteger const kOtaProviderEndpoint = 0;
499+
} // anonymous namespace
498500

499501
MTROTAProviderDelegateBridge::MTROTAProviderDelegateBridge(id<MTROTAProviderDelegate> delegate)
500502
: mDelegate(delegate)

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+20
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,10 @@
17531753
CoreBluetooth,
17541754
"-lnetwork",
17551755
"-Wl,-unexported_symbol,\"__Z*\"",
1756+
"-Wl,-unexported_symbol,\"___*\"",
1757+
"-Wl,-unexported_symbol,\"__Unwind_*\"",
1758+
"-Wl,-unexported_symbol,\"_unw_*\"",
1759+
"-Wl,-hidden-lCHIP",
17561760
);
17571761
"OTHER_LDFLAGS[sdk=macosx*]" = (
17581762
"-framework",
@@ -1767,11 +1771,17 @@
17671771
"-framework",
17681772
CoreData,
17691773
"-Wl,-unexported_symbol,\"__Z*\"",
1774+
"-Wl,-unexported_symbol,\"___*\"",
1775+
"-Wl,-unexported_symbol,\"__Unwind_*\"",
1776+
"-Wl,-unexported_symbol,\"_unw_*\"",
1777+
"-Wl,-hidden-lCHIP",
17701778
);
17711779
PRODUCT_BUNDLE_IDENTIFIER = com.csa.matter;
17721780
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
17731781
SDKROOT = iphoneos;
1782+
TAPI_VERIFY_MODE = Pedantic;
17741783
TARGETED_DEVICE_FAMILY = "1,2,3,4";
1784+
VERSION_INFO_EXPORT_DECL = "__attribute__((visibility(\"hidden\")))";
17751785
};
17761786
name = Debug;
17771787
};
@@ -1905,6 +1915,10 @@
19051915
CoreBluetooth,
19061916
"-lnetwork",
19071917
"-Wl,-unexported_symbol,\"__Z*\"",
1918+
"-Wl,-unexported_symbol,\"___*\"",
1919+
"-Wl,-unexported_symbol,\"__Unwind_*\"",
1920+
"-Wl,-unexported_symbol,\"_unw_*\"",
1921+
"-Wl,-hidden-lCHIP",
19081922
);
19091923
"OTHER_LDFLAGS[sdk=macosx*]" = (
19101924
"-framework",
@@ -1919,12 +1933,18 @@
19191933
"-framework",
19201934
CoreData,
19211935
"-Wl,-unexported_symbol,\"__Z*\"",
1936+
"-Wl,-unexported_symbol,\"___*\"",
1937+
"-Wl,-unexported_symbol,\"__Unwind_*\"",
1938+
"-Wl,-unexported_symbol,\"_unw_*\"",
1939+
"-Wl,-hidden-lCHIP",
19221940
);
19231941
PRODUCT_BUNDLE_IDENTIFIER = com.csa.matter;
19241942
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
19251943
SDKROOT = iphoneos;
19261944
STRIP_STYLE = "non-global";
1945+
TAPI_VERIFY_MODE = Pedantic;
19271946
TARGETED_DEVICE_FAMILY = "1,2,3,4";
1947+
VERSION_INFO_EXPORT_DECL = "__attribute__((visibility(\"hidden\")))";
19281948
};
19291949
name = Release;
19301950
};

0 commit comments

Comments
 (0)