-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Actual behavior
For the native compilation target, after using cl, switching back to gcc does not take effect.
Scenario:
While casually testing whether vc6.0 cl.exe could compile native, I used AI to help configure a native JSON configuration. Using the command moon build --target native --dry-run showed that the corresponding cl.exe was indeed invoked. However, when configuring gcc in a new demo and executing moon build --target native --dry-run, it still displayed the previous cl.exe information. I have tried reinstalling moon and running moon clean, but neither worked.
Expected Behavior
When executing the command moon build --target native --dry-run, the cc configuration for native should display the current configuration, not persistently show the previous one. For example, if gcc is configured this time, it should show gcc-related information; if cl is configured, it should show cl's information.
Steps to Reproduce
- First demo01
///|
fn main {
println(@lib.fib(10))
}
native target, first configure vc6.0's cli generated here with the help of AI
{
"is-main": true,
"import": [
{
"path": "username/demo01",
"alias": "lib"
}
],
"supported-targets": [
"native"
],
"link": {
"native": {
"cc": "cl",
"cflags": [
"/nologo",
"/O2",
"/GX", // Enable exception handling (alternative to /EHsc)
"/W3", // Warning level 3
"/D \"_CRT_SECURE_NO_WARNINGS\"", // Disable security warnings
"/D \"WIN32\"",
"/D \"_WINDOWS\"",
"/D \"_MBCS\""
],
"include_dirs": [
"{MOON_HOME}/include",
"D:/software/vc6.0/Microsoft Visual Studio/VC98/Include"
],
"lib_dirs": [
"{MOON_HOME}/lib",
"D:/software/vc6.0/Microsoft Visual Studio/VC98/Lib"
],
"libs": [
"kernel32.lib",
"user32.lib",
"gdi32.lib",
"winspool.lib",
"comdlg32.lib",
"advapi32.lib",
"shell32.lib",
"ole32.lib",
"oleaut32.lib",
"uuid.lib",
"odbc32.lib",
"odbccp32.lib"
]
}
}
}Run:
moon build --target native --dry-runOutput:
PS E:\workspace\moondemo> moon build --target native --dry-run
'D:/software/vc6.0/Microsoft Visual Studio/VC98/Bin/CL.EXE' /Fo./_build/native/release/build/runtime.obj '/I$MOON_HOME/include' /c /utf-8 /wd4819 /nologo /O2 '$MOON_HOME/lib/runtime.c'
moonc build-package ./moondemo.mbt -o ./_build/native/release/build/moondemo.core -pkg username/moondemo -std-path '$MOON_HOME/lib/core/target/native/release/bundle' -i '$MOON_HOME/lib/core/target/native/release/bundle/prelude/prelude.mi:prelude' -pkg-sources username/moondemo:. -target native -workspace-path . -all-pkgs ./_build/native/release/build/all_pkgs.json
moonc build-package ./cmd/main/main.mbt -o ./_build/native/release/build/cmd/main/main.core -pkg username/moondemo/cmd/main -is-main -std-path '$MOON_HOME/lib/core/target/native/release/bundle' -i ./_build/native/release/build/moondemo.mi:lib -i '$MOON_HOME/lib/core/target/native/release/bundle/prelude/prelude.mi:prelude' -pkg-sources username/moondemo/cmd/main:./cmd/main -target native -workspace-path . -all-pkgs ./_build/native/release/build/all_pkgs.json
moonc link-core '$MOON_HOME/lib/core/target/native/release/bundle/abort/abort.core' '$MOON_HOME/lib/core/target/native/release/bundle/core.core' ./_build/native/release/build/moondemo.core ./_build/native/release/build/cmd/main/main.core -main username/moondemo/cmd/main -o ./_build/native/release/build/cmd/main/main.c -pkg-config-path ./cmd/main/moon.pkg.json -pkg-sources username/moondemo:. -pkg-sources username/moondemo/cmd/main:./cmd/main -pkg-sources 'moonbitlang/core:$MOON_HOME/lib/core' -target native
gcc -o ./_build/native/release/build/cmd/main/main.exe '-I$MOON_HOME/include' -fwrapv -fno-strict-aliasing ./_build/native/release/build/cmd/main/main.c ./_build/native/release/build/runtime.obj -lm '-std=c99' -m32- Second demo
///|
fn main {
println(@lib.fib(10))
}
native target,
{
"is-main": true,
"import": [
{
"path": "username/moondemo2",
"alias": "lib"
}
],
"supported-targets": [
"native"
],
"link": {
"native": {
"cc": "gcc",
"cc-flags": "",
"cc-link-flags": ""
}
}
}Run:
moon build --target native --dry-runOutput:
PS E:\workspace\moondemo2> moon build --target native --dry-run
'D:/software/vc6.0/Microsoft Visual Studio/VC98/Bin/CL.EXE' /Fo./_build/native/release/build/runtime.obj '/I$MOON_HOME/include' /c /utf-8 /wd4819 /nologo /O2 '$MOON_HOME/lib/runtime.c'
moonc build-package ./moondemo2.mbt -o ./_build/native/release/build/moondemo2.core -pkg username/moondemo2 -std-path '$MOON_HOME/lib/core/target/native/release/bundle' -i '$MOON_HOME/lib/core/target/native/release/bundle/prelude/prelude.mi:prelude' -pkg-sources username/moondemo2:. -target native -workspace-path . -all-pkgs ./_build/native/release/build/all_pkgs.json
moonc build-package ./cmd/main/main.mbt -o ./_build/native/release/build/cmd/main/main.core -pkg username/moondemo2/cmd/main -is-main -std-path '$MOON_HOME/lib/core/target/native/release/bundle' -i ./_build/native/release/build/moondemo2.mi:lib -i '$MOON_HOME/lib/core/target/native/release/bundle/prelude/prelude.mi:prelude' -pkg-sources username/moondemo2/cmd/main:./cmd/main -target native -workspace-path . -all-pkgs ./_build/native/release/build/all_pkgs.json
moonc link-core '$MOON_HOME/lib/core/target/native/release/bundle/abort/abort.core' '$MOON_HOME/lib/core/target/native/release/bundle/core.core' ./_build/native/release/build/moondemo2.core ./_build/native/release/build/cmd/main/main.core -main username/moondemo2/cmd/main -o ./_build/native/release/build/cmd/main/main.c -pkg-config-path ./cmd/main/moon.pkg.json -pkg-sources username/moondemo2:. -pkg-sources username/moondemo2/cmd/main:./cmd/main -pkg-sources 'moonbitlang/core:$MOON_HOME/lib/core' -target native
gcc -o ./_build/native/release/build/cmd/main/main.exe '-I$MOON_HOME/include' -fwrapv -fno-strict-aliasing -O2 ./_build/native/release/build/cmd/main/main.c ./_build/native/release/build/runtime.obj -lm
PS E:\workspace\moondemo2> Environment
Operating System:
PS C:\Users\xkp> moon version --all
moon 0.1.20260110 (0e584ac 2026-01-10) ~\.moon\bin\moon.exe
moonc v0.7.1+adb125543 (2026-01-10) ~\.moon\bin\moonc.exe
moonrun 0.1.20260110 (0e584ac 2026-01-10) ~\.moon\bin\moonrun.exe
moon-pilot ~\.moon\bin\moon-pilot.bat
PS E:\workspace\moondemo2> gcc --version
gcc.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.Checklist
- (Optional) My case is minimal enough to be reproducible.