Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Developer Guide] How to compile this project #51

Closed
HerringtonDarkholme opened this issue May 12, 2016 · 22 comments
Closed

[Developer Guide] How to compile this project #51

HerringtonDarkholme opened this issue May 12, 2016 · 22 comments
Milestone

Comments

@HerringtonDarkholme
Copy link

HerringtonDarkholme commented May 12, 2016

It should be tracked by #45, but in case you cannot compile this project, here is my try.

Prerequisite:

Make sure you have sbt, java and clang installed. My version:

$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

$ sbt -version
sbt launcher version 0.13.8

$ clang++ -version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Thread model: posix

And optionally, if you don't have gc.h in your lib path. Please refer to this to install it.

clone this project

git clone https://github.com/scala-native/scala-native.git --recursive
cd scala-native

Note the recursive option because scala-native requires scala as submodule.

publish localDeps

$ sbt
project rtlib
publishLocal
project nscplugin
publishLocal

run demoNative

still in the sbt session

project demoNative
run

And Finally I got an error from clang++, which reads error: expected '{' in function body llvm

Hope this will help.

@andreaTP
Copy link
Contributor

Same point:

demonative-out.ll:152:40: error: expected '{' in function body
declare double @"llvm.sqrt.f64"(double)

and

rt.cpp:3:10: fatal error: 'gc.h' file not found
#include <gc.h>

My configuration is:

clang++ --version
Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: x86_64-pc-linux-gnu
Thread model: posix

and

java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~15.10.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

@andreaTP
Copy link
Contributor

update:
gc.h can be fixed by installing manually BOEHM GC for example as explained here:
https://github.com/crystal-lang/crystal/wiki/All-required-libraries

@andreaTP
Copy link
Contributor

got it working on Linux!!!!

You will need to update clang and llvm to 3.7 version.

Going to try to write a usable guide.

thanks also to @andreaferretti

@timothyklim
Copy link
Contributor

on OS X too:

Rendering (8 spp) 100.00%

@rockjam
Copy link

rockjam commented May 12, 2016

Got it working on OS X after this

@kmizu
Copy link

kmizu commented May 12, 2016

Got it working on OS X after placing the file to pass additional options to clang on demo-native directory. !

@mkotsbak
Copy link
Contributor

gc.h for Ubuntu is as easy as doing:
sudo aptitude install libgc-dev

@andreaferretti
Copy link

andreaferretti commented May 12, 2016

I have a working container for Vagga: see here

@easel
Copy link

easel commented May 12, 2016

These worked for me on OS X after installing the llvm/gc stuff via home-brew. Very nice.

@andreaTP
Copy link
Contributor

I mad a PR with a Docker configuration to run it:
#56

@joprice
Copy link
Contributor

joprice commented May 12, 2016

Anyone else getting errors encoding errors in javalib/doc? I tried setting utf8 flags for scalacOptions, javaOptions, etc, and running dos2unix over all files.

@mkotsbak
Copy link
Contributor

I don't get it to compile: #68
What is the required version of clang? I just see an Apple version above. In my Ubuntu I have 3.5, 3.6, 3.7 and 3.8 available.

@andreaferretti
Copy link

You need clang 3.7 at a minimum. See this Vagga file or this Dockerfile for complete instructions.

@josdirksen
Copy link

Also got it working on OS-X Yosemite.

Got this:

rt.cpp:3:10: fatal error: 'gc.h' file not found
#include <gc.h>

Which was solved by installed boehm gc, and also got this:

demonative-out.ll:152:40: error: expected '{' in function body
declare double @"llvm.sqrt.f64"(double)

Which was solved by using brew to install llvm and clang++ 3.7 and adding those to the front of the path.

@josephwinston
Copy link

Attempting on windows:

C:\>java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

C:\>sbt --version
sbt launcher version 0.13.8

C:\>clang++ --version
clang version 3.8.0 (branches/release_38)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: c:\cygwin64\bin
C:\> sbt
project rtlib
publishLocal
project nscplugin
publishLocal

project demoNative
run

Finally produces:

> run
Unresolved dependencies:
  `#java.lang.Object`
  `#java.lang.String`
  `#scala.runtime.BoxedUnit`
  `#scala.scalanative.runtime.Exc`
  `#scala.scalanative.runtime.ObjectArray`
  `#scala.scalanative.runtime.Type`
  `@demo.Main::main_class.ssnr.ObjectArray_unit`
  `@scala.scalanative.runtime.package::init_i32_ptr_class.ssnr.ObjectArray`
  `@scala.scalanative.runtime.package`
scala.scalanative.linker.LinkingError
        at scala.scalanative.linker.Linker.linkClosed(Linker.scala:115)
        at scala.scalanative.compiler.Compiler.assembly$lzycompute(Compiler.scala:15)
        at scala.scalanative.compiler.Compiler.assembly(Compiler.scala:14)
        at scala.scalanative.compiler.Compiler.apply(Compiler.scala:66)
        at scala.scalanative.sbtplugin.ScalaNativePluginInternal$.scala$scalanative$sbtplugin$ScalaNativePluginInternal$$compileNir(ScalaNativePluginInternal.scala:24)
        at scala.scalanative.sbtplugin.ScalaNativePluginInternal$$anonfun$projectSettings$6$$anonfun$apply$1$$anonfun$apply$2.apply(ScalaNativePluginInternal.scala:85)
        at scala.scalanative.sbtplugin.ScalaNativePluginInternal$$anonfun$projectSettings$6$$anonfun$apply$1$$anonfun$apply$2.apply(ScalaNativePluginInternal.scala:67)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last demoNative/*:run for the full output.
[error] (demoNative/*:run) scala.scalanative.linker.LinkingError
[error] Total time: 0 s, completed May 13, 2016 10:24:35 AM
>

Once I get pass here, I'll deal with needing Boehm

@andreaTP
Copy link
Contributor

@josephwinston did you clone with --recursive ?

@josephwinston
Copy link

@andreaTP I thought so. I'll try starting over from scratch to see if it is user error.

@josephwinston
Copy link

@andreaTP No joy after a deleting what I had and then running git clone --recursive https://github.com/scala-native/scala-native.git. I then followed the recipe here http://stackoverflow.com/questions/6631694/replace-git-submodule-protocol-from-git-to-http/6632693#6632693 to switch from git to https. The same traceback.

@andreaTP
Copy link
Contributor

@josephwinston sorry I haven't got access ti any windows machine I can test on... Could you give a try to my docker support? manage.sh will not work but the docker commands are trivial to reproduce....

@josephwinston
Copy link

I'll switch to one of the other platforms.

On May 13, 2016, at 1:43 PM, Andrea Peruffo notifications@github.com wrote:

@josephwinston sorry I haven't got access ti any windows machine I can test on... Could you give a try to my docker support? manage.sh will not work but the docker commands are trivial to reproduce....


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@josephwinston
Copy link

Using Apple LLVM version 7.3.0 (clang-703.0.31) compiled with -O3 on demo-cpp
screen shot 2016-05-13 at 10 01 22 pm
demo-native compiled with the same level (-O3)
screen shot 2016-05-13 at 10 01 28 pm

@densh
Copy link
Member

densh commented May 18, 2016

We've got initial build instructions and docker image merged recently. Feel free opening pull requests if you want to improve those. We're also working on making linux build easier in #102 .

@densh densh closed this as completed May 18, 2016
@densh densh added this to the Wontfix milestone Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests