11

As an experienced programmer I feel quite dumb asking such a question: Is there a step-by-step tutorial explaining how to write a "Hello World"-Program in LLVM-Assembly Language resulting in a simple "hello.exe" which can be executed on a Standard Windows PC?

I followed dozens of such tutorial explaining how to checkout, make, compile llvm, etc. But either they require some other Software (which results in another tutorial-Marathon), or they ended up with some "Path/File/Dll not found"-Error (which results in another tutorial-Marathon). I achieved to let llvm.exe execute ... once. Now Windows reports the application to be crashing?!

Now I feel completely lost in a maze of outdated tutorials, errors, incompatibilities, emulators/VMs, IDE, Crosslinks, 32 vs. 64-Bit, with/out WinGW, with/out Cygwin, with/out Visual Studio, with/out clang, experimental, not supported, missing Environment-variables etc.

I expected to find an installer or archive containing a bunch of precompiled dll- and exe-files which can be used via command line out of the box. I just want to USE a bare llvm-toolset - no clang, no Visual Studio (if possible) - just like javac.exe, masm.exe, fasm.exe, link.exe, ...

If I have to compile llvm on my own, the possibility to achieve this via Eclipse-CDT would be great - I was unable to import the Project without any FileNotFound-Errors; which was related to some make-specific incompatibilities regarding the directory structure ... cmake should have solved that problem, but the only tutorial I found so far was about cmake-gui - which failed to install for some other reasons ...

Can someone please point me to an up-to-date tutorial on how to get a working llvm-as.exe or write a step-by-step-instruction how he/she achieved the above?

Thanks in advance - I lost three days on this so far :/

Kai Giebeler
  • 517
  • 6
  • 12
  • A web search revealed this [Hello world module in the LLVM reference](http://llvm.org/docs/LangRef.html#introduction)... – Kerrek SB Oct 20 '13 at 21:54
  • As mentioned in my description, the real challenge is to let this code compile under Windows. The "Hello World" is just a placeholder for a program to verify the toolchain works as expected. – Kai Giebeler Oct 21 '13 at 20:36
  • As of 2016 these problems persist. http://llvm.org/builds/ has pre-compiled Windows builds, but contains only `clang` and `lld`. There is a github page with a bag of compiled binaries, but its `llc` failed to compile all Hello-Worlds I threw at it. – BoppreH Jun 16 '16 at 04:26

1 Answers1

4

LLVM historically had second-rate support on Windows, but quite recently things have changed so you have good timing. Check out this LLVM blog post from just a month ago. It points to this page with binary builds of the LLVM toolchain for Windows. Once you have the tools, then the flow to a "hello world" is similar to other platforms. It would be a good idea to start with the LLVM tutorial.

FWIW there's also a getting started on Windows guide, though I'm not sure how up to date it is w.r.t the blog post mentioned above. It does create a "hello world" LLVM IR file in the process, though.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
  • 2
    Thanks. I came across the blog, but didn't notice the deep link. Trying to install results in a "Failed to find MSBuild toolsets directory."-Error while "Installing MSVC integration". – Kai Giebeler Oct 21 '13 at 20:46
  • The "getting started on Windows guide" still requires CMake and Visual Studio just to build LLVM. The linked CMake-description is for linux systems - I expect some problems and deeper research to apply this guide to Windows. Maybe I can extract some Binaries from the installer mentioned above... Thanks a lot for the Kaleidoscope-link it covers exactly what I'm trying to do with LLVM when it's up and running. – Kai Giebeler Oct 21 '13 at 20:59
  • @KaiGiebeler: if you have troubles with the binary installer, I suggest you email the llvmdev@ mailing list. Maybe things were changed or there's a known problem. These things are new and dynamic. – Eli Bendersky Oct 21 '13 at 22:04