Bug 205787 - Can't compile freebsd srcs (/usr/src) with clang/llvm 3.8 and option -march=haswell
Summary: Can't compile freebsd srcs (/usr/src) with clang/llvm 3.8 and option -march=h...
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-01 18:27 UTC by Leo
Modified: 2021-01-16 21:19 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo 2016-01-01 18:27:36 UTC
My computer has the "haswell" processor (a version of Intel i7), the clang version that ships with FreeBSD has no knowledge of my processor, only the "generic" i7, so I installed the clang/llvm 3.8, as it has knowledge of my processor.

Trying to compile the source code installed with Freebsd 10.2 CD (src.txz, make buildworld), using the clang 8.0 (and option -march=haswell) resulted in a lot of "warnings as errors", switched back to 3.4.1 (and option -march=corei7) and all done.

So there is new "checks" made by the 3.8 compiler that isn't compatible with some included sources in the /usr/src.

Some I tryed to "repair": openpam, libz (zip lib), "jail lib", then I stopped.

The problem is the option to treat warnings as errors, for example, in jail lib clang 3.4.1 accepts to assign a string of char (char[5] like "aaaa") to *(const **)&, but 3.8 refuses.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2016-01-04 02:56:12 UTC
Building 10.2 with Clang 3.8 isn't supported, but perhaps you can compile with NO_WERROR?
Comment 2 Leo 2016-01-08 22:29:41 UTC
(In reply to Ed Maste from comment #1)

Hello, adding -DNO_WERROR option to make is ok, but then it stops at /usr/src/sys/boot/i386/boot2

The error is:

===> sys/boot/i386/boot2 (all)
--- boot2 ---
-265 bytes available
*** [boot2] Error code 1

If I compile with the default clang version that comes with Freebsd 10 (3.4.1), even  if I modify the CFLAGS/CXXFLAGS (-O3 -march=corei7 -fomit-frame-pointer), all goes well, but if I try to compile with clang 3.6 (/usr/ports/lang/clang36), clang 3.7 and clang 3.8 (clang-devel), then this error appears, with variable "-[X] bytes available" error message.
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2016-01-08 22:43:19 UTC
CCing dim@
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2016-01-08 23:15:32 UTC
Without any further information, I'm guessing that your bsd.compiler.mk does not detect the compiler version properly, and that incorrect flags are being used to compile boot2.  (The whole sys/boot area is very sensitive to the exact optimization flags, it will almost always grow too large if they aren't correct.)

Can you provide a log of the commands being used to compile everything under /usr/src/sys/boot?  For example, by running "make clean" in there, and then running make as usual, but redirected to a log file.

I'm also interested in the COMPILER_TYPE and COMPILER_VERSION detected by your version of the build system.  E.g. in /usr/src, run:

make -V COMPILER_TYPE -V COMPILER_VERSION

and paste the output here.

Having said all that, I think you will run into multiple problems that will be pretty tricky to solve, if you continue this way.  10.2-RELEASE is completely frozen, and misses a lot of important fixes and updates which are in 10-STABLE, making the task even more difficult.

Therefore, I think it is wisest to abandon this attempt.  You will most likely not gain any significant performance advantage by compiling with -march=haswell, as opposed to e.g. -march=corei7.