Hello CLang World!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Hello CLang World!

David Zarzycki via cfe-dev
Hi, 

Er. Hello, I don't feel like I have any business being on a compiler mailing list but I've been driven here by desperation. Not that I don't want to be here, I just suck at C so it feels weird. 

Anywho, I like Lua. It's  a fun little language. The neat part is it's so small and customizable. On FreeBSD it's *super* easy to build. In fact, it's so easy a nicompoop like me has become the port maintainer for Lua (albeit with great heaps of help from someone else). 

Alas, on Windows, Lua is not so easy to build. I need to download a 20 GB Visual Studio or tear my hair out getting mingw set up. I have sometimes resorted to the Free VC++ Build Tools, but that's still 4GB to build Lua, which is.. er.. 402 KB. I also still need to do everything in DOS to get all the environment variables, or go through backflips trying to set up powershell to work with VC++.

So, many years ago I downloaded LLVM (clang 5.01) and tried to build Lua only to be stymied and then waylaid by life. I recently became interested in compilers on Windows again, spurred on by the discovery of the Embarcadero and Keil compilers, both built on clang. However, both licenses *explicitly* forbids my use case.

So, here I am. I just want to be able to build Lua easily on Windows, so I'm going to make my own compiler toolchain using clang and I'm going to include it in my binary Windows distribution of Lua. PERFECTLY logical. 

Anyway, you know how I said I suck at C? Well the thing that stymied me so many years ago - and has stymied me this very night and driven me insane enough to swear to almighty God that I'mna learn how to make a compiler - is that the Lua Makefile uses `ar` and there is no `ar` on Windows. Do I need ar (an archiver to build lib files) when I'm compiling on Windows with clang? Could someone help me build Lua on Windows with clang so I can start my lunatic journey into LLVM?

Thanks, and nice meeting you all.

Russell Haley


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Hello CLang World!

David Zarzycki via cfe-dev
On Windows lib files are typically made with a tool called lib which ships with Visual Studio.  Unlike ar, which outputs .a files, lib outputs .lib files.

It sounds like perhaps you need to modify the Makefile to not try to use ar on Windows, but to use lib instead.

On Thu, Jan 9, 2020 at 10:27 PM Russell Haley via cfe-dev <[hidden email]> wrote:
Hi, 

Er. Hello, I don't feel like I have any business being on a compiler mailing list but I've been driven here by desperation. Not that I don't want to be here, I just suck at C so it feels weird. 

Anywho, I like Lua. It's  a fun little language. The neat part is it's so small and customizable. On FreeBSD it's *super* easy to build. In fact, it's so easy a nicompoop like me has become the port maintainer for Lua (albeit with great heaps of help from someone else). 

Alas, on Windows, Lua is not so easy to build. I need to download a 20 GB Visual Studio or tear my hair out getting mingw set up. I have sometimes resorted to the Free VC++ Build Tools, but that's still 4GB to build Lua, which is.. er.. 402 KB. I also still need to do everything in DOS to get all the environment variables, or go through backflips trying to set up powershell to work with VC++.

So, many years ago I downloaded LLVM (clang 5.01) and tried to build Lua only to be stymied and then waylaid by life. I recently became interested in compilers on Windows again, spurred on by the discovery of the Embarcadero and Keil compilers, both built on clang. However, both licenses *explicitly* forbids my use case.

So, here I am. I just want to be able to build Lua easily on Windows, so I'm going to make my own compiler toolchain using clang and I'm going to include it in my binary Windows distribution of Lua. PERFECTLY logical. 

Anyway, you know how I said I suck at C? Well the thing that stymied me so many years ago - and has stymied me this very night and driven me insane enough to swear to almighty God that I'mna learn how to make a compiler - is that the Lua Makefile uses `ar` and there is no `ar` on Windows. Do I need ar (an archiver to build lib files) when I'm compiling on Windows with clang? Could someone help me build Lua on Windows with clang so I can start my lunatic journey into LLVM?

Thanks, and nice meeting you all.

Russell Haley

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Hello CLang World!

David Zarzycki via cfe-dev
As a rule, if you're trying to use clang-on-Windows tools in place of Visual Studio's, you should keep this correspondence in mind:

clang-cl is equivalent to cl.exe (the C/C++ compiler)
lld-link is equivalent to link.exe (the linker)
llvm-lib is equivalent to lib.exe (the static library archiver)
llvm-rc is (sort of) equivalent to rc.exe (the Windows resource compiler) - though you may need to run clang-cl /P on any .rc files first, since llvm-rc doesn't include the preprocessor.

... on the other hand, I'm seeing a few guides online already to building Lua on Windows with gcc and mingw (e.g., [1], though I can't confirm its quality). You may well be able to use clang in place of gcc without much difficulty!


On Fri, Jan 10, 2020 at 1:42 AM Zachary Turner via cfe-dev <[hidden email]> wrote:
On Windows lib files are typically made with a tool called lib which ships with Visual Studio.  Unlike ar, which outputs .a files, lib outputs .lib files.

It sounds like perhaps you need to modify the Makefile to not try to use ar on Windows, but to use lib instead.

On Thu, Jan 9, 2020 at 10:27 PM Russell Haley via cfe-dev <[hidden email]> wrote:
Hi, 

Er. Hello, I don't feel like I have any business being on a compiler mailing list but I've been driven here by desperation. Not that I don't want to be here, I just suck at C so it feels weird. 

Anywho, I like Lua. It's  a fun little language. The neat part is it's so small and customizable. On FreeBSD it's *super* easy to build. In fact, it's so easy a nicompoop like me has become the port maintainer for Lua (albeit with great heaps of help from someone else). 

Alas, on Windows, Lua is not so easy to build. I need to download a 20 GB Visual Studio or tear my hair out getting mingw set up. I have sometimes resorted to the Free VC++ Build Tools, but that's still 4GB to build Lua, which is.. er.. 402 KB. I also still need to do everything in DOS to get all the environment variables, or go through backflips trying to set up powershell to work with VC++.

So, many years ago I downloaded LLVM (clang 5.01) and tried to build Lua only to be stymied and then waylaid by life. I recently became interested in compilers on Windows again, spurred on by the discovery of the Embarcadero and Keil compilers, both built on clang. However, both licenses *explicitly* forbids my use case.

So, here I am. I just want to be able to build Lua easily on Windows, so I'm going to make my own compiler toolchain using clang and I'm going to include it in my binary Windows distribution of Lua. PERFECTLY logical. 

Anyway, you know how I said I suck at C? Well the thing that stymied me so many years ago - and has stymied me this very night and driven me insane enough to swear to almighty God that I'mna learn how to make a compiler - is that the Lua Makefile uses `ar` and there is no `ar` on Windows. Do I need ar (an archiver to build lib files) when I'm compiling on Windows with clang? Could someone help me build Lua on Windows with clang so I can start my lunatic journey into LLVM?

Thanks, and nice meeting you all.

Russell Haley

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Fwd: Hello CLang World!

David Zarzycki via cfe-dev
In reply to this post by David Zarzycki via cfe-dev
Hi, 

As I said to  Zachary, the lua mailing list automagically replies to the mailing list and I forget to reply all sometimes. This is the messages forwarded on to the list.

---------- Forwarded message ---------
From: Russell Haley <[hidden email]>
Date: Sat, Jan 11, 2020 at 11:06 AM
Subject: Re: [cfe-dev] Hello CLang World!
To: Zachary Turner <[hidden email]>




On Sat, Jan 11, 2020 at 7:45 AM Zachary Turner <[hidden email]> wrote:
Well, a kid would just install VS and call it a day :)

Yes, touche. Remember I'm full on triggered! None of what I'm doing makes much sense (ha ha). I guess this is a haphazard attempt to figure out *why* nobody else has created a C compiler for Windows. 


If you’re feeling motivated, you could install everything you need (including VS), then manually extract out the necessary components, and package them up, then put that in some (private) github somewhere so whenever you need it, you just clone it and you’re good to go.

I looked at that briefly the other day. I need to check about the licensing. The thought was distribute the clang compiler with header and lib files from the VS toolchain and just point them at the redistributable. As to your point below: that means no debug symbols or debug version to link to, no debugger and likely a bunch of other problems.


That said, MinGW is — imho — trying to fit a square peg in a round hole.  If you want to have a good experience on Windows, you need to embrace the Windows way.  For example, if you build with MinGW, you won’t even be able to step through your program in a debugger. 

Yes, I agree. As we discuss this my envisioned toolset keeps getting less and less useful.  My primary use case for all this is alongside LuaRocks to compile existing modules, but a debugger would  be nice... hello 20GB Visual Studio. Drat.


On Fri, Jan 10, 2020 at 11:49 PM Russell Haley <[hidden email]> wrote:


On Fri, Jan 10, 2020 at 10:41 PM Zachary Turner <[hidden email]> wrote:
Libc++ can get you a c++ standard library, but you’ll need a libc as well, and you have two options - Microsoft’s or MinGW.  using clang on Windows with MinGW is not a common combination so I don’t know what kind of issues you’ll run into.
D'oh! I had assumed Libc++ included a C library. That's actually all I was interested in. 
 

If you just want to avoid paying money, then you don’t need to worry about that because VS Community Edition is free.  If it’s a principle thing a d you just want to use OSS for the whole stack, you might need to go with MinGW.

Don't get me wrong, I've used VS for almost 2 decades now for C# (and enjoy it). Yes, the community edition is free and 20 GB. Even the the free VC++ Build Tools - which I've used effectively to run Luarocks - is 4GB. I just can't believe that's necessary. My experience with setting up mingw has been horrible and I'm *nix fluent . How is some kid supposed to deal with that? Maybe I just botched it, I don't know. I also still don't know if I need a runtime distributable with mingw. 

The thing that triggered me this time (and I'm full on SJW triggered) was when I tried the Embarcadero package. The clang based compiler and runtime are small - 194 MB. It only does Win32 and requires a runtime but I'm good with that! Dammit, I want to do that! I just want a C compiler on Windows.

I wonder if I can hack bsd libc...

Cheers,
Russ


On Fri, Jan 10, 2020 at 10:37 PM Russell Haley <[hidden email]> wrote:


On Thu, Jan 9, 2020 at 11:27 PM Zachary Turner <[hidden email]> wrote:


On Thu, Jan 9, 2020 at 11:17 PM Russell Haley <[hidden email]> wrote:

On Thu, Jan 9, 2020 at 10:42 PM Zachary Turner <[hidden email]> wrote:
On Windows lib files are typically made with a tool called lib which ships with Visual Studio.  Unlike ar, which outputs .a files, lib outputs .lib files.

Thank you! I'll start with that and change the make file. Is there an open source equivalent to lib? One that could be shipped by me and minus the few gigabytes of VS? I'll obviously google it after this, but I'll ask in case you or someone has a preference (or project?)
llvm includes a tool called llvm-lib which is command-line compatible with Microsoft’s lib.exe

You can’t get by without installing visual studio at all though, because even if you use clang on Windows it still needs the MS headers and libraries which are installed via Visual Studio and the Windows SDK.

I'm hoping libc++ can help out there? I see there is Visual Studio/Cmake build instructions. Lua modules are primarily written in C though so I think even that might be overkill (if viable). I read some of the documentation about turning off vcruntime compatability as well (of dubious relevance).  



By the way my boys and I love roblox and your studio is a *great* Lua environment.
and more to come here soon :)

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev