feat: auto-detect MSVC outside VS shell#1587
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dddfc109de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[cfg(windows)] | ||
| if let Some(msvc_cc) = detect_msvc_with_find_msvc_tools() { | ||
| return msvc_cc; | ||
| } |
There was a problem hiding this comment.
Honor explicit compiler overrides before forcing MSVC
The new early return in DETECTED_CC makes cl.exe win whenever Visual Studio is installed, even if users set MOON_CC to a GCC/Clang toolchain. In this repo, propagate_link_config still consults DETECTED_CC when native.cc is unset (crates/moonbuild-rupes-recta/src/build_plan/builders.rs:1029), so this change can now emit MSVC-style link args (foo.lib, /LIBPATH:) while the actual compiler is non-MSVC, breaking native linking for mixed/MinGW setups that previously worked unless cl was already on PATH.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed:
$env:MOON_CC="clang"
moon test -vfailed: clang -o C:\Users\mbt\Workspace\tonyfettes-raylib\_build\native\debug\test\internal\raylib\raylib.blackbox_test.exe -IC:\Users\mbt\.moon\include -g -fwrapv -fno-strict-aliasing -Wno-unused-value C:\Users\mbt\Workspace\tonyfettes-raylib\_build\native\debug\test\internal\raylib\raylib.blackbox_test.c C:\Users\mbt\Workspace\tonyfettes-raylib\_build\native\debug\test\runtime.obj C:\Users\mbt\Workspace\tonyfettes-raylib\_build\native\debug\test\internal\raylib\libraylib.lib -lm opengl32.lib gdi32.lib winmm.lib user32.lib shell32.lib opengl32.lib gdi32.lib winmm.lib user32.lib shell32.lib
clang: error: no such file or directory: 'opengl32.lib'
clang: error: no such file or directory: 'gdi32.lib'
clang: error: no such file or directory: 'winmm.lib'
clang: error: no such file or directory: 'user32.lib'
clang: error: no such file or directory: 'shell32.lib'
There was a problem hiding this comment.
This should have been fixed.
tonyfettes
left a comment
There was a problem hiding this comment.
Compile and link correctly on Windows when MSVC is configured but not added to path.
Reproduced the bug spotted by Codex. See above for more information.
da8049a to
3cef384
Compare
3cef384 to
75ccf3f
Compare
Summary
cl,cc,gcc, andclangfind-msvc-toolsto discovercl.exebuild_planWhy
Windows users should be able to build native targets without starting from a Visual Studio Developer Command Prompt.
Scope