C++ A buildworld stopped at some point : will it restart from the beginning again ? I don't want it.

Hello.

I'm trying to upgrade FreeBSD 13.2 to 15.0 for armv7 and I've started the compilation of the world directly on the Chromebook. Unfortunately the memory was not enough and at some point the compilation stopped :

Code:
mario@freebsd:/usr/freebsd-src # make KERNCONF=GENERIC TARGET=arm TARGET_ARCH=armv7 buildworld

-DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -std=c++14 -Wno-deprecated-copy   -Wno-error=inconsistent-missing-override -Wno-error=missing-variable-declarations -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-c++11-extensions   -c /usr/freebsd-src/contrib/googletest/googlemock/test/gmock-actions_test.cc -o gmock-actions_test.o
Feb  4 11:49:31 freebsd syslogd: last message repeated 6 times
Feb  4 11:49:59 freebsd kernel: pid 57620 (clang), jid 0, uid 0, was killed: failed to reclaim memory
*** Signal 9

I would like to know what happens when I restart the compilation. I mean,I don't want that when it restarts,it makes a "make clean" and it removes all the files already compiled. If this will happens,I would like to know how to remove the part of the script that wants to do that. I want to restart the compilation exactly from the point where it stopped.
 
make -DWITHOUT_CLEAN -DNO_KERNELCLEAN buildworld buildkernel
will restart the build where it left off. Without the two -D options it will rm -rf /usr/obj and start from scratch.
 
Can I ask another little help ? something like this : when the compilation stops with the error string "failed to reclaim memory",wait 10 seconds and then restart it,issuing the proper command : "make -DWITHOUT_CLEAN -DNO_KERNELCLEAN buildworld buildkernel". A script like this will require months for me to be completed,while for you only some minutes. Please understand it. Very thanks.
 
Can I ask another little help ? something like this : when the compilation stops with the error string "failed to reclaim memory",wait 10 seconds and then restart it,issuing the proper command : "make -DWITHOUT_CLEAN -DNO_KERNELCLEAN buildworld buildkernel". A script like this will require months for me to be completed,while for you only some minutes. Please understand it. Very thanks.
That's OOM. Your machine ran out of virtual memory (RAM + swap). Add more swap.
 
However you might want to do it. Expand a partition, add a swap file, add a swap volume (in ZFS). You can add it to fstab permanently or you can swapon(8) some temporary space.

I temporarily add swap to one of my zpools as needed using the following script on my laptop. Then, swapon /dev/zvol/<my extra zpool>/SWAPVOL on my laptop. For my servers downstairs the swap is multiple partitions and/or a zvol added to fstab.

Code:
#!/bin/sh -

# -b 4096 \
zfs create -b 16384 \
    -o org.freebsd:swap=on \
    -o checksum=off \
    -o primarycache=metadata \
    -o compress=off \
    -o dedup=off \
    -o sync=disabled \
    -o snapshot_limit=0 \
    -V $2 $1/SWAPVOL

Your choice how you want to add swap.
 
The largest consumer of RAM during the build is during the build of llvm. It also consumes the most build time.
 
I have created the swap file called swap0 :

Code:
# dd if=/dev/zero of=/mnt/zroot-swap/swap0 bs=1m count=100000
# chmod 0600 /mnt/zroot-swap/swap0

I put the fusefs module on the loader.conf :

Code:
# nano /boot/loader.conf :
fusefs_load="YES"

now,what could be the problem that could arise ? that I need to store the swap0 file inside an USB disk that I have "formatted" using ZFS,but with a zpool directory that I "mount" later,manually,when FreeBSD is fully loaded,using sshfs with this command :

Code:
sshfs -o Compression=no -o allow_root -o transform_symlinks root@192.168.1.3:/mnt/zroot-swap /mnt/zroot-swap

Now the problem is that when the file fstab is read,it does not find the swap0 file....,so I need to find the way to mount the zpool directory using sshfs directly on the fstab file,that could be something like this,even if I'm not sure at all :



Code:
md99                               none             swap        sw,file=/mnt/zroot-swap/swap0,late    0    0
root@192.168.1.3:/mnt/zroot-swap   /mnt/zroot-swap  fuse.sshfs  defaults                              0    0

my doubt is that the sshfs mount will not work because I'm not able to disable the password :

Code:
# ssh-keygen
# ssh-keygen -t rsa
# ssh-keygen -t rsa -b 4096 -f ~/.ssh/chiave.key
# sshfs root@192.168.1.3:/mnt/zroot-swap /mnt/zroot-swap -o IdentityFile=/root/.ssh/chiave.key.pub

root@192.168.1.3's password:

it shouldn't ask for the password,right ? Unfortunately it asks it,so I think that it does not work as expected.

This solution :

What you need to do is specify which private key to use in the ~/.ssh/config file. for example:
Host server1.nixcraft.com
IdentityFile ~/backups/.ssh/id_dsa
Host server2.nixcraft.com
IdentityFile /backup/home/userName/.ssh/id_rsa

from here : https://unix.stackexchange.com/questions/61567/how-to-specify-key-in-sshfs

it does not work :

Code:
nano /root/.ssh/config
Host 192.168.1.3
IdentityFile /root/.ssh/id_rsa

# sshfs root@192.168.1.3:/mnt/zroot-swap /mnt/zroot-swap -o IdentityFile=/root/.ssh/id_rsa

root@192.168.1.3's password:

Anyway,I see that the IdentityFile is declared in a different config file :

Code:
root@freebsd:/etc/ssh # nano ssh_config

#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa         
#   IdentityFile ~/.ssh/id_ed25519

Sources :

http://man.hubwiz.com/docset/FreeBSD_Hand.docset/Contents/Resources/Documents/adding-swap-space.html

https://unixcop.com/mount-a-remote-folder-with-sshfs/

https://www.cyberciti.biz/faq/freebsd-setting-up-public-key-password-less-ssh-login/
 
Last edited:
Back
Top