-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provide an MSVC-compatible command line interface, similar to zig cc
but with MSVC-flavored flags
#4785
Comments
https://clang.llvm.org/docs/MSVCCompatibility.html I think "drop in replacement" means no compatibility issues, while what CLang tries to achieve is ability to compile Windows SDK headers. I think "ability to compile latest Windows SDK headers" is what the real goal should be, not "drop in replacement", this is simply not a realistic task. MSVC has a lot of language extensions. |
Hi! Does this mean that |
On Windows you might want to use |
Thanks for the reply.
I'm runnning zig 0.6.0 on windows. |
It will. Give it a minute while it builds and caches mingw-w64. The terminal progress indicator isn't implemented for Windows terminals yet. It only has to do this the first time. |
Yes it indeed work. Might need to print something atleast to stderr so it's less confusing. |
There is a whole progress bar system in place, but it does not yet know how to display on windows terminals. Contribution welcome! Line 102 in 48dc3b6
|
Is there still interest in this? I'm unfamiliar with Zig source (and C/C++ in general), but if Clang is in-tree, maybe this could be used? llvm::opt::DerivedArgList* MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
StringRef BoundArch,
Action::OffloadKind OFK) {} If I'm wrong, I think it could still be done with just a mapping/lookup table function (though more tedious and fragile). I feel a lot of folks would benefit from this. It's not always the most intuitive process to translate MSVC Have learned that you can pass λ clang-cl /c /EHa /EHc -### a.c
clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
(in-process)
"C:\\Program Files\\LLVM\\bin\\clang-cl.exe" "-cc1" "-triple" "x86_64-pc-windows-msvc19.28.29913" "-emit-obj" "-mrelax-all" "-mincremental-linker-compatible" "--mrelax-relocations" "-disable-free" "-main-file-name" "a.c" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-relaxed-aliasing" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-mllvm" "-x86-asm-syntax=intel" "-tune-cpu" "generic" "-D_MT" "-flto-visibility-public-std" "--dependent-lib=libcmt" "--dependent-lib=oldnames" "-stack-protector" "2" "-fexceptions" "-fms-volatile" "-fdiagnostics-format" "msvc" "-resource-dir" "C:\\Program Files\\LLVM\\lib\\clang\\12.0.0" "-internal-isystem" "C:\\Program Files\\LLVM\\lib\\clang\\12.0.0\\include" "-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\include" "-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\atlmfc\\include" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt" "-fdebug-compilation-dir" "C:\\Users\\rayga" "-ferror-limit" "19" "-fmessage-length=120" "-fno-use-cxa-atexit" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=19.28.29913" "-fdelayed-template-parsing" "-fcolor-diagnostics" "-faddrsig" "-o" "a.obj" "-x" "c" "a.c" So maybe it's possible to script/automate the generation of the conversion by writing an array of all possible flags (with dummy input where needed), and iterating them one-by-one and taking only the diff between each invocation to get the converted output of the flag. Then you'd have a mapping from Alternatively, something like this could be used as a duct-tape hack maybe: #!/bin/sh
$clang_flags = $(clang-cl.exe "-###" "$@") # Do some processing on the text too so it's only the clang flags
zig cc $clang_flags If there's still interest in this or a good way of implementing it, maybe I could try to take a crack it. =) |
Wouldn't making this work out-of-the-box require the user to also have the MSVCRT and SDK, which are both huge and not freely licensed/forbidden from redistribution? E.G. I have followed this as an example and tool for using Clang/CL: |
Zig with Xwin test: https://github.com/kassane/xwin-zig-test |
note that Xwin is not ideal, as it does not handle (and owner refuses to handle) important parts of MSVC such as |
I am convinced this is not worth it. Note that this proposal is about the CLI interface of Zig. It has already been possible for a long time to use Zig as a replacement for MSVC. |
zig cc
but with MSVC-flavored flags
you mean in the context of headers and libraries. in the context of executables such as |
clang already has a "cl mode", and it should be pretty minimal efforts to also support
zig cl
, given the framework we already have in place forzig cc
. Thanks to ihnorton for the idea.The text was updated successfully, but these errors were encountered: