Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tools/niminst/makefile.nimf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ endif
target := ?{"$(binDir)/" & toLowerAscii(c.name)}


ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"')
## get CPU arch from GCC instead of using `uname -m` as GCC target CPU arch can be different from uname.
## see #25296
## 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:]"')
Copy link
Contributor

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?

Copy link
Contributor Author

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.

##ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"')
ifeq ($(OS),Windows_NT)
uos := windows
else
Expand Down