xmake
xmake copied to clipboard
[BUG] set_arch() doesn't do anything
Xmake 版本
2.9.9
操作系统版本和架构
Windows 10
描述问题
Setting the architecture to riscv doesn't do anything, I can still run the compiled binaries on my x86 laptop.
期待的结果
Programs compiled to other architectures shouldn't run on my machine
工程配置
add_rules("mode.debug", "mode.release")
set_arch("riscv")
set_toolchains("llvm")
target("riscv_test")
set_kind("binary")
add_files("src/*.cpp")
#include <iostream>
int main(int argc, char** argv) {
std::cout << "hello world!" << std::endl;
return 0;
}
$ xmake build
$ xmake run
hello world!
附加信息和错误日志
$ xmake build -vD
checking for platform ... msys
checking for architecture ... x86_64
checking for gcc ... C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\gcc.exe
checking for clang ... C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang
checking for the c++ compiler (cxx) ... clang
checking for C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang ... ok
checking for flags (-fPIC) ... ok
> clang "-fPIC" "-Qunused-arguments"
checking for flags (-fvisibility-inlines-hidden) ... ok
> clang "-fvisibility-inlines-hidden" "-Qunused-arguments"
checking for flags (-O3) ... ok
> clang "-O3" "-Qunused-arguments"
checking for flags (-DNDEBUG) ... ok
> clang "-DNDEBUG" "-Qunused-arguments"
[ 50%]: cache compiling.release src\main.cpp
C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang -c -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hid
den -O3 -Ibuild\.gens\riscv_test\msys\riscv\release\platform\windows\idl -DNDEBUG -o build\.objs\riscv_test\msys\riscv\release\
src\main.cpp.o src\main.cpp
checking for flags (-MMD -MF) ... ok
> clang "-MMD" "-MF" "C:\Users\xxx\scoop\apps\msys2\2025-02-21\tmp\.xmake\250426\_66925238CF0F43708D073E14A2DA44C0" "-Qunused
-arguments"
checking for flags (-fdiagnostics-color=always) ... ok
> clang "-fdiagnostics-color=always" "-Qunused-arguments"
checking for flags (-fansi-escape-codes) ... ok
> clang "-fansi-escape-codes" "-Qunused-arguments"
checking for flags (-Wno-gnu-line-marker -Werror) ... ok
> clang "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments"
checking for clang++ ... C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang++
checking for the linker (ld) ... clang++
checking for C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang++ ... ok
checking for flags (-fPIC) ... ok
> clang++ "-fPIC"
[ 75%]: linking.release riscv_test.exe
C:\Users\xxx\scoop\apps\msys2\2025-02-21\clang64\bin\clang++ -o build\msys\riscv\release\riscv_test.exe build\.objs\riscv_tes
t\msys\riscv\release\src\main.cpp.o -s
build cache stats:
cache directory: C:\Users\cakit\Desktop\riscv_test\build\.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 1
cache miss total time: 0.000s
new cached files: 1
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.360s
[100%]: build ok, spent 1.36s
xmake f -p cross --toolchains=llvm --cross=[riscv target name] --sdk=/llvm/sdk
xmake