Skip to content
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

clang-cl support? #204

Closed
nico opened this issue Dec 14, 2016 · 5 comments
Closed

clang-cl support? #204

nico opened this issue Dec 14, 2016 · 5 comments
Assignees
Labels
enhancement help wanted MS/Windows Microsoft or Windows specific issues

Comments

@nico
Copy link

nico commented Dec 14, 2016

Since the beta now has MSVC (yay!), maybe it could offer clang-cl too? clang-cl is part of the normal clang distribution, it runs clang in a driver mode that understands cl.exe-like options and it enables a few language extensions so that the MSVC headers can be parsed.

@nico
Copy link
Author

nico commented Jan 24, 2017

If I wanted to help with this, what would I have to do?

@mattgodbolt
Copy link
Member

Hi there: grab the source, get it running (should be as per the README) and start hacking! To start with edit the etc/config/c++.local.properties and override the compiler list (see etc/config/c++.defaults.properties etc). to be something like

compilers=clang-cl390
compiler.clang-cl390.exe=/path/to/clang/cl
compiler.clang-cl390.name=Clang CL 3.9.0

...and then see how it goes! If you need to start overriding behaviour for clang-cl specifically, you can set the compiler.clang-390.type=somethingnew and then create a file in lib/compilers/somethingnew.js in the same vein as the other files in that directory.

And the send a PR :) (NB the .local. files don't go into source control, so you'll need to give me an example) I can generalise anything that doesn't fit spefically into the CE AWS setup!

And of course: email or message me (email is as per Help menu; messaging is best on the cpplang slack) if I can help unblock you!

@nico
Copy link
Author

nico commented Feb 22, 2017

I played with this a bit. (Took a while 'cause compiler-explorer needed a newer node than available on my system.)

This makes the compiler show up and makes it kind of functional:

$ cat etc/config/c++.local.properties 
compilers=clang-cl
defaultCompiler=clang_cl

compiler.clang-cl.exe=/usr/local/google/home/thakis/src/llvm-build-nolibcxx/bin/clang-cl
compiler.clang-cl.name=clang-cl
compiler.clang-cl.compilerType=CL
compiler.clang-cl.versionFlag=/?
compiler.clang-cl.versionRe=^USAGE: clang-\S* \[options\] <inputs>$

However, clang-cl is a native linux binary (on linux; on Windows it's a native Windows binary of course) and doesn't have to run under wine. CL.js always passes 'Z:' + fn as temp file, which doesn't work without wine. So I hacked that up to

diff --git a/lib/compilers/CL.js b/lib/compilers/CL.js
index b165773..55fda82 100644
--- a/lib/compilers/CL.js
+++ b/lib/compilers/CL.js
@@ -39,16 +39,19 @@ function compileCl(info, env) {
             }
             return origExec(command, args, options);
         };
-        compile.filename = function (fn) {
-            return 'Z:' + fn;
-        };
+        // FIXME: Only do this when wine is actually needed (it isn't for
+        // clang-cl)
+        //compile.filename = function (fn) {
+            //return 'Z:' + fn;
+        //};
     }
     compile.supportsObjdump = function () {
         return false;

With this, I can pass CL-style options to clang-cl and I even get disassembly if I click the buttons just right. One issue is that clang-cl produces regular clang-style assembly and it also doesn't support /FAsc (it does support /FA), so the CL assembly parser gets kind of confused.

It probably makes sense to add something like

group.cl19.options=/I/opt/compiler-explorer/windows/10.0.10240.0/ucrt/ /I/opt/compiler-explorer/windows/14.0.24629/lib/native/include/

to the .properties file. (Even better: If we use -imsvc instead of /I, then the system directories will be treated as system include directories and clang-cl won't emit warnings for them -- see https://docs.google.com/presentation/d/1oxNHaVjA9Gn_rTzX6HIpJHP7nXRua_0URXxxJ3oYRq0/edit#slide=id.g71ecd450e_2_831 for some details) but I couldn't test that since I don't have these files on my Linux box.

So it's fairly easy to get something that kind-of works. I'm not sure if you'd prefer if there was a lib/compilers/clang-cl.js that's kind-of-but-not-quite like lib/compilers/CL.js (similar flags, but no need for wine, and has clang-style disassembly output instead of MSVC-style) or if you prefer tweaking CL.js to work for both.

@mattgodbolt
Copy link
Member

Great progress: thanks so much!

@partouf partouf added the MS/Windows Microsoft or Windows specific issues label Mar 29, 2021
@timmy-ms timmy-ms self-assigned this Jun 6, 2022
@timmy-ms
Copy link
Contributor

timmy-ms commented Jun 7, 2022

Using #1967 to track this.

@timmy-ms timmy-ms closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted MS/Windows Microsoft or Windows specific issues
Projects
None yet
Development

No branches or pull requests

4 participants