lbguilherme / crystal

The Crystal Programming Language
http://crystal-lang.org
Apache License 2.0
1 stars 0 forks source link

fix src to be able to build the compiler (in linux) #1

Closed bcardiff closed 7 years ago

bcardiff commented 7 years ago

I was able to repro the Hello Crystal sample in a ubuntu 16.04 + llvm 3.9 + wine 2.0-rc3 + the steps in https://github.com/crystal-lang/crystal/pull/3582 \o/ .

This PR should tidy up things a bit since someone need a crystal compiler with the windows target to emit llvm. Before this PR the compiler can't be built because the prelude is changed. This also make the build fail.

# file ./foo.cr
require "./windows-prelude" 
puts "Hello Windows!" 
$ make # to build the compiler with windows target
$ ./bin/crystal build foo.cr --ll --single-module --cross-compile --target x86_64-windows-gnu --prelude=empty
$ wine /path/to/LLVM-3.9.0/bin/clang.exe  -g3 foo.ll -c -o foo.o
$ /path/to/mxe/usr/bin/x86_64-w64-mingw32.static-gcc -g3 foo.o -o foo.exe -liconv -lkernel32 -lgc -levent -lws2_32
$ wine foo.exe 
Hello Windows!

The windows-prelude.cr has the prelude.cr before this PR so your examples are reproducible, yet if someone uses further functionality it will most probably break.

If I am missing something in your workflow let me know.

lbguilherme commented 7 years ago

I didn't remember I had build the compiler with LLVM 3.8 locally before starting the changes and I was using this compiler instead of the prebuilt one for Linux (LLVM 3.5). This probably explains everything working for me with Clang 3.9.

Thanks for this. At least now the existing specs will pass.

lbguilherme commented 7 years ago

I've made just a change here: I moved windows-prelude.cr to src, so now one can write --prelude=windows-prelude instead of requiring in the source.