The compiler works great, there are 4 cores available, but if I use all 4 of them, invariably the memory runs out. Aside from uninstalling as many services as possible, compiling with a cross-compiler and skipping on the GUI/IDE, what can one do?
It appears my problems were power-supply related. A 5V/3A power supply solved the reset problem when the cores started burning too much power. ZRAM solved the lockup problem when memory ran out (but you need to be sure to supply enough, that is, around 100M, /tmp space). I am actually impressed with the compilation speed now. The zram approach is the way to go, but also mount /tmp as tmpfs with at least 100M space and disable/uninstall as many services as you can. Doing this allows me to use all 4 cores for compilation without crashes and resets. It also saves my SD card, since the temporary files will not be written to SD, but into memory. I'd also advise to add some cooling to the Pi. I have placed some heat sinks on the Pi chips, but it does not appear to be enough at times. Also, you should hack around the ext4 a little (like turn on writeback and discard options).
max_usb_current=1 gpu_mem=16 dtoverlay=pi3-disable-bt hdmi_blanking=1 avoid_warnings=2
total used free shared buff/cache available Mem: 976M 25M 896M 6.4M 54M 897M Swap: 976M 0B 976M
Startup finished in 2.754s (kernel) + 3.853s (userspace) = 6.607s
tune2fs 1.43.4 (31-Jan-2017) Filesystem volume name: rootfs Last mounted on: / Filesystem UUID: fd695ef5-f047-44bd-b159-2a78c53af20a Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file dir_nlink extra_isize Filesystem flags: signed_directory_hash **Default mount options: journal_data_writeback discard** Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 1889056 Block count: 7802880 Reserved block count: 315875 Free blocks: 7406202 Free inodes: 1849110 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 106 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 7904 Inode blocks per group: 494 Flex block group size: 16 Filesystem created: Wed Jun 27 03:08:02 2018 Last mount time: Thu Nov 3 18:16:43 2016 Last write time: Thu Nov 3 18:16:42 2016 Mount count: 261 Maximum mount count: -1 Last checked: Thu Nov 3 18:16:44 2016 Check interval: 0 (<none>) Lifetime writes: 12 GB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 32 Desired extra isize: 32 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: 7c83a135-91d4-411c-9e7e-0c08c37476d1 Journal backup: inode blocks
proc /proc proc defaults 0 0 PARTUUID=9cde2d98-01 /boot vfat defaults,noatime 0 2 PARTUUID=9cde2d98-02 / ext4 defaults,noatime,commit=60 0 1 tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0