Fails to build

222 views
Skip to first unread message

Elliott Stoneham

unread,
Sep 1, 2015, 6:11:34 AM9/1/15
to llgo-dev
Could someone give me some help please.

I've attempted to build the system using the instructions in http://llvm.org/viewvc/llvm-project/llgo/trunk/README.TXT?view=markup

However I did not understand what value I should put in for "/path/to/llvm-inst" in:
cmake /path/to/llvm -DCMAKE_INSTALL_PREFIX=/path/to/llvm-inst

Therefore I did not provide a "-DCMAKE_INSTALL_PREFIX" setting ... the error message I have (after a very long build process) is:
...
[ 92%] Built target llvm-config
Scanning dependencies of target llgo
make[2]: *** No rule to make target 'bin/llvm-go', needed by 'bin/llgo'. Stop.
CMakeFiles/Makefile2:18269: recipe for target 'tools/llgo/CMakeFiles/llgo.dir/all' failed
make[1]: *** [tools/llgo/CMakeFiles/llgo.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2

I'm running on the latest Ubuntu with go 1.5 installed.

I'm particularly interested in investigating llgoi.

Thanks for taking the time to read this, please let me know what I should do to get it working if you know.

Andrew Wilkins

unread,
Sep 1, 2015, 7:52:52 AM9/1/15
to llgo...@googlegroups.com
On Tue, 1 Sep 2015 at 18:11 Elliott Stoneham <elliott....@gmail.com> wrote:
Could someone give me some help please.

I've attempted to build the system using the instructions in http://llvm.org/viewvc/llvm-project/llgo/trunk/README.TXT?view=markup

However I did not understand what value I should put in for "/path/to/llvm-inst" in:
cmake /path/to/llvm -DCMAKE_INSTALL_PREFIX=/path/to/llvm-inst

You shouldn't need it, unless you want to install. You just specify the path prefix for the installation (e.g. "/usr/local"). This can be anywhere; I put mine under my home directory.

Therefore I did not provide a "-DCMAKE_INSTALL_PREFIX" setting ... the error message I have (after a very long build process) is:
...
[ 92%] Built target llvm-config
Scanning dependencies of target llgo
make[2]: *** No rule to make target 'bin/llvm-go', needed by 'bin/llgo'. Stop.
CMakeFiles/Makefile2:18269: recipe for target 'tools/llgo/CMakeFiles/llgo.dir/all' failed
make[1]: *** [tools/llgo/CMakeFiles/llgo.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2

I'm running on the latest Ubuntu with go 1.5 installed.

Likewise, and llgo builds for me. What svn rev are you on? (svn info)

I'm particularly interested in investigating llgoi.

llgoi is broken (runtime error) on trunk, I'll investigate shortly.

Thanks for taking the time to read this, please let me know what I should do to get it working if you know.

Would you please pastebin the entire output of running cmake? I suspect it's not picking up your Go 1.5 installation properly, which means no Go bindings, which means no llvm-go. CMake output should confirm that.

Cheers,
Andrew

Elliott Stoneham

unread,
Sep 1, 2015, 8:50:36 AM9/1/15
to llgo-dev
Many thanks for getting back to me so quickly Andrew, much appreciated.

As regards svn and go, please see the output below:
elliott@elliott-VirtualBox:~/llvm$ svn info
Path: .
Working Copy Root Path: /home/elliott/llvm
Relative URL: ^/llvm/trunk
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 246532
Node Kind: directory
Schedule: normal
Last Changed Author: ruiu
Last Changed Rev: 246532
Last Changed Date: 2015-09-01 07:01:53 +0100 (Tue, 01 Sep 2015)

elliott@elliott-VirtualBox:~/llvm$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/elliott/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
elliott@elliott-VirtualBox:~/llvm$ go version
go version go1.5 linux/amd64
elliott@elliott-VirtualBox:~/llvm$ 

I'll go and run CMake again (which will take a while) and give you the output to browse through.

Thanks again,
Elliott

Elliott Stoneham

unread,
Sep 1, 2015, 8:54:25 AM9/1/15
to llgo-dev
The cmake command:

elliott@elliott-VirtualBox:~/llvm-build$ cmake ~/llvm -DCMAKE_INSTALL_PREFIX=~
-- No build type selected, default to Debug
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Sphinx disabled.
-- Go bindings enabled.
-- Could NOT find OCaml (missing:  OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing:  OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting BPF
-- Targeting CppBackend
-- Targeting Hexagon
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting Sparc
-- Targeting SystemZ
-- Targeting X86
-- Targeting XCore
-- Clang version: 3.8.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/elliott/llvm-build
elliott@elliott-VirtualBox:~/llvm-build$ 

Elliott Stoneham

unread,
Sep 1, 2015, 10:58:01 AM9/1/15
to llgo-dev
Andrew,

Please the output from "make install" at https://gist.github.com/elliott5/75a26524a50bb93c1bd8

Thanks,

Elliott

Andrew Wilkins

unread,
Sep 1, 2015, 10:02:40 PM9/1/15
to llgo-dev
Hi Elliott,

Unfortunately I can't see much there. Can you try building just llgo or llgoi?
    make VERBOSE=1 llgoi 2>&1 | tee build.log; pastebinit < build.log
I think I've had issues in the past where "install" doesn't depend on targets properly, so you have to do "make && make install".

Cheers,
Andrew

Elliott Stoneham

unread,
Sep 2, 2015, 5:10:23 AM9/2/15
to llgo-dev
Thank you Andrew, I now have a working llvm-go command!
...though not quite in the way you suggested (I've pasted the output I caught into https://gist.github.com/elliott5/75a26524a50bb93c1bd8 if you want to see)

make VERBOSE=1 llgoi 2>&1 | tee llgoi.log  # did not work, output in gist
make && make install 2>&1 | tee makeandmakeinstall.log  # failed on the make stage and therefore produced no output

so I tried:
make VERBOSE=1 llvm-go 2>&1 | tee llvm-go.log  # which did appear to work, output in gist
then again with:
make VERBOSE=1 llgoi 2>&1 | tee llgoi2.log  # which took a very long time, but worked, output in gist

And behold:
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ llvm-go run *.go
hello, world
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ llvm-go build 
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ ls -l
total 2308
-rwxr-xr-x 1 elliott elliott 2356520 Sep  2 09:57 hw
-rw-rw-r-- 1 elliott elliott      78 Sep  1 07:19 hw.go
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ ./hw
hello, world

llgoi builds and presents a prompt when it is run, but whatever I type seems to give a stack dump.

Still, progress! So thank you for your help.

Elliott

Andrew Wilkins

unread,
Sep 2, 2015, 5:33:23 AM9/2/15
to llgo...@googlegroups.com
Great, glad you got that far. This is where I'm at too. It's dumping because of an assertion due to the JIT and module having different data layouts. Maybe try reverting to r241608 or earlier.

Cheers,
Andrew

Elliott

--
You received this message because you are subscribed to the Google Groups "llgo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to llgo-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elliott Stoneham

unread,
Sep 3, 2015, 3:16:17 AM9/3/15
to llgo-dev
OK so llvm-go seems to be damn clever, and uses normal Go where it can...

To actually run the llgo compiler on my hello world program I need to call it explicitly:
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ llgo hw.go
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ ls -l
total 2336
-rwxrwxr-x 1 elliott elliott   26792 Sep  3 07:47 a.out
-rwxr-xr-x 1 elliott elliott 2356520 Sep  2 09:57 hw
-rw-rw-r-- 1 elliott elliott      78 Sep  1 07:19 hw.go
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ ./a.out
hello, world

Lots of interesting options for the compile, but you need to read the code to find them in:
llvm/tools/llgo/cmd/gllo/gllgo.go

Andrew Wilkins

unread,
Sep 3, 2015, 3:37:43 AM9/3/15
to llgo...@googlegroups.com
On Thu, 3 Sep 2015 at 15:16 Elliott Stoneham <elliott....@gmail.com> wrote:
OK so llvm-go seems to be damn clever, and uses normal Go where it can...

llvm-go is just an internal build thing. There is also a script called "llgo-go", which is a wrapper around the standard "go" tool. Calling this you should be able to (AOT) compile things just the same as with gc or gccgo.

Elliott Stoneham

unread,
Sep 3, 2015, 4:32:33 AM9/3/15
to llgo-dev
Andrew,

What are the options required to generate a .bc or .ll file from the .go? I'm sorry, I can't easily see them from the code.

I've tried:
elliott@elliott-VirtualBox:~/go/src/elliott/hw$ llgo  hw.go -emit-llvm 
/tmp/llgo820448161.o: file not recognized: File format not recognised
collect2: error: ld returned 1 exit status
gllgo: error: exit status 1

Thanks,
Elliott

Andrew Wilkins

unread,
Sep 3, 2015, 5:01:26 AM9/3/15
to llgo...@googlegroups.com
llgo -c -emit-llvm hw.go
    (-c stops after compiling, does not attempt to link an executable)
You should end up with bitcode in a file called hw.o. You can call it hw.bc by adding "-o hw.bc"

If you want textual IR, substitute -S for -c, and you'll end up with test.s. Pass "-o -" to dump it to stdout.

Cheers,
Andrew

Thanks,
Elliott

Elliott Stoneham

unread,
Sep 3, 2015, 5:08:35 AM9/3/15
to llgo-dev
Many thanks Andrew, works a treat!

Reply all
Reply to author
Forward
0 new messages