Bug 240507 - WITHOUT_CLANG=yes WITH_CLANG_BOOTSTRAP=yes does not work
Summary: WITHOUT_CLANG=yes WITH_CLANG_BOOTSTRAP=yes does not work
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Bryan Drewery
URL:
Keywords:
Depends on:
Blocks: 240506
  Show dependency treegraph
 
Reported: 2019-09-11 13:16 UTC by Kyle Evans
Modified: 2020-04-27 17:09 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 Kyle Evans freebsd_committer freebsd_triage 2019-09-11 13:16:13 UTC
The picobsd build script is trivially broken for CLANG_BOOTSTRAP archs because it wants to set WITHOUT_CLANG and that unsets all of the LLVM_TARGET knobs. It can be fixed to only set it for install phase because it presumably doesn't want clang installed.

Can we consider enabling all LLVM_TARGET_* knobs for the bootstrap/cross-compiler clang, and leaving those user-controlled knobs to be purely for the clang that's getting installed.
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2019-09-11 13:17:16 UTC
Assign to -toolchain, CC dim@, part of the picobsd breakage on stable/12 and head.
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2019-09-11 16:18:02 UTC
(In reply to Kyle Evans from comment #0)
> Can we consider enabling all LLVM_TARGET_* knobs for the bootstrap/cross-compiler clang, and leaving those user-controlled knobs to be purely for the clang that's getting installed

The problem with that is that a lot of unused targets will be built, which is why the MK_LLVM_TARGET_ knobs were created in the first place.  Ideally, only the minimum set of targets is built.

That said, I agree that WITHOUT_CLANG should not immediately cause all MK_LLVM_TARGET_ knobs to be turned off.  However, the logic in share/mk/*.mk to achieve all this is very convoluted and fragile, so I would rather defer to an expert in that area. :)
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2019-09-11 16:34:11 UTC
(In reply to Dimitry Andric from comment #2)

> The problem with that is that a lot of unused targets will be built, which is why the MK_LLVM_TARGET_ knobs were created in the first place.  Ideally, only the minimum set of targets is built.

Right... so this all feels like a good opportunity for foot shooting. =\ It'd be nice if we had some way of listing the targets that `cc` supports, so we can decide if we need to bootstrap a cross-compiler that works for what we're trying to build and we can at least force *that* option on for the bootstrap compiler.

The last time I checked, one could turn off all of the LLVM_TARGET_* knobs except, say, LLVM_TARGET_X86. They install a machine that way, and the machine has all of the knobs except LLVM_TARGET_X86 turned off just like the builder. A cross-build of aarch64 would then just error out with 'target triple unknown' or something to this effect, rather than being able to detect- "oh yes, the host isn't functional for this."
Comment 4 Bryan Drewery freebsd_committer freebsd_triage 2019-11-06 23:11:35 UTC
It's the fault of r335706 binding the LLVM_TARGET_* options to MK_CLANG. That
doesn't make sense to me anymore.


Testing this patch which so far is working but I need to test universe and more
specific cases.

diff --git share/mk/src.opts.mk share/mk/src.opts.mk
index 171676dd52d3..b960692b1dd4 100644
--- share/mk/src.opts.mk
+++ share/mk/src.opts.mk
@@ -130,6 +130,7 @@ __DEFAULT_YES_OPTIONS = \
     LIBPTHREAD \
     LIBTHR \
     LLVM_COV \
+    LLVM_TARGET_ALL \
     LOADER_GELI \
     LOADER_LUA \
     LOADER_OFW \
@@ -220,7 +221,6 @@ __DEFAULT_NO_OPTIONS = \
 # RIGHT option is disabled.
 __DEFAULT_DEPENDENT_OPTIONS= \
        CLANG_FULL/CLANG \
-       LLVM_TARGET_ALL/CLANG \
        LOADER_VERIEXEC/BEARSSL \
        LOADER_EFI_SECUREBOOT/LOADER_VERIEXEC \
        VERIEXEC/BEARSSL \
@@ -283,7 +283,7 @@ __LLVM_TARGET_FILT= C/(amd64|i386)/x86/:S/sparc64/sparc/:S/arm64/aarch64/:S/powe
 .for __llt in ${__LLVM_TARGETS}
 # Default the given TARGET's LLVM_TARGET support to the value of MK_CLANG.
 .if ${__TT:${__LLVM_TARGET_FILT}} == ${__llt}
-__DEFAULT_DEPENDENT_OPTIONS+=  LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}/CLANG
+__DEFAULT_YES_OPTIONS+=        LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}
 # Disable other targets for arm and armv6, to work around "relocation truncated
 # to fit" errors with BFD ld, since libllvm.a will get too large to link.
 .elif ${__T} == "arm" || ${__T} == "armv6"
Comment 5 Bryan Drewery freebsd_committer freebsd_triage 2019-12-10 18:51:27 UTC
Fixed in r355588
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-12-10 18:51:39 UTC
A commit references this bug:

Author: bdrewery
Date: Tue Dec 10 18:50:51 UTC 2019
New revision: 355588
URL: https://svnweb.freebsd.org/changeset/base/355588

Log:
  Fix WITHOUT_CLANG build.

  This decouples MK_LLVM_TARGET_ALL from MK_CLANG. It is fine if
  LLVM_TARGET_* are set even if MK_CLANG is disabled. It never
  made sense to depend MK_LLVM_TARGET_* to MK_CLANG (which I did
  in r335706).

  PR:	        240507
  Reported by:	kevans, swills
  MFC after:	2 weeks

Changes:
  head/share/mk/src.opts.mk
Comment 7 commit-hook freebsd_committer freebsd_triage 2020-01-13 19:23:07 UTC
A commit references this bug:

Author: bdrewery
Date: Mon Jan 13 19:22:52 UTC 2020
New revision: 356696
URL: https://svnweb.freebsd.org/changeset/base/356696

Log:
  MFC r355588:

    Fix WITHOUT_CLANG build.

  PR:		240507

Changes:
_U  stable/12/
  stable/12/share/mk/src.opts.mk