-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fixes #25296; get CPU arch from gcc #25297
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
base: devel
Are you sure you want to change the base?
Conversation
tools/niminst/makefile.nimf
Outdated
| ## it should also get OS from GCC so that csource can be build with more GCC for cross compilation. | ||
| ## but parsing OS name from `gcc -dumpmachine` is hard: | ||
| ## https://wiki.osdev.org/Target_Triplet | ||
| ucpu := $(shell sh -c 'gcc -dumpmachine | cut --delimiter=- --field=1 | tr "[:upper:]" "[:lower:]"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long options are a GNUism so this won't work on FreeBSD etc. cut -d - -f 1 seems preferable.
Also, later down the file there's this line:
mycpu = $(shell /bin/sh -c '"$(CC)" -dumpmachine | sed "s/-.*//"')clang supports dumpmachine too, so maybe $(CC) is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I wasn't aware there is already code calls $(CC) -dumpmachine.
2fe0d18 to
f055400
Compare
|
I don't see why we would prefer GCC's ideas over the OS's ideas for OS/CPU detection. For example, what if we build with clang? |
|
On Raspberry Pi 5 with 32-bit OS, So if I think using GCC for OS/CPU detection works better when you want to cross compile csource and set Other ways to detect CPU architecture without C compiler are:
import platform
print(platform.architecture()[0])
print(platform.machine())Output on 32bit Raspberry Pi OS:
Output on 32bit Raspberry Pi OS: |
|
There is nothing to detect here, if |
No description provided.