Bug 242266 - CLang 6.0.1 (Part of the System 12.0) can not Build CLang 8.0.1 from the Port Collection
Summary: CLang 6.0.1 (Part of the System 12.0) can not Build CLang 8.0.1 from the Port...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: i386 Any
: --- Affects Only Me
Assignee: freebsd-toolchain (Nobody)
Depends on:
Reported: 2019-11-27 12:45 UTC by CrazyMihey
Modified: 2020-05-07 08:40 UTC (History)
2 users (show)

See Also:

Requested Files /tmp/AArch64InstPrinter-6bd737.cpp && /tmp/AArch64InstPrinter-6bd737.sh (679.37 KB, application/x-xz)
2019-11-27 12:45 UTC, CrazyMihey
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description CrazyMihey 2019-11-27 12:45:31 UTC
Created attachment 209478 [details]
Requested Files /tmp/AArch64InstPrinter-6bd737.cpp && /tmp/AArch64InstPrinter-6bd737.sh

It seems, CLang 6.0.1 (Part of the System 12.0) can not Build CLang 8.0.1 from the Port Collection.
The Error happened when Updating Ports in the System.
Preparations, Before the Error (Worked Ok):
time rm -rf /usr/ports/* /usr/ports/.[!.]* /var/db/portsnap/* /var/db/portsnap/.[!.]*
time portsnap fetch extract fetch update
time portmaster -B -d --no-confirm `whereis -s -q portmaster`
pkg --option AUTOCLEAN=Yes --option ASSUME_ALWAYS_YES=Yes delete "libXp"
time portmaster -B -v -d --no-confirm --delete-build-only --delete-packages -y --check-port-dbdir
time portmaster -y --check-depends

I think, some Ports need LLVM 8.0 for Building, so PortMaster will Build and Install LLVM 8.0, ignoring LLVM 6.0...

Next Command generated Error:
time portmaster -B -v -d --no-confirm --delete-build-only --delete-packages -a

[1396/4930] /usr/bin/c++  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/AArch64/InstPrinter -I/usr/p
orts/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64/InstPrinter -I/usr/ports/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64 -Ilib/Target/AArch64 -Iinclude -I/usr/ports/de
vel/llvm80/work/llvm-8.0.1.src/include -Ilib/Target/AArch64/InstPrinter/.. -I/usr/ports/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64/InstPrinter/.. -O2 -pipe -march=native -
O3 -pipe -march=native -DNDEBUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -march=native -O3 -pipe  -DNDEBUG -isystem /usr/local/include -fPIC -fvisi
bility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -
pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffu
nction-sections -fdata-sections -O2 -pipe -march=native -O3 -pipe -march=native -DNDEBUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -march=native -O3
 -pipe  -DNDEBUG -isystem /usr/local/include    -fno-exceptions -MD -MT lib/Target/AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o -MF lib/Target/
AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o.d -o lib/Target/AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o
-c /usr/ports/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64/InstPrinter/AArch64InstPrinter.cpp
FAILED: lib/Target/AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o
/usr/bin/c++  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/AArch64/InstPrinter -I/usr/ports/devel/l
lvm80/work/llvm-8.0.1.src/lib/Target/AArch64/InstPrinter -I/usr/ports/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64 -Ilib/Target/AArch64 -Iinclude -I/usr/ports/devel/llvm80/w
ork/llvm-8.0.1.src/include -Ilib/Target/AArch64/InstPrinter/.. -I/usr/ports/devel/llvm80/work/llvm-8.0.1.src/lib/Target/AArch64/InstPrinter/.. -O2 -pipe -march=native -O3 -pipe -ma
rch=native -DNDEBUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -march=native -O3 -pipe  -DNDEBUG -isystem /usr/local/include -fPIC -fvisibility-inlin
es-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wn
o-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-secti
ons -fdata-sections -O2 -pipe -march=native -O3 -pipe -march=native -DNDEBUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -march=native -O3 -pipe  -DND
EBUG -isystem /usr/local/include    -fno-exceptions -MD -MT lib/Target/AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o -MF lib/Target/AArch64/Inst
Printer/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o.d -o lib/Target/AArch64/InstPrinter/CMakeFiles/LLVMAArch64AsmPrinter.dir/AArch64InstPrinter.cpp.o -c /usr/port
c++: error: unable to execute command: Abort trap (core dumped)
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
Target: i386-unknown-freebsd12.0
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:

Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/AArch64InstPrinter-6bd737.cpp
c++: note: diagnostic msg: /tmp/AArch64InstPrinter-6bd737.sh
c++: note: diagnostic msg:

Comment 1 Brooks Davis freebsd_committer 2019-11-27 19:07:32 UTC
Official packages are currently built on 12.0 so I suspect a local issue.  Since you indicate that you are running on an i386 system it is likely that the compiler was killed by an out-of-memory or out-of-swap error.  Please check dmesg or your logs for errors related to c++.

As a workaround you might consider setting the BE_NATIVE option to disable the AArch64 backend.  It will also save you a bit of compile time.
Comment 2 CrazyMihey 2019-11-28 10:08:51 UTC
dmesg | grep --extended-regexp --ignore-case --colour=Auto "(CC|C\+\+|Memory|Swap)"
dmesg says «pid 54444 (c++), uid 0: exited on signal 6 (core dumped)», but unfortunately there is no Time specified.
«/var/log/messages» contains the same Message:
grep --extended-regexp --ignore-case --colour=Auto --bz2decompress "(CC|C\+\+|Memory|Swap)" /var/log/messages*
Nov 27 12:12:37 CrazyServer kernel: pid 54444 (c++), uid 0: exited on signal 6 (core dumped)
Nov 28 00:00:00 CrazyServer kernel: Accounting disabled
Nov 28 00:00:02 CrazyServer kernel: Accounting enabled

Does «signal 6» mean Out of Memory? Is It «SIGABRT», sent by Compiler to HimSelf? I did not find the Answer.

One more Thing: I had «CFLAGS+=-march=native -O3 -pipe» in «/etc/make.conf». Maybe it is the Reason. Now I added next Lines:
# Ошибка Сборки LLVM 8.0:	HTTP://Bugs.FreeBSD.Org/bugzilla/show_bug.cgi?id=242266
.if ( ${.CURDIR:M*/devel/llvm80*} )
  CFLAGS+=	-O2

and will Try again.
This Time «portmaster -B -v -d --no-confirm --delete-packages -a» worked perfectly, but I also excluded some «Heavy» Ports (actially, from FFMPEG dependants). PortMaster worked without Building of «GCC 9» and «LLVM 8». Global System UpGrade to 12.1 is planned later...

Machine has 2 GB of RAM and Top says: «Mem: 31M Active, 494M Inact, 288K Laundry, 528M Wired, 920M Free»; «Swap: 4096M Total, 16M Used, 4080M Free».

The «BE_NATIVE» Option appeared only in LLVM and Clang 8.0.0.r1, but FreeBSD 12.0 had 6.0.1 Version.

Thank You for Advices!

P.S. The worst part is that My Atom N270 does not support x64 OSes :).
Comment 3 Dimitry Andric freebsd_committer 2019-11-28 19:29:31 UTC
It looks like you are tickling some old bug in 6.0.1 which makes it use way too much memory for this particular compile command.  I tried on 12.0-RELEASE amd64 with a lot of RAM, and I got the following time(1) output:

       84.83 real        31.36 user        53.31 sys
   6560428  maximum resident set size
     40472  average shared memory size
      2587  average unshared data size
       255  average unshared stack size
   3201539  page reclaims
      1370  page faults
         0  swaps
      1379  block input operations
         5  block output operations
         0  messages sent
         0  messages received
         0  signals received
      1383  voluntary context switches
      1152  involuntary context switches

E.g, it needs 6.3 GiB of memory and more than a minute to compile.  This is obviously never going to work on i386, which can use up to 4 GiB of memory for user processes.

Compare this to clang 8.0.1 on recent stable/12:

       23.17 real        18.12 user         3.36 sys
    314944  maximum resident set size
     42981  average shared memory size
       358  average unshared data size
       253  average unshared stack size
     69152  page reclaims
      1090  page faults
         0  swaps
      1100  block input operations
         5  block output operations
         3  messages sent
         0  messages received
         0  signals received
      1105  voluntary context switches
       346  involuntary context switches

That needs only ~308 MiB of memory, and a little more than 20 seconds.

I'm unsure what will help here. You could try leaving out the -march=native stuff, or lowering the optimization level.  The former should be easy enough, but for the latter, I don't know how to achieve that with the port.

Another alternative is to do a binary upgrade to 12.1-R, and work from there.
Comment 4 CrazyMihey 2019-11-30 08:44:34 UTC
Ok, I got It.
Thank You very much for the Statistics 6.0.1 vs 8.0.1.
I will make a Clean Install of 12.1 in some Days (just have no Time for Full ReInstall).
Just for Fun: «Make BuildWorld» («-march=native -O3 -pipe» in Make.Conf) takes a bit more than 24 hours on this Book :)
Comment 5 CrazyMihey 2019-11-30 08:59:14 UTC
«-march=native» is very usefull for further Work and «-O3» makes a Good Profit on «i386» (even Simple Test with «UBench»), but actually No Profit on «AMD64». Maybe because all AMD64/EM64T CPUs can execute SSE2, but not all x86 can.