Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated code in macOS Monterey #1164

Closed
1 task done
lavrd opened this issue Oct 27, 2021 · 14 comments · Fixed by #1191
Closed
1 task done

Deprecated code in macOS Monterey #1164

lavrd opened this issue Oct 27, 2021 · 14 comments · Fixed by #1191

Comments

@lavrd
Copy link

lavrd commented Oct 27, 2021

Describe the bug
There is a deprecation messages while building code with gopsutil v3.

# github.com/shirou/gopsutil/disk
iostat_darwin.c:28: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
# github.com/shirou/gopsutil/host
smc_darwin.c:75:41: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here

To Reproduce

package main

import (
	_ "github.com/shirou/gopsutil/cpu"
	_ "github.com/shirou/gopsutil/disk"
	_ "github.com/shirou/gopsutil/host"
	_ "github.com/shirou/gopsutil/mem"
)

func main() {}

Expected behavior
There isn't any messages about deprecation.

Environment (please complete the following information):

  • Mac OS: [paste the result of sw_vers and uname -a
ProductName:	macOS
ProductVersion:	12.0.1
BuildVersion:	21A559
Darwin MacBook-Pro.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
@zihjiang

This comment has been minimized.

@zls3434

This comment has been minimized.

@lfjdhr123

This comment has been minimized.

@vikiea

This comment has been minimized.

@Kennnnnnji
Copy link

Kennnnnnji commented Nov 26, 2021

This may relate to CGO. I found a temporary solution, use this before building projects:

go env -w CGO_ENABLED="0"

@janflyborg
Copy link

This may relate to CGO. I found a temporary solution, use this before building projects:

go env -w CGO_ENABLED="0"

Sure, but some people need cgo, so this workaround does not work for everyone.

@Lomanic
Copy link
Collaborator

Lomanic commented Nov 27, 2021

I don't have any darwin device or VM. Can any of you try go build github.com/shirou/gopsutil/disk and go build github.com/shirou/gopsutil/host after applying (curl -L https://github.com/shirou/gopsutil/files/7612001/diff.txt | git apply) the following diff on both macos 12 and a lower macos version?

diff.txt

@lavrd
Copy link
Author

lavrd commented Nov 27, 2021

@Lomanic I have applied your diff in master branch, then I have tried to execute go build github.com/shirou/gopsutil/disk and go build github.com/shirou/gopsutil/host in v3 folder and I had warnings about deprecation code.

@Mxxim
Copy link

Mxxim commented Nov 30, 2021

Hi, I have got the same warning in macOS 12.0.1, do you known how to fix it?

# github.com/shirou/gopsutil/cpu
../../../../pkg/mod/github.com/shirou/gopsutil@v2.20.7+incompatible/cpu/cpu_darwin_cgo.go:13:5: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
# github.com/shirou/gopsutil/disk
iostat_darwin.c:28:2: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:132:1: note: 'IOMasterPort' has been explicitly marked deprecated here

@dt
Copy link

dt commented Dec 3, 2021

@Lomanic Should that MAC_OS_X_VERSION_MAX_ALLOWED be MAC_OS_X_VERSION_MIN_REQUIRED instead, to avoid the missing symbol on older deployment targets?

@liuhaoran666
Copy link

+1 how to resolve it?

@lavrd
Copy link
Author

lavrd commented Feb 14, 2022

+1 how to resolve it?

You can update package to the latest v3 version

@bsergean
Copy link

bsergean commented Apr 6, 2022

# github.com/shirou/gopsutil/v3/disk
iostat_darwin.c:28:2: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]

@lavrxxx I'm getting this warning with the v3 version as well.

@ashutosh-tikaj
Copy link

This may relate to CGO. I found a temporary solution, use this before building projects:

go env -w CGO_ENABLED="0"

You saved my day, I had already spent 2 hours finding the issue :(

jacknif3 pushed a commit to jacknif3/pantegana that referenced this issue Jan 15, 2024
When client is ran on Windows, fingerprinting info is properly shown on session list.
Due to a warning message shown when compiling client exe, we need to have 'CGO_ENABLED=0' env var on compile time.
Relevant GH issue: shirou/gopsutil#1164
jacknif3 pushed a commit to jacknif3/pantegana that referenced this issue Jan 19, 2024
When client is ran on Windows, fingerprinting info is properly shown on session list.
Due to a warning message shown when compiling client exe, we need to have 'CGO_ENABLED=0' env var on compile time.
Relevant GH issue: shirou/gopsutil#1164
jacknif3 pushed a commit to jacknif3/pantegana that referenced this issue Jan 19, 2024
When client is ran on Windows, fingerprinting info is properly shown on session list.
Due to a warning message shown when compiling client exe, we need to have 'CGO_ENABLED=0' env var on compile time.
Relevant GH issue: shirou/gopsutil#1164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.