# compiling freebsd



## zbsd (Mar 2, 2018)

11.1-RELEASE under a centos 6 host runing under kvm with kvm64 (6 cpu) 6GB memory. When building with buildworld or buildkernel no memory problem exist.

When building via `cd /usr/src/ && release.sh -c release.conf` I keep getting the same error:


```
release.conf

TARGET="amd64"
TARGET_ARCH="amd64"
KERNEL="GENERIC"
MAKE_CONF="/etc/make.conf"
###
cat /etc/make.conf
CC=clang
CXX=clang++
CPP=clang-cpp
###
SRCBRANCH="base/stable/11@rHEAD"
WORLD_FLAGS="-j6" # same as buildworld
KERNEL_FLAGS="-j6" # same as buildkernel
```


```
make[4]: "/usr/src/lib/libc/Makefile" line 70: Cannot open /usr/src/lib/libc//Makefile.inc
make[4]: "/usr/src/lib/libc/gen/Makefile.inc" line 167: warning: using previous script for "cancelpoints_sem_new.c" defined here
make[4]: Cannot allocate memory.
```
 
I have had this work only one time using `/usr/src/release/release.sh`. How can I diagnose the problem here? Any more info needed just ask.


----------



## SirDice (Mar 2, 2018)

I rarely use that script, I just enter a couple of commands by hand. You could try that, it'll probably be a bit clearer at what point it fails.

```
cd /usr/src
make buildworld buildkernel  # Add -j6 for example if you want to use more cores.
cd release
make -DNOPKG -DNODOC -DNOPORTS KERNCONF="GENERIC" release
make -DNOPKG -DNODOC -DNOPORTS KERNCONF="GENERIC" DESTDIR=/storage/release/11-stable install
```
The last command will create the FTP tree and 'installs' the built images to /storage/release/11-stable.


----------



## zbsd (Mar 4, 2018)

SirDice said:


> I rarely use that script, I just enter a couple of commands by hand. You could try that, it'll probably be a bit clearer at what point it fails.
> 
> ```
> cd /usr/src
> ...



What you posted above does work doing it that way. The difference is there is not chroot made. The problem I see is, that there is something wrong with how free bsd allocates memory or I just don't understand how it works under free bsd versus centos / pnalv. I see that zfs will load a whole file in memory and keep it their but can be limited to how much memory caching is done before paging to disk swap.

Maybe someone can educate me a bit more. I've looked at rctl and different loader.conf settings. Any ideas or education are welcome.


```
Under kvm64 6 cores allocated -j6 virtual machine

Virtual Memory:         (Total: 615344K Active: 610260K)
Real Memory:            (Total: 32136K Active: 31064K)
Shared Virtual Memory:  (Total: 14260K Active: 9388K)
Shared Real Memory:     (Total: 4128K Active: 3144K)
Free Memory:    64200K
 
hw.physmem: 6112M
hw.usermem: 5164M
hw.realmem: 6144M
 
 
Mem: 66M Active, 4846M Inact, 17M Laundry, 948M Wired, 590M Buf, 64M Free
Swap: 2560M Total, 2560M Free
 
procs  memory       page                    disks     faults         cpu
r b w  avm   fre   flt  re  pi  po    fr   sr vt0 cd0   in    sy    cs us sy id
1 0 0 592M   65M 12813   1   1   0 14011  246   0   0   47  9616  1108 40  8 52
###

core2duo with only 2 cores -j3 (real hardware)

Virtual Memory:         (Total: 509528K Active: 504312K)
Real Memory:            (Total: 38860K Active: 37700K)
Shared Virtual Memory:  (Total: 14368K Active: 9364K)
Shared Real Memory:     (Total: 6764K Active: 5692K)
Free Memory:    49804K
 
hw.physmem: 3921M
hw.usermem: 3193M
hw.realmem: 4096M
 
 
Mem: 124M Active, 2882M Inact, 16M Laundry, 728M Wired, 382M Buf, 50M Free
Swap: 4096M Total, 4096M Free
 
procs  memory       page                    disks     faults         cpu
r b w  avm   fre   flt  re  pi  po    fr   sr ad0 cd0   in    sy    cs us sy id
0 0 0 488M   50M 12199   2   4   0 13391  308   0   0  961  8985   866 72  5 23
 
Device          1K-blocks     Used    Avail Capacity
/dev/ada0p3       4194304       0B     4.0G     0%
```


----------



## zbsd (Mar 4, 2018)

Ohh I discovered it also uses memory disk during the install phase /dev/md0 .


----------

