Skip to content

Fix macOS 12 deprecation notice#5

Merged
lufia merged 1 commit intolufia:mainfrom
dt:macos12-deprecation
Dec 4, 2021
Merged

Fix macOS 12 deprecation notice#5
lufia merged 1 commit intolufia:mainfrom
dt:macos12-deprecation

Conversation

@dt
Copy link
Contributor

@dt dt commented Dec 2, 2021

Previously compiling on Monterey would print a warning like this:

iostat_darwin.c:27:2: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:132:1: note: 'IOMasterPort' has been explicitly marked deprecated here

This updates that usage to remove the warning.

@lufia
Copy link
Owner

lufia commented Dec 3, 2021

Hi @dt
Thank you for your patch.

In macOS 11 runner, go test shows below error:

iostat_darwin.c:27:2: warning: 'IOMainPort' is only available on macOS 12.0 or newer [-Wunguarded-availability-new]
/Applications/Xcode_13.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:114:1: note: 'IOMainPort' has been marked as being introduced in macOS 12.0 here, but the deployment target is macOS 11.0.0
iostat_darwin.c:27:2: note: enclose 'IOMainPort' in a __builtin_available check to silence this warning
dyld: lazy symbol binding failed: Symbol not found: _IOMainPort
  Referenced from: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/go-build829090575/b001/iostat.test
  Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

dyld: Symbol not found: _IOMainPort
  Referenced from: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/go-build829090575/b001/iostat.test
  Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

Would IOMainPort need to check if deployment target is macOS 12.0 or higher?

@dt
Copy link
Contributor Author

dt commented Dec 3, 2021

Huh, whoops, looks like that conditional define isn't doing what I thought it would. I'll dig a bit. Thanks!

Previously compiling on Monterey would print a warning like this:

```
iostat_darwin.c:27:2: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:132:1: note: 'IOMasterPort' has been explicitly marked deprecated here
```

This updates that usage to remove the warning.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1535477136

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.906%

Totals Coverage Status
Change from base Build 1448197860: 0.0%
Covered Lines: 45
Relevant Lines: 53

💛 - Coveralls

@lufia
Copy link
Owner

lufia commented Dec 4, 2021

I checked above error is fixed. Thanks! @dt

@lufia lufia merged commit 7c07874 into lufia:main Dec 4, 2021
@lufia
Copy link
Owner

lufia commented Dec 4, 2021

I've published v1.2.1
https://github.com/lufia/iostat/releases/tag/v1.2.1

@dt dt deleted the macos12-deprecation branch December 4, 2021 14:08
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jan 4, 2022
74397: vendor: bump gopsutil and iostat to fix macOS 12 warnings r=dt a=dt

Picks up upstream fixes for macOS 12 compiler warnings about deprecation of IOMasterPort:
- lufia/iostat#5
- shirou/gopsutil#1191

Co-authored-by: David Taylor <tinystatemachine@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants