# fail to build lang/ghc



## hedgehog (Oct 6, 2013)

Hi everyone,

I'm trying to build lang/ghc during the process it eats all the memory and swap available and crashes. I have 3.5GB RAM and 1.5GB swap on that computer.

`uname -a`

```
FreeBSD vbox-freebsd64 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
```

Is there any way to decrease amount of RAM required to build it?


----------



## sk8harddiefast (Oct 6, 2013)

`pkg_add -r ghc`. This will install it as binary (already precompiled). No compile, no crash  When you say crash, `Virtualbox` restarts FreeBSD or you get a compile error? Also do you checked flags?
`cd /usr/ports/lang/ghc`
`make config`


----------



## ShelLuser (Oct 6, 2013)

Binary packages have their advantages, but also disadvantages. For example you'll lose control over the way you want your package to be set up.

@hedgehog; a lot depends on how you're trying to build this port. Do you use programs such as portmaster or did you simply issue a direct command like `# make build` (or `make install` of course)?

If you run such commands then keep in mind that you're building several ports. A port will have both build and run dependencies. Ports required for compiling and ports which are required for actually using the program.

I'd start by trying something like this (I'm assuming a default root environment, so using the C shell):


```
cd /usr/ports/devel/ghc
foreach a in (`make build-depends-list`)
  make -C $a install clean
end
```
After which you should try to build devel/ghc again. (using `# make install clean` or `# make build`).

It's just an educated guess mind you, but I could imagine that memory usage is different when you're compiling several programs in one session versus compiling programs on an individual basis.

Hope this can help.


----------



## hedgehog (Oct 7, 2013)

Sorry, forgot to mention that I build everything using ports-mgmt/poudriere with custom options and PERL 5.18, so pre-compiled package is not an option for me. Here is compile log:

```
84% ( 31 / 37) in 'LlvmCodeGen.Base'
  75% (  3 /  4) in 'LlvmCodeGen.Data'
 100% (  6 /  6) in 'LlvmCodeGen.Ppr'
 100% (  2 /  2) in 'LlvmMangler'
 100% (  2 /  2) in 'LlvmCodeGen.CodeGen'
 100% (  3 /  3) in 'LlvmCodeGen'
  90% ( 19 / 21) in 'CgExtCode'
  11% (  2 / 19) in 'CgProf'
   0% (  0 / 26) in 'CgTicky'
   5% (  1 / 20) in 'CgStackery'
   9% (  1 / 11) in 'CgCallConv'
   0% (  0 /  6) in 'CgParallel'
   0% (  0 / 22) in 'CgHeapery'
   0% (  0 / 11) in 'ByteCodeItbls'
   0% (  0 /  5) in 'ByteCodeInstr'
   8% (  1 / 12) in 'ByteCodeAsm'
  62% (105 /170) in 'HscTypesgmake[1]: *** [compiler/stage2/doc/html/ghc/ghc.haddock] Killed: 9
gmake: *** [all] Error 2
*** [do-build] Error code 1

Stop in /usr/ports/lang/ghc.
===>  Cleaning for ghc-7.6.3
```


```
$ dmesg | tail
swap_pager: out of swap space
swap_pager_getswapspace(16): failed
pid 97480 (haddock), uid 0, was killed: out of swap space
pid 715 (sendmail), uid 0, was killed: out of swap space
swap_pager: out of swap space
swap_pager_getswapspace(16): failed
pid 6988 (haddock), uid 0, was killed: out of swap space
swap_pager: out of swap space
swap_pager_getswapspace(16): failed
pid 2450 (haddock), uid 0, was killed: out of swap space
```
I don't think I need documentations so I'm going to try building ghc without docs.


----------



## cpm@ (Oct 7, 2013)

Well, your system ran out of VM. So you should create a swapfile to have much more VM, then try to install again lang/ghc.

Follow this link for instructions: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/adding-swap-space.html.


----------



## hedgehog (Oct 7, 2013)

cpu82 said:
			
		

> Well, your system ran out of VM. So you should create a swapfile to have much more VM, then try to install again lang/ghc.
> 
> Follow this link for instructions: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/adding-swap-space.html.



Awesome, thank you. I might need that for future, for building something like editors/openoffice. But for now the current amount of RAM+swap was enough to build lang/ghc without documentations.

Thanks everyone for responses!


----------

