Is there another way to detect the OSArchitecture?
In the makefile there is this line:
OSARCH := $(shell wmic OS get OSArchitecture)
The command wmic.exe is disabled by default on Windows 11 since 29th January 2024.
Assistant
User
The next line in the makefile is:
ifneq ((findstringARM64−bit,(OSARCH)),)
+PLATFORM := arm64
Can i use the echo tip (Using set environment variable in cmd. You can echo the environment variable) ?
Assistant
User
This is the addition:
makefile: Detect Windows for 64-bit ARM and set PLATFORM accordingly.
Diffstat
-rw-r--r-- makefile 5
1 files changed, 5 insertions, 0 deletions
diff --git a/makefile b/makefile
index 5aa597ee0e7..24adcc8151d 100644
--- a/makefile
+++ b/makefile
@@ -140,9 +140,14 @@ MAKEPARAMS := -R
ifeq ((OS),Windows(shell wmic OS get OSArchitecture)
OS := windows
GENIEOS := windows
+ifneq ((OSARCH)),)
+PLATFORM := arm64
+else
PLATFORM := x86
+endif
else
UNAME := (shell uname -m)
Assistant
Yes, since wmic is deprecated and disabled by default on Windows 11 (from January 2024), you need alternative ways to detect the OS architecture in your Makefile.
Here are some alternative methods:
1. Using powershell in the Makefile
You can call PowerShell to get the OS architecture reliably:
You need to parse the output, but PROCESSOR_ARCHITECTURE is usually AMD64 or x86 or ARM64.
Recommendation
The PowerShell method is the most reliable for detecting OS architecture, especially if your Makefile can expect PowerShell to be available (it is installed by default on modern Windows versions).
Example full approach:
makefile
# Detect OS arch at make run-time
IS64BIT := $(shell powershell -NoProfile -Command "[Environment]::Is64BitOperatingSystem")
ifeq ($(IS64BIT),True)
OSARCH := 64-bit
else
OSARCH := 32-bit
endif
$(info OS architecture detected: $(OSARCH))
Summary
Method
Output
Notes
wmic OS get OSArchitecture
Deprecated
Disabled since Windows 11 22H2
Powershell [Env]::Is64Bit...
True / False
Reliable, modern
Environment variable PROCESSOR_ARCHITECTURE
e.g. AMD64
Process level architecture, may differ from OS architecture for 32-bit process on 64-bit OS
Registry query reg query
e.g. AMD64
A bit more complex to parse
If you want a direct replacement for wmic OS get OSArchitecture, the following Powershell command prints the architecture string:
Feel free to ask if you want help parsing or formatting any of these outputs inside the Makefile!
Let's review your snippet:
makefile
ifneq ($(findstring ARM 64-bit,$(OSARCH)),)
+PLATFORM := arm64
Here it looks like the Makefile expects OSARCH to be a string containing "ARM 64-bit" (or "ARM" and "64-bit" both). Then it sets PLATFORM := arm64.
Your question:
Can I use the echo %PROCESSOR_ARCHITECTURE% tip (cmd /C echo %PROCESSOR_ARCHITECTURE%) instead?
The answer: It depends, but mostly no if you want to detect ARM64 platform reliably.
Explanation and details:
%PROCESSOR_ARCHITECTURE% environment variable reports the architecture of the current shell process, not the OS directly.
Values you usually get there:
Value returned
Meaning
AMD64
64-bit Intel/AMD CPU
x86
32-bit Intel/AMD CPU
ARM64
64-bit ARM CPU
ARM or (sometimes ARM64)
32-bit or 64-bit ARM CPU
If your shell is 32-bit running on a 64-bit OS, %PROCESSOR_ARCHITECTURE% may show x86 even if OS is 64-bit.
If you want to detect if the CPU architecture is ARM64, this variable can be helpful because it directly includes ARM64 (provided you run a shell that is not misleading in environment).
However, sometimes (with WoW64 or on Windows 11 ARM emulation), the environment may be tricky.
So to detect ARM64 platform, the environment variable method works if:
Your build shell is consistent with the host platform architecture.
%PROCESSOR_ARCHITECTURE% can be used to detect ARM platforms (like ARM64),
But it only reports current process architecture (not fully reliable under WoW64 or emulation),
If you want reliable OS architecture, use the Powershell (Get-CimInstance Win32_OperatingSystem).OSArchitecture,
Use a combined check for ARM in PROCESSOR_ARCHITECTURE and 64-bit in OSArchitecture string to assign arm64 platform.
If you want ultimate simplicity and your Makefile environment is always a native shell, the echo %PROCESSOR_ARCHITECTURE% approach can work to detect ARM but be aware of edge cases.
If you want I can help you write the adjusted Makefile snippet for your use case — just ask!
N
T
)
+
OSARCH:=
(findstringARM64−bit,
(shelluname−mps)UNAMEM:=
Can i use OSARCH := $(shell cmd /C echo %PROCESSOR_ARCHITECTURE%) ?
Your diff currently uses this line for OSARCH on Windows:
makefile
OSARCH := $(shell wmic OS get OSArchitecture)
You want to replace it because wmic is deprecated/disabled.
Short answer: yes, you can, but the semantics change and your downstream check (findstring ARM 64-bit,$(OSARCH)) won't work as-is anymore.
Explanation
wmic OS get OSArchitecture returns strings like:
code
OSArchitecture
64-bit
or
code
32-bit
or on ARM64 Windows:
code
64-bit ARM
(For example, on ARM64 Windows 11, it can return "64-bit" plus info elsewhere.)
The output that you are parsing with
makefile
ifneq ($(findstring ARM 64-bit,$(OSARCH)),)
PLATFORM := arm64
else
PLATFORM := x86
endif
expects OSARCH to include bothARM and 64-bit in the same string (or "ARM 64-bit").
But cmd /C echo %PROCESSOR_ARCHITECTURE% returns one of:
code
AMD64
x86
ARM64
(no spaces, no "64-bit" string).
Therefore:
The string you get with cmd /C echo %PROCESSOR_ARCHITECTURE% will never contain "64-bit" literally.
Your current check findstring ARM 64-bit,$(OSARCH) will always fail if you just replace the assignment.
You must adjust the condition to check for "ARM" or "ARM64" only.
Proposed fix:
makefile
ifeq ($(OS),Windows_NT)
OSARCH := $(shell cmd /C echo %PROCESSOR_ARCHITECTURE%)
OS := windows
GENIEOS := windows
ifneq ($(findstring ARM,$(OSARCH)),)
PLATFORM := arm64
else
PLATFORM := x86
endif
else
UNAME := $(shell uname -mps)
UNAME_M := $(shell uname -m)
endif
Notes:
%PROCESSOR_ARCHITECTURE% reports current process architecture, which should be fine if you run native shells (not 32-bit shells on 64-bit OS).
If you want to be absolutely sure about OS architecture (not current shell), you'd need a more reliable method (like the Powershell (Get-CimInstance Win32_OperatingSystem).OSArchitecture).
The above modification assumes that:
"ARM" in %PROCESSOR_ARCHITECTURE% means ARM64 platform (Windows ARM 64-bit).
All others default to x86 (AMD64 64-bit Intel/AMD).
Alternative (recommended) replacement using PowerShell:
If you want to keep your original logic and detect "ARM 64-bit" string, replace your wmic line with: