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

cpufetch support for ARM macOS (Apple M1) #47

Closed
Kyngo opened this issue Apr 6, 2021 · 17 comments
Closed

cpufetch support for ARM macOS (Apple M1) #47

Kyngo opened this issue Apr 6, 2021 · 17 comments
Labels
enhancement New feature or request

Comments

@Kyngo
Copy link

Kyngo commented Apr 6, 2021

Attempting to build on an ARM MacBook Pro shows the below result:

$ make
gcc -Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99 -DARCH_ARM -Wno-unused-parameter -Wfloat-equal -Wshadow -Wpointer-arith src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/arm/soc.c src/arm/udev.c -o cpufetch
src/arm/midr.c:7:10: fatal error: 'sys/auxv.h' file not found
#include <sys/auxv.h>
         ^~~~~~~~~~~~
1 error generated.
make: *** [cpufetch] Error 1

uname -a returns this:

Darwin MacBook-Pro.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
@Dr-Noob Dr-Noob added the enhancement New feature or request label Apr 6, 2021
@Dr-Noob
Copy link
Owner

Dr-Noob commented Apr 6, 2021

Hi,

Thanks for posting the issue.

cpufetch can't work on the new M1 Macbook. At least for now, the macOS + ARM it is not supported. It looks like Apple will continue to release ARM based macOS, so to me is an interestig topic to work on. However, right now I can't work on this since it will proably be a lot of work from my part.

I wasn't thinking about adding support for it, but if I can have someone to test stuff and try some patches, I am open to work on this. If you are interested, please leave this issue opened and I will work on it in a few months. I will post a new commit then, so you can try it on your Macbook and check that everything works well.

@feiticeir0
Copy link

I also did try to build it just now and got the same error. I would love to help.

@Dr-Noob Dr-Noob changed the title Cannot build on macOS ARM cpufetch support for ARM macOS (Apple M1) Apr 6, 2021
@Dr-Noob
Copy link
Owner

Dr-Noob commented Apr 6, 2021

The issue is not the compilation error. Solving the compilation error is quite easy, but cpufetch will fail since the ARM version is designed to work with Linux only.

Now that I know that there are people interested in it, I will try to support it in the future (I hope to commit a new patch in two or three months). However, I would not expect too much functionality to work. Maybe cpufetch will be able to get the number of cores, but not much more than that (because the support is really limited, and it will be literally impossible to get more information. We will see...).

Sorry for the inconvenience and thanks for your support!

@infex987
Copy link

infex987 commented Apr 6, 2021

hello good day I have the same detail try to compile it on a MacBook Pro M1

@no-fruit
Copy link

no-fruit commented Apr 8, 2021

What you can do is run it in docker

$ git clone https://github.com/Dr-Noob/cpufetch.git && cd cpufetch
$ docker run -it --rm -v "$PWD:$PWD" -w "$PWD" ubuntu:20.04 bash -c 'apt-get update && apt-get -y install build-essential && make && { ./cpufetch ; ./cpufetch --debug; }'
[ERROR]: Unknown microarchitecture detected: IM=0x00000000 P=0x00000000 V=0x00000000 R=0x00000000
Please, create a new issue with this error message, your smartphone/computer model and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
                                                              
                                                              
                                                              
                                                              
                                                              
                                                              
                                                              SoC:                 Unknown
                                                              Technology:          Unknown
                                                              Microarchitecture:   Unknown
                                                              Max Frequency:       Unknown
                                                              Cores:               4 cores
                                                              Features:            NEON,SHA1,SHA2,AES,CRC32
                                                              Peak Performance:    Unknown
                                                              
                                                              
                                                              
                                                              
                                                              
                                                              
[ERROR]: Unknown microarchitecture detected: IM=0x00000000 P=0x00000000 V=0x00000000 R=0x00000000
Please, create a new issue with this error message, your smartphone/computer model and the output of 'cpufetch --debug' in https://github.com/Dr-Noob/cpufetch/issues
cpufetch v0.96 (ARM build)
[Core 0] 0x000F0000 -1 MHz
[Core 1] 0x000F0000 -1 MHz
[Core 2] 0x000F0000 -1 MHz
[Core 3] 0x000F0000 -1 MHz

Screenshot 2021-04-08 at 09 04 10

macOS's System Information reports

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro17,1
  Chip:	Apple M1
  Total Number of Cores:	8 (4 performance and 4 efficiency)
  Memory:	16 GB

The difference in cores is obviously down to my Docker setup which I've configured to have 4 cores/2GB memory. The CPU features are also probably not quite right because of the VM setup.

@Dr-Noob
Copy link
Owner

Dr-Noob commented Apr 8, 2021

For the moment, at least it runs, but fetched data are incorrect. For example, the message "Unknown microarchitecture detected" just shows that it tried fetching MIDR registers but instead got all zeros. Frequency is messed up too.

I hope that it will run natively in the future...

@Dr-Noob
Copy link
Owner

Dr-Noob commented Apr 8, 2021

NOTE FOR FUTURE VISITORS

This is a planned feature to be implemented in cpufetch. I can't promise anything, but I will work on it this summer, stay tuned!

@Dr-Noob
Copy link
Owner

Dr-Noob commented Apr 9, 2021

@weilantian
Copy link

I successfully compiled by switching to x86_64 architecture using the command
arch -x86_64 zsh on an M1 mac terminal
And this is what I got if I try to run the compiled binary:
CleanShot 2021-05-17 at 14 18 26

@Kyngo
Copy link
Author

Kyngo commented Aug 12, 2021

@Dr-Noob and I have been testing a new version of cpufetch with M1 support, more info to come soon!

@Dr-Noob
Copy link
Owner

Dr-Noob commented Aug 13, 2021

I have good news for those waiting for M1 support. As anticipated by @Kyngo, the M1 port is finished and already integrated into the master branch. Just clone the repo (or update it with git pull), and cpufetch will compile and run seamlessly on the M1. Give it a try and let me know if there is any problem. I hope you like it!

PS: I will leave this issue open for a few days until I am sure that everything works correctly, then I'll close it.

@Kyngo
Copy link
Author

Kyngo commented Aug 13, 2021

@Dr-Noob I found a problem when building on the master branch.

Makefile:38: Unsupported arch detected: arm64. See https://github.com/Dr-Noob/cpufetch#1-support
Makefile:39: If your architecture is supported but the compilation fails, please open an issue in https://github.com/Dr-Noob/cpufetch/issues
Makefile:40: *** Aborting compilation.  Stop.

Seems like you forgot to merge something?

@Dr-Noob
Copy link
Owner

Dr-Noob commented Aug 13, 2021

@Dr-Noob I found a problem when building on the master branch.

Makefile:38: Unsupported arch detected: arm64. See https://github.com/Dr-Noob/cpufetch#1-support
Makefile:39: If your architecture is supported but the compilation fails, please open an issue in https://github.com/Dr-Noob/cpufetch/issues
Makefile:40: *** Aborting compilation.  Stop.

Seems like you forgot to merge something?

Fixed. The Makefile is more strict in the master branch than in the m1 branch and did not recognize the arm64 architecture, now it does.

@Kyngo
Copy link
Author

Kyngo commented Aug 13, 2021

Tested and working like a charm in the master branch. Awesome work!

@Kyngo
Copy link
Author

Kyngo commented Aug 13, 2021

@Dr-Noob you should probably update the README file, as it still says M1 is not supported.

@Kyngo
Copy link
Author

Kyngo commented Aug 16, 2021

@Dr-Noob there is a small typo in the readme file now, my username is Kyngo, not Kingo :)

@Dr-Noob
Copy link
Owner

Dr-Noob commented Aug 16, 2021

@Dr-Noob there is a small typo in the readme file now, my username is Kyngo, not Kingo :)

Whoops...Fixed!

@Dr-Noob Dr-Noob closed this as completed Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants