Bug 221543 - [toolchain] FreeBSD HEAD with LLD_BOOTSTRAP and WITHOUT_LLD_IS_LD
Summary: [toolchain] FreeBSD HEAD with LLD_BOOTSTRAP and WITHOUT_LLD_IS_LD
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D12072
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-08-15 15:44 UTC by Johannes Jost Meixner
Modified: 2017-08-23 13:03 UTC (History)
1 user (show)

See Also:


Attachments
add libllvm debuginfo when LLD_BOOTSTRAP is on (512 bytes, patch)
2017-08-15 15:44 UTC, Johannes Jost Meixner
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Jost Meixner freebsd_committer freebsd_triage 2017-08-15 15:44:17 UTC
Created attachment 185450 [details]
add libllvm debuginfo when LLD_BOOTSTRAP is on

When trying to build with options LLD_BOOTSTRAP=yes and WITHOUT_LLD_IS_LD=yes in src.conf, the initial build of libllvm will be missing certain DebugInfo subdirectories/objects required for ld.lld to proceed.

Patch attached fixes this.
Comment 1 Johannes Jost Meixner freebsd_committer freebsd_triage 2017-08-15 16:00:35 UTC
Build log: http://xmj.me/freebsd/buildworld_llvm_lld.log
Comment 2 Ed Maste freebsd_committer freebsd_triage 2017-08-16 00:53:21 UTC
Your change will stop the build from failing, but I don't think will have the desired effect (the cross-build /usr/bin/ld will still be ld.bfd, I believe).

Can you give this (untested) patch a try?

Index: Makefile.inc1
===================================================================
--- Makefile.inc1       (revision 322559)
+++ Makefile.inc1       (working copy)
@@ -557,6 +557,7 @@
 # cross-tools stage
 XMAKE=         TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
                TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+               MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} \
                MK_GDB=no MK_TESTS=no
 
 # kernel-tools stage
Comment 3 Johannes Jost Meixner freebsd_committer freebsd_triage 2017-08-17 05:20:49 UTC
(In reply to Ed Maste from comment #2)
Ed, I flipped your patch around to better fit my actual usecase: build with ld.bfd on HardenedBSD  (which sets LLD_BOOTSTRAP on by default, to use CFI and others). I've verified this works:

diff --git a/Makefile.inc1 b/Makefile.inc1
index 1c10579bf80..f4a17266cee 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -557,6 +557,7 @@ TMAKE=              MAKEOBJDIRPREFIX=${OBJTREE} \
 # cross-tools stage
 XMAKE=         TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
                TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+               MK_LLD_BOOTSTRAP=${MK_LLD_IS_LD} \
                MK_GDB=no MK_TESTS=no
 
 # kernel-tools stage

I will try to redo it in `share/mk/src.opts.mk` some time later today.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2017-08-18 14:25:41 UTC
The sense of your change is backwards though, because MK_LLD_BOOTSTRAP is intended to control whether LLD is used as the linker while building world.
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-08-23 12:48:17 UTC
A commit references this bug:

Author: emaste
Date: Wed Aug 23 12:47:10 UTC 2017
New revision: 322811
URL: https://svnweb.freebsd.org/changeset/base/322811

Log:
  Set MK_LLD_IS_LD to MK_LLD_BOOTSTRAP for cross-tools

  LLD_BOOTSTRAP is intended to control the linker used to link world and
  kernel, while LLD_IS_LD is intended to control the linker installed in
  that world.

  Force LLD_IS_LD equal to LLD_BOOTSTRAP for the cross-tools build and
  install phase, so that lld will be installed as the ld to run on the
  host, when LLD_BOOTSTRAP is set.

  PR:		221543
  Reviewed by:	dim
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D12072

Changes:
  head/Makefile.inc1