Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Clone and Build LLVM with the Experimental WebAssembly Target

    Guy BedfordGuy Bedford

    This lesson demonstrates a full build of LLVM roughly following the steps in GettingStarted.html (or GettingStartedVS.html for Windows), but with the experimental WebAssembly target build option. Prerequisites include cmake (which can be downloaded from, Visual Studio on windows, or Xcode command line tools on mac.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Before installing LLVM, you want to just check a few prerequisites. You should check that you have GCC installed, a version of Make and a version of CMake as well.

    If you don't have GCC or Make, then it's advisable to run a Xcode-Select installed on Mac to make sure you've got the Xcode online tools. In Windows, you want to have VisualStudio installed. For CMake, you can download this from the website in the documentation of this lesson.

    I'm going to start off by cloning LLVM, and I'm going to use a mirror just so we can do this five gits. Once that's complete, we can go into this LLVM folder. Within the tools folder, we want a clone Clang. Again, I'm going to use the LLVM Mirror. With Clang installed, I'm going to back out of this tools folder. I'm going to make a folder below the LLVM folder called LLVM Build.

    Within this folder, I can now use our CMake command to setup the build. Here's the command we're going to use.

    In windows, this Unix Makefiles would be Visual Studio instead. I'm building into another folder called LLVM Wasm which is going to contain the final build outputs. We're moving all the targets. We're building for the Wasm32 Architecture as a WebAssembly target from the source in the LLVM folder.

    Once CMake completes, we can then begin the built process. This is going to take about an hour or so. I'm going to use the J8 flag so that we run Make in parallel and then a Make install.

    In Windows, I would need to inaudible VisualStudio and open the llvm.sln file to start the build from there. When the build eventually completes, we can check if we've got our C compiler available at LLVM Wasm then Clang. To free up some space, this LLVM Build folder can then be removed.