Bug 196193 - WITHOUT_CROSS_COMPILER=true uses system header files instead of those from the build root
Summary: WITHOUT_CROSS_COMPILER=true uses system header files instead of those from th...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 10.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Bryan Drewery
URL:
Keywords:
: 182170 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-22 15:01 UTC by Philippe Michel
Modified: 2018-06-26 17:19 UTC (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Michel 2014-12-22 15:01:58 UTC
If WITHOUT_CROSS_COMPILER is false, a clang is built with 
-DDEFAULT_SYSROOT=\"/usr/obj/usr/src/tmp\", world is built with it and everything goes well.

With this flag set to true, a clang is built with -DDEFAULT_SYSROOT=\"\" and buildword uses it, using for instance the system includes instead of those from /usr/src, and fails when new include files appear in the source tree.

I didn't investigate if this compiler is a misconfigured first stage one or already the final one, but in either case there is a problem since even if it is the second case and this is a feature, it is a much more aggressive shortcut than what src.conf man page suggests, with serious limitations.


This is the underlying cause of another PR I opened as misc/195503 and may well be the cause of bin/182170 as well (at least in the case of the me-too comment there).
Comment 1 Henry Hu 2015-11-26 23:53:40 UTC
This problem has occurred several times, and finally I figured out the reason by myself. After that, I searched for WITHOUT_CROSS_COMPILER and found this PR.
It's hard for a user to find this PR or a solution of the problem until the user figured out what's wrong. Because the complexity of the build process and the misleading name of the option, it's unclear to the user that this option is the culprit.
WITHOUT_CROSS_COMPILER causes MK_CLANG_BOOTSTRAP=no in src.opts.mk, so the current clang is used instead. But the name of the option only suggests something about "cross compiling", which in the common sense is not required if you are building for the same architecture.
Please add some comments to src.opts.mk, which I guess is the common way for users to find this option, or just make the option do what its name suggests.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2015-11-27 14:58:50 UTC
Add two possibly interested parties to the CC: of this older PR which has a new comment.
Comment 3 Bryan Drewery freebsd_committer 2015-11-27 20:29:07 UTC
Take, I was planning to fix this soon.
Comment 4 Bryan Drewery freebsd_committer 2016-03-23 18:52:57 UTC
It's due to the lack of --sysroot when not using the bootstrap compiler (as
comment #0 alluded to). https://reviews.freebsd.org/D3970 is the start to resolving that.
Comment 5 commit-hook freebsd_committer 2016-03-25 19:12:43 UTC
A commit references this bug:

Author: bdrewery
Date: Fri Mar 25 19:12:38 UTC 2016
New revision: 297270
URL: https://svnweb.freebsd.org/changeset/base/297270

Log:
  Build libcompat (lib32) with a --sysroot pointing into its stage directory.

  This overrides the cross-compiler's default sysroot to use the WORLD32's
  sysroot for building the lib32 libraries.  Previously the cross-compiler
  would default the sysroot to the 64bit WORLDTMP and -B/-L/-isystem flags
  were used to build using the lib32 files.  This leads to multiple issues
  discussed later.  Some extra headers are now needed to be staged since the
  64bit WORLDTMP is not referenced at all for headers.  The 64bit WORLDTMP
  is still used via PATH for build tools.  Overriding the default
  target/arch is retained in the CC/CXX overrides.

  This allows reverting the LDSCRIPT rewriting in installworld from r296921 and
  r235122, thus allowing read-only objdirs to work for installing again.

  This removes the need for _LDSCRIPTROOT.

  This allows progressing the change to always use --sysroot for the build
  rather than only relying on the cross-compiler's default sysroot.  The
  work for that is in D3970 and needed to resolve WITHOUT_CROSS_COMPILER
  not using a --sysroot [1].

  PR:		196193 [1]
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/Makefile.inc1
  head/Makefile.libcompat
  head/share/mk/bsd.lib.mk
  head/share/mk/bsd.sys.mk
Comment 6 commit-hook freebsd_committer 2016-03-25 22:37:01 UTC
A commit references this bug:

Author: bdrewery
Date: Fri Mar 25 22:36:13 UTC 2016
New revision: 297277
URL: https://svnweb.freebsd.org/changeset/base/297277

Log:
  WITHOUT_CROSS_COMPILER: Fix this to use external compiler logic.

  Without this the default toolchain in /usr/bin/ would not use
  WORLDTMP via --sysroot, and would lack --target if cross-building.

  PR:		196193
  Related:	D3970
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/Makefile.inc1
Comment 7 Enji Cooper freebsd_committer 2017-01-03 05:47:17 UTC
*** Bug 182170 has been marked as a duplicate of this bug. ***
Comment 8 larryboman 2017-06-13 05:53:25 UTC
MARKED AS SPAM
Comment 9 lauraduncan 2018-02-14 07:54:49 UTC
MARKED AS SPAM
Comment 10 Emma 2018-06-05 15:40:56 UTC
MARKED AS SPAM
Comment 11 Emily Richmond 2018-06-21 10:37:44 UTC
MARKED AS SPAM
Comment 12 Mia Wilson 2018-06-26 17:19:04 UTC
MARKED AS SPAM