Bug 253785 - make buildworld fails compiling llvm: cpp killed "PLEASE submit a bug report to"
Summary: make buildworld fails compiling llvm: cpp killed "PLEASE submit a bug report to"
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 12.2-RELEASE
Hardware: arm64 Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-23 04:26 UTC by Jouni Laakso
Modified: 2021-02-27 11:28 UTC (History)
3 users (show)

See Also:


Attachments
/tmp/PassBuilder-2f2b98.sh (5.56 KB, application/x-shellscript)
2021-02-23 04:43 UTC, Jouni Laakso
no flags Details
truncated /tmp/PassBuilder.cpp (912.11 KB, application/zip)
2021-02-23 04:46 UTC, Jouni Laakso
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jouni Laakso 2021-02-23 04:26:15 UTC
make buildworld fails at llvm:
make -j4 buildworld 2>&1 >> logfile.log

The last lines of syslog is attached. The cpp had been quit as if swapspace had run out.

As in the stack trace, preprocessed files are as a 1,9 kB attachment. 

Attachments 1 zip file, stacktrace below, /var/log/message after this one, device info (memory and processor).

 ----- clip ------

Stacktrace:

...
--- ProfileData/SampleProfWriter.o ---
c++  -O2 -pipe -fno-common -I/usr/obj/usr/src/arm64.aarch64/tmp/obj-tools/lib/clang/libllvm -I/usr/src/contrib/llvm-project/llvm/lib/Target/AArch64 -I/usr/src/contrib/llvm-project/llvm/lib/Target/ARM -I/usr/src/lib/clang/include -I/usr/src/contrib/llvm-project/llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_VCS_VERSION_INC -DNDEBUG -DLLVM_DEFAULT_TARGET_TRIPLE=\"aarch64-unknown-freebsd12.2\" -DLLVM_HOST_TRIPLE=\"aarch64-unknown-freebsd12.2\" -DDEFAULT_SYSROOT=\"/usr/obj/usr/src/arm64.aarch64/tmp\" -DLLVM_TARGET_ENABLE_AARCH64 -DLLVM_TARGET_ENABLE_ARM -DLLVM_NATIVE_ASMPARSER=LLVMInitializeAArch64AsmParser -DLLVM_NATIVE_ASMPRINTER=LLVMInitializeAArch64AsmPrinter -DLLVM_NATIVE_DISASSEMBLER=LLVMInitializeAArch64Disassembler -DLLVM_NATIVE_TARGET=LLVMInitializeAArch64Target -DLLVM_NATIVE_TARGETINFO=LLVMInitializeAArch64TargetInfo -DLLVM_NATIVE_TARGETMC=LLVMInitializeAArch64TargetMC -ffunction-sections -fdata-sections -gline-tables-only -MD -MF.depend.ProfileData_SampleProfW--- ProfileData/SampleProf.o ---
c++  -O2 -pipe -fno-common -I/usr/obj/usr/src/arm64.aarch64/tmp/obj-tools/lib/clang/libllvm -I/usr/src/contrib/llvm-project/llvm/lib/Target/AArch64 -I/usr/src/contrib/llvm-project/llvm/lib/Target/ARM -I/usr/src/lib/clang/include -I/usr/src/contrib/llvm-project/llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_VCS_VERSION_INC -DNDEBUG -DLLVM_DEFAULT_TARGET_TRIPLE=\"aarch64-unknown-freebsd12.2\" -DLLVM_HOST_TRIPLE=\"aarch64-unknown-freebsd12.2\" -DDEFAULT_SYSROOT=\"/usr/obj/usr/src/arm64.aarch64/tmp\" -DLLVM_TARGET_ENABLE_AARCH64 -DLLVM_TARGET_ENABLE_ARM -DLLVM_NATIVE_ASMPARSER=LLVMInitializeAArch64AsmParser -DLLVM_NATIVE_ASMPRINTER=LLVMInitializeAArch64AsmPrinter -DLLVM_NATIVE_DISASSEMBLER=LLVMInitializeAArch64Disassembler -DLLVM_NATIVE_TARGET=LLVMInitializeAArch64Target -DLLVM_NATIVE_TARGETINFO=LLVMInitializeAArch64TargetInfo -DLLVM_NATIVE_TARGETMC=LLVMInitializeAArch64TargetMC -ffunction-sections -fdata-sections -gline-tables-only -MD -MF.depend.ProfileData_SampleProf.--- ProfileData/SampleProfWriter.o ---
riter.o -MTProfileData/SampleProfWriter.o -Qunused-arguments -I/usr/obj/usr/src/arm64.aarch64/tmp/legacy/usr/include  -fno-exceptions -fno-rtti -gline-tables-only -std=c++14 -stdlib=libc++ -Wno-c++11-extensions  -c /usr/src/contrib/llvm-project/llvm/lib/ProfileData/SampleProfWriter.cpp -o ProfileData/SampleProfWriter.o
--- ProfileData/SampleProf.o ---
o -MTProfileData/SampleProf.o -Qunused-arguments -I/usr/obj/usr/src/arm64.aarch64/tmp/legacy/usr/include  -fno-exceptions -fno-rtti -gline-tables-only -std=c++14 -stdlib=libc++ -Wno-c++11-extensions  -c /usr/src/contrib/llvm-project/llvm/lib/ProfileData/SampleProf.cpp -o ProfileData/SampleProf.o
--- Passes/PassBuilder.o ---
c++: error: unable to execute command: Killed
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: aarch64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin
c++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
c++: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/PassBuilder-2f2b98.cpp
c++: note: diagnostic msg: /tmp/PassBuilder-2f2b98.sh
c++: note: diagnostic msg: 

********************
*** [Passes/PassBuilder.o] Error code 254

make[4]: stopped in /usr/src/lib/clang/libllvm
1 error

make[4]: stopped in /usr/src/lib/clang/libllvm
*** [all_subdir_lib/clang/libllvm] Error code 2

make[3]: stopped in /usr/src/lib/clang
1 error

make[3]: stopped in /usr/src/lib/clang
*** [cross-tools] Error code 2

make[2]: stopped in /usr/src
1 error

make[2]: stopped in /usr/src
*** [_cross-tools] Error code 2

make[1]: stopped in /usr/src
1 error

make[1]: stopped in /usr/src
*** [buildworld] Error code 2

make: stopped in /usr/src

make: stopped in /usr/src

 ----- clip ------

/var/log/messages
Feb 12 09:19:55 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 104774, size: 16384
Feb 12 09:20:02 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 103899, size: 8192
Feb 12 10:39:10 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 311358, size: 20480
Feb 12 10:39:16 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 322016, size: 12288
Feb 12 10:39:51 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 312151, size: 20480
Feb 12 10:40:00 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 318352, size: 24576
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 312153, size: 12288
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 306846, size: 4096
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 338655, size: 16384
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 312153, size: 12288
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 306846, size: 4096
Feb 12 10:40:46 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 338655, size: 16384
Feb 12 10:42:42 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 368951, size: 8192
Feb 12 10:42:42 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 370388, size: 28672
Feb 12 10:42:42 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 74382, size: 12288
Feb 12 10:43:05 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 370430, size: 24576
Feb 12 10:43:05 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 392003, size: 4096
Feb 12 10:46:30 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 438266, size: 12288
Feb 12 10:46:31 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 436240, size: 24576
Feb 12 10:46:31 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 428683, size: 4096
Feb 12 11:11:13 myhost kernel: pid 23787 (c++), jid 0, uid 0, was killed: out of swap space
Feb 12 11:11:35 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 1025, size: 24576
Feb 12 11:11:35 myhost kernel: swap_pager: indefinite wait buffer: bufobj: 0, blkno: 468510, size: 28672


# swapinfo 
Device          1K-blocks     Used    Avail Capacity
/dev/mmcsd0p5     3028972    30572  2998400     1%

 ----- clip ------

Device:
arm64 processor A53, 1 GB memory 3 GB swapspace.
Comment 1 Jouni Laakso 2021-02-23 04:43:41 UTC
Created attachment 222742 [details]
/tmp/PassBuilder-2f2b98.sh

PassBuilder-2f2b98.sh
Comment 2 Jouni Laakso 2021-02-23 04:46:19 UTC
Created attachment 222743 [details]
truncated /tmp/PassBuilder.cpp

Comments removed and finally truncated using command "head". Zipped. File was 10 MB, zipped 1,9 MB. File size limit 1000 kB is too low.
Comment 3 Mark Millard 2021-02-23 06:50:00 UTC
Unfortuantely, "swapinfo" after the process-kill does not report
the swap usage from just before the process-kill.

The message with "was killed: out of swap space" is commonly a
misnomer: other things can cause the kills but the same message
is output for such. If you had actually run out of swap space
there should be one or more messages that would have text
something like:

swap_pager_getswapspace(??): failed

The 4 causes of kills that I know of are:

Sustained low free RAM (via stays-runnable processes).
A sufficiently delayed pageout.
The swap blk uma zone was exhausted.
The swap pctrie uma zone was exhausted.

Your "indefinite wait buffer" messages suggest the 2nd
may be involved in addition to the 1st of those 4.

There are tunables for those 2 that make them not
trip as soon for the 1st or ever for the 2nd
( /etc/sys.conf content or sysctl assignments ):

#
# Delay when persistent low free RAM leads to
# Out Of Memory killing of processes. The
# delay is a count of kernel-attempts to gain
# free RAM (so not time units).
vm.pageout_oom_seq=120

(The default is 12 as far as I know.)

#
# For plunty of swap/paging space (will not
# run out), avoid pageout delays leading to
# Out Of Memory killing of processes:
vm.pfault_oom_attempts=-1

I expect that 12.2-RELEASE has both of those
available but I've not been using 12.x .
Comment 4 Daniel Engberg freebsd_committer freebsd_triage 2021-02-24 06:14:16 UTC
Hi Jouni,

Unforunately 1Gb of RAM is way too little to build world (FreeBSD) using 4 workers. LLVM/Clang will at some stages use around ~800Mbyte per job which will push about 3x of the available amount of RAM to swap. This doesn't necessarily mean that it'll run out of memory but if you have a fairly slow storage device (SD card, USB memory and even a mechanical HDD to some extent) you'll get so slow access that it'll spend minutes trying shuffle data back and forth between main memory and swap which eventually will lead to the kernel killing processes to restore performance and lower memory pressure.

Now, if you want to run buildworld on your device which I wouldn't recommend with only 1Gb of RAM you can at best use 2 jobs (-j2 but I would recommend -j1) but be aware of excess swapping at some stages and it's going to be very slow. Unless you have a beefier device at hand I'd recommend cross-compiling but I'm not aware of any easy way upgrading a system going that route.

Additionally if you're using the official image(s) you'll need to modify /etc/fstab and increase and/or remove the limit of tmpfs otherwise make installworld will fail.
Comment 5 Mark Millard 2021-02-24 08:12:09 UTC
(In reply to daniel.engberg.lists from comment #4)

I agree in general that for the context -j2 or -j1 would
likely be better, especially for trying to use microsd
cards for the file system and swap/paging space.

But, I've tried a 1 GiByte aarch64 FreeBSD context for
a -j4 buildworld buildkernel in the past and had it
work (because of appropriate configuration). . .

I had a RPi3 that was based on head -r358966 do a
build world buildkernel of the same version, from
scratch, -j4 style. The RPi3 is a 1 GiByte RAM
context. I had 3072 GiBytes for the swap partition.
That and the ufs file system, were on a USB SSD,
not the microsd card. (No ZFS involved. No memory
based /tmp involved: generally avoiding such
competition for memory vs. the compiler and linker
and the like.)

The build completed without any /var/log/message or
console output during the build. My modified version
of top reported (details copied from a ssh window) . . .

For Mem: 738512Ki MaxObsActive, 190608Ki MaxObsWired, 906372Ki MaxObs(Act+Wir)
For Swap:  1927Mi MaxObsUsed

(top was started before the build. "MaxObs" is short
for "Maximum Observed".)

The build took a few minutes under 31 hrs.

The build used (my PINE64 media are also set up
to boot the RPi3, explaining some naming):

vm.pageout_oom_seq=120
vm.pfault_oom_attempts=-1
vfs.root.mountfrom="ufs:/dev/gpt/PINE642Groot"
dumpdev="/dev/gpt/PINE642Gswp2"
/dev/gpt/PINE642Groot           /               ufs rw,noatime          1 1
/dev/gpt/PINE642Gswap           none            swap sw                 0 0

(So this avoided the microsd card for ufs and
for swap/page space.)

Overall, it looks like having more than 2 GiBytes
of swap partition is appropriate for -j4 : 1927
MiByte is not much less than 2048 MiByte.

But, with appropriate configuration anyway, the
RPi3 can do buildworld buildkernel for head 13,
even -j4 style.

That was aarch64 FreeBSD. armv7 FreeBSD style with
1 GiByte RAM does not allow as much swap/page space
without complaining at boot. It does not appear that
such a -j4 build would be appropriate under armv7
FreeBSD. (As I remember, I've done a -j2 build on
armv7 that worked well but I'd have to look up the
details.)
Comment 6 Jouni Laakso 2021-02-27 10:38:16 UTC
Thank you for the really specific explanation. It was nice to read it. Another similar bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214299 . The processor was specified as two cores aarch64, URL: http://espressobin.net/tech-spec/ .

The -j1 option stopped as in attachment 1 [details]. The swap space was increased to 11 GB total before the run. The -j2 right after this run stopped similarly as the -j4. The first run took multiple days (a full 3-4 days) and the USB console was helpful. I'm reading the settings in the comments today. The version was 12.2-RELEASE (at svn revision 369333) and a binary distribution exists. It could be easier to install it and update it later. Only the kernel would be compiled. It is possible to use a full day to read more about the build.

The -j1 stopped in error code 137 at 'all_subdir_lib'.

Attachment 1 [details], build log
----- clip -----
echo gmock-matchers_test.full: /usr/obj/usr/src/arm64.aarch64/tmp/usr/lib/libc++.a >> .depend.gmock-matchers_test
c++  -target aarch64-unknown-freebsd12.2 --sysroot=/usr/obj/usr/src/arm64.aarch64/tmp -B/usr/obj/usr/src/arm64.aarch64/tmp/usr/bin  -O2 -pipe -fno-common -g -MD -MF.depend.gmock-matchers_test.gmock-matchers_test.o -MTgmock-matchers_test.o -fstack-protector-strong -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls -Wmissing-variable-declarations -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments  -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private  -I/usr/src/contrib/googletest/googlemock/include -I/usr/src/contrib/googletest/googlemock -I/usr/src/contrib/googletest/googletest/include -I/usr/src/contrib/googletest/googletest -I/usr/obj/usr/src/arm64.aarch64/tmp/usr/include/private -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -DGTEST_HAS_POSIX_RE=1 -DGTEST_HAS_PTHREAD=1 -DGTEST_HAS_STREAM_REDIRECTION=1 -frtti -Wno-deprecated-copy -Wno-signed-unsigned-wchar -std=c++11 -Wno-deprecated-declarations   -Wno-c++11-extensions  -c /usr/src/contrib/googletest/googlemock/test/gmock-matchers_test.cc -o gmock-matchers_test.o
/usr/src/contrib/googletest/googlemock/test/gmock-matchers_test.cc:1028:8: warning: private field 'c_' is not used [-Wunused-private-field]
  char c_;
       ^
Killed
*** [all_subdir_lib] Error code 137

make[2]: stopped in /usr/src
1 error

make[2]: stopped in /usr/src
*** [everything] Error code 2

make[1]: stopped in /usr/src
1 error

make[1]: stopped in /usr/src
*** [buildworld] Error code 2

make: stopped in /usr/src

make: stopped in /usr/src
Comment 7 Jouni Laakso 2021-02-27 10:59:29 UTC
SD-card was HD-quality (almost the fastest).
Comment 8 Mark Millard 2021-02-27 11:11:18 UTC
(In reply to Jouni Laakso from comment #6)

I'll note that there are tradeoffs where one can have
too much swap: there is kernel memory use involved in
keeping track of the paging/swapping and it completes
with other kernel memory use.

If you got a boot message of the form:

warning: total configured swap (??? pages) exceeds maximum recommended amount (??? pages).

then you may have had such problems. There are also
warnings in the documentation about causing tradeoffs
if kern.maxswzone is increased (less space for other
kernel information). (See "man 8 loader" and its
kern.maxswzone description, although the "eight times"
material does not seem to be correct for arm64. Also
the wording presumes decreasing kern.maxswzone in
order to make more room for other things. Making less
room has to be inferred for increases.)

On arm64, an 11 GiByte swap space would need a fair
amount of RAM to avoid getting the warning.
Comment 9 Mark Millard 2021-02-27 11:28:53 UTC
(In reply to Jouni Laakso from comment #6)

See:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241848

about issues with compiling gmock-matchers_test.cc . It
turns out that clang with -O2 uses a huge amount of
memory and time for that file (but does not for -O use).

Things were changed to use -O in HEAD -r367101 ( main
433f33d285eee7c ) but it was not MFC'd to stable/12 .

If you locally make a similar change, you likely can get
gmock-matchers_test.cc to build.