From 2b0aef5fd114d880bd15086b979b251f71dfcf1a Mon Sep 17 00:00:00 2001 From: demotomohiro Date: Wed, 19 Nov 2025 10:35:31 +0900 Subject: [PATCH 1/2] fixes #25296; get CPU arch from gcc --- tools/niminst/makefile.nimf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/niminst/makefile.nimf b/tools/niminst/makefile.nimf index 002bc05929ef..a160c304888a 100644 --- a/tools/niminst/makefile.nimf +++ b/tools/niminst/makefile.nimf @@ -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:]"') +##ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"') ifeq ($(OS),Windows_NT) uos := windows else From 2fe0d189f58236cfee50207c100cd45aa8369264 Mon Sep 17 00:00:00 2001 From: demotomohiro Date: Thu, 20 Nov 2025 06:57:58 +0900 Subject: [PATCH 2/2] fixes gcc -dumpmachine call --- tools/niminst/makefile.nimf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/niminst/makefile.nimf b/tools/niminst/makefile.nimf index a160c304888a..5f9ac83cd45d 100644 --- a/tools/niminst/makefile.nimf +++ b/tools/niminst/makefile.nimf @@ -22,7 +22,7 @@ target := ?{"$(binDir)/" & toLowerAscii(c.name)} ## 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:]"') +ucpu := $(shell sh -c '"$(CC)" -dumpmachine | sed "s/-.*//" | tr "[:upper:]" "[:lower:]"') ##ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"') ifeq ($(OS),Windows_NT) uos := windows