Page MenuHomeFreeBSD

Opportunistically skip building a cross-compiler with SMART_CROSS_COMPILER set.
ClosedPublic

Authored by bdrewery on May 13 2016, 8:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 21, 4:28 AM
Unknown Object (File)
Fri, Mar 15, 5:05 AM
Unknown Object (File)
Feb 23 2024, 10:45 PM
Unknown Object (File)
Jan 9 2024, 7:27 AM
Unknown Object (File)
Jan 5 2024, 6:17 PM
Unknown Object (File)
Jan 2 2024, 8:23 PM
Unknown Object (File)
Dec 23 2023, 3:31 AM
Unknown Object (File)
Dec 10 2023, 4:47 PM
Subscribers
Tokens
"Yellow Medal" token, awarded by bdrewery.

Details

Summary

This will still build the compiler for the target but will not build the
bootstrap cross-compiler in the cross-tools phase. Other toolchain
bootstrapping, such as elftoolchan an binutils, currently still occurs.

This is planned to be on-by-default eventually.

This will utilize the __FreeBSD_cc_version compiler macro defined in the
source tree and compare it to CC's version. If they match then the
cross-compiler is skipped. If [X]CC is an external compiler (absolute
path) or WITHOUT_CROSS_COMPILER is already set, then this logic is skipped.
If the expected bootstrap compiler type no longer matches the found CC
compiler type (clang vs gcc), then the logic is skipped. As an extra
safety check the version number is also compared from the compiler to
the tree version.

Clang:

The macro FREEBSD_CC_VERSION is defined in:
  lib/clang/include/clang/Basic/Version.inc
For clang -target will be used if TARGET_ARCH != MACHINE_ARCH.  This
is from the current external toolchain logic.  There is currently an
assumption that the host compiler can build the TARGET_ARCH.  This
will usually be the case since we don't conditionalize target arch
support in clang, but it will break when introducing new
architectures.  This problem is mitigated by incrementing the version
when adding new architectures.

GCC:

The macro FBSD_CC_VER is defined in:
  gnu/usr.bin/cc/cc_tools/freebsd-native.h
For GCC there is no simple -target support when TARGET_ARCH !=
MACHINE_ARCH.  In this case the opportunistic skip is not done.  If we
add proper support for this case in external toolchain logic then it
will be fine to enable.

This relies on the macros being incremented whenever any change occurs
to these compilers that warrant rebuilding files. It also should never
repeat earlier values.

Sponsored by: EMC / Isilon Storage Division

This also depends on http://reviews.llvm.org/D20037
and a change such as this:

diff --git lib/clang/include/clang/Basic/Version.inc lib/clang/include/clang/Basic/Version.inc
index 94dc282..373cdb4 100644
--- lib/clang/include/clang/Basic/Version.inc
+++ lib/clang/include/clang/Basic/Version.inc
@@ -8,3 +8,5 @@
 #define        CLANG_VENDOR                    "FreeBSD "

 #define        SVN_REVISION                    "262564"
+
+#define FREEBSD_CC_VERSION             1100001U

Here is a ministat as well (no ccache and clean build on all 6 builds):

x before
+ after
+--------------------------------------------------------------------------+
|  +                                                                      x|
|+ +                                                                      x|
||AM|                                                                     A|
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3          2966          2968          2966     2966.6667     1.1547005
+   3          2300          2319          2318     2312.3333     10.692677
Difference at 95.0% confidence
        -654.333 +/- 17.2371
        -22.0562% +/- 0.581024%
        (Student's t, pooled s = 7.60482)
Test Plan

Tested having the same revision, skipped.
Testing having a different revision, did not skip.
Tested same revision with universe and had this glorious result:

~/git/freebsd # grep SMART _*.buildworld
_.amd64.amd64.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.arm.arm.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.arm.armeb.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.arm.armv6.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.arm.armv6hf.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.i386.i386.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.
_.pc98.i386.buildworld:make[2]: "/root/git/freebsd/Makefile.inc1" line 144: SMART_CROSS_COMPILER: Determined that CC=/usr/local/bin/ccache cc matches the source tree.  Not bootstrapping a cross-compiler.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bdrewery retitled this revision from to Opportunistically skip building a cross-compiler with SMART_CROSS_COMPILER set..
bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
bdrewery added reviewers: bapt, imp, brooks, emaste, dim.
bdrewery added a subscriber: jhb.

I am going to post to toolchain@ about this shortly.

bdrewery updated this object.
bdrewery edited the test plan for this revision. (Show Details)
brooks edited edge metadata.
This revision is now accepted and ready to land.May 14 2016, 3:55 AM
bapt edited edge metadata.

Damn, this breaks installworld. Just needs a few tweaks to fix.

imp edited edge metadata.
This revision was automatically updated to reflect the committed changes.