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

[macOS Apple Silicon] Installation fails due to compiler errors #1945

Closed
zachriggle opened this issue May 6, 2021 · 4 comments · Fixed by #2010
Closed

[macOS Apple Silicon] Installation fails due to compiler errors #1945

zachriggle opened this issue May 6, 2021 · 4 comments · Fixed by #2010

Comments

@zachriggle
Copy link

Summary

  • OS: macOS
  • Architecture: Apple M1
  • Psutil version: Not applicable
  • Python version: Python 3.8.2
  • Type: wheels

Description

When attempting to install psutil on an Apple Silicon Mac mini running Big Sur, I encounter the following compiler error when building psutil/_psutil_posix.c

    psutil/_psutil_posix.c:514:21: error: duplicate case value '16'
                    case(IFM_1000_T):
                        ^
    psutil/_psutil_posix.c:508:21: note: previous case defined here
                    case(IFM_1000_TX):
                        ^
    1 error generated.
    error: command 'xcrun' failed with exit status 1
@giampaolo
Copy link
Owner

Mmm I don't understand. I can't see anything wrong with the code:

case(IFM_1000_TX):
#endif
#ifdef IFM_1000_FX
case(IFM_1000_FX):
#endif
#ifdef IFM_1000_T
case(IFM_1000_T):

Since I cannot reproduce it, if you're proficient with C, could you try downloading latest master version from GIT, try to build from sources and see if you can fix it?

git clone [email protected]:giampaolo/psutil.git
cd psutil
make build

@zachriggle
Copy link
Author

It seems that the issue is specific to the build of Python installed by my company. Using python3.9 from Homebrew works.

@gsnedders
Copy link

See if_media.h in the XNU release: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/net/if_media.h.auto.html

Specifically, this contains:

#define IFM_1000_T      16              /* 1000baseT - 4 pair cat 5 */
#ifdef PRIVATE
#define IFM_1000_TX     IFM_1000_T      /* For compatibility */
#endif /* PRIVATE */

The challenge here is if Python is compiled against the case where PRIVATE is defined, then clang ends up outputting the above error.

Note there's nothing Apple Silicon specific here, it's simple a case of post-processed source ending up with:

                case(11):
                case(14):
                case(15):


                case(16):





                case(16):

                    return 1000;

Checking whether IFM_1000_T and IFM_1000_TX are equal would make it easy to guard against this.

@giampaolo
Copy link
Owner

Re-opening. Whoever can reproduce it, please provide a patch.

@giampaolo giampaolo reopened this Oct 6, 2021
georgemarshall pushed a commit to georgemarshall/psutil that referenced this issue Apr 6, 2022
Change the build.yml to add aarch64/arm64 builds

Closes giampaolo#1782, closes giampaolo#1945, closes giampaolo#1954, closes giampaolo#1966, closes giampaolo#1972,
closes giampaolo#2090

Signed-off-by: George Marshall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants