Bug 240507 - WITHOUT_CLANG=yes WITH_CLANG_BOOTSTRAP=yes does not work
Summary: WITHOUT_CLANG=yes WITH_CLANG_BOOTSTRAP=yes does not work
Status: New
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: 2019-11-06 23:11 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 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 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 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 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 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"