title: How to get Hello Word compiling from Swift to JavaScript using Emscripten
body: <p>Given the simplest of swift files:</p>
  
  <pre><code>println("lol")
  </code></pre>
  
  <p>It's trivial to run this on the command line with <code>xcrun swift -i lol.swift</code> or compile to an executable with <code>xcrun swift lol.swift -o lol</code>, but how about a simple proof of concept for emscripten?</p>
  
  <p>I haven't used emscripten before, but got a hello world example using C++ working from <a href="http://kripken.github.io/emscripten-site/docs/getting_started/Tutorial.html" rel="noreferrer">http://kripken.github.io/emscripten-site/docs/getting_started/Tutorial.html</a>, and wanted to compile my Swift code too.</p>
  
  <p>I tried</p>
  
  <pre><code>xcrun swift lol.swift -emit-bc -o lol.bc
  emcc lol.bc
  </code></pre>
  
  <p>But get</p>
  
  <pre><code>Value:   %1 = call { i8*, i64, i64 } @_TFSS37_convertFromBuiltinUTF16StringLiteralfMSSFTBp17numberOfCodeUnitsBw_SS(i8* bitcast ([4 x i16]* @0 to i8*), i64 3)
  LLVM ERROR: Unrecognized struct value
  Traceback (most recent call last):
    File "/Users/glen/Downloads/emsdk_portable/emscripten/1.16.0/emcc", line 1540, in &lt;module&gt;
  shared.Building.llvm_opt(final, link_opts)
    File "/Users/glen/Downloads/emsdk_portable/emscripten/1.16.0/tools/shared.py", line 1267, in llvm_opt
  assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output
  AssertionError: Failed to run llvm optimizations:
  </code></pre>
  
  <p>Thoughts?</p>