Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 677524 Details for
Bug 758167
Fix bootstrapping linker/compiler packages for clang-based darwin prefix
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bootstrap-prefix.sh modifications for linker/compiler in stage2/3
0002-Darwin-clang-Build-libcxx-before-llvm-clang.patch (text/plain), 5.28 KB, created by
Jacob Floyd
on 2020-12-10 04:12:46 UTC
(
hide
)
Description:
bootstrap-prefix.sh modifications for linker/compiler in stage2/3
Filename:
MIME Type:
Creator:
Jacob Floyd
Created:
2020-12-10 04:12:46 UTC
Size:
5.28 KB
patch
obsolete
>From bee3f107e401fe29940bbd29ce85d7bbfa2344d9 Mon Sep 17 00:00:00 2001 >From: Jacob Floyd <jacob.floyd@copart.com> >Date: Sun, 6 Dec 2020 19:00:54 -0600 >Subject: [PATCH 2/4] Darwin clang: Build libcxx before llvm & clang > >llvm and clang need to be built with the same libc++. If you don't build >with the same libc++ then you get weird errors where comparing >std::error_code's fails because llvm has one errc enum, and clang has a >different one. > >Also, make sure to use our libc++, not the system provided libc++ in >both stage 2 and stage3 when building llvm and clang. > >To make this work, we need to control CPLUS_INCLUDE_PATH carefully at >several points. > >Bug: https://bugs.gentoo.org/758167 > >Signed-off-by: Jacob Floyd <cognifloyd@gmail.com> >--- > scripts/bootstrap-prefix.sh | 52 ++++++++++++++++++++++++++++++------- > 1 file changed, 43 insertions(+), 9 deletions(-) > >diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh >index e8471bde99..6378eed5a5 100755 >--- a/scripts/bootstrap-prefix.sh >+++ b/scripts/bootstrap-prefix.sh >@@ -102,14 +102,22 @@ darwin_symlink_sdk() { > } > > darwin_include_paths_for_clang() { >- # only used on clang-based darwin installs >+ # C_INCLUDE_PATH and CPLUS_INCLUDE_PATH are the only way to override >+ # clang's builtin header search path. (vs adding new paths w/ -I or -isystem) >+ # we need to carefully adjust these paths throughout stage 1 & stage 2 in order >+ # to successfully bootstrap with clang on darwin. > > local XCODE_PATH=$(xcode-select -p) > # Xcode.app path is deeper than CommandLineTools path > [[ "${XCODE_PATH}" == */CommandLineTools ]] || XCODE_PATH+="/Toolchains/XcodeDefault.xctoolchain" > > export C_INCLUDE_PATH="${ROOT}/MacOSX.sdk/usr/include" >+ # stage1&2: CPLUS_INCLUDE_PATH needs to have system c++ headers before libcxx is built > export CPLUS_INCLUDE_PATH="${XCODE_PATH}/usr/include/c++/v1:${C_INCLUDE_PATH}" >+ # stage2: CPLUS_INCLUDE_PATH must not have system c++ headers for building libcxx >+ export libcxx_CPLUS_INCLUDE_PATH="${C_INCLUDE_PATH}" >+ # stage2: CPLUS_INCLUDE_PATH should have EPREFIX/tmp c++ headers after libcxx is built >+ export post_libcxx_CPLUS_INCLUDE_PATH="${ROOT}/tmp/usr/include/c++/v1:${C_INCLUDE_PATH}" > } > > configure_cflags() { >@@ -254,12 +262,14 @@ configure_toolchain() { > vers=${vers% (clang-*} > # this is Clang, recent enough to compile recent clang > mycc=clang >+ # llvm and clang must be built with the same libc++ >+ # So, make sure that llvm and clang are always after libcxx* > compiler_stage1+=" > ${llvm_deps} >- sys-devel/llvm >- sys-devel/clang > sys-libs/libcxxabi >- sys-libs/libcxx" >+ sys-libs/libcxx >+ sys-devel/llvm >+ sys-devel/clang" > CC=clang > CXX=clang++ > linker=sys-devel/binutils-apple >@@ -284,10 +294,10 @@ configure_toolchain() { > mycc=clang > compiler_stage1+=" > ${llvm_deps} >- sys-devel/llvm >- sys-devel/clang > sys-libs/libcxxabi >- sys-libs/libcxx" >+ sys-libs/libcxx >+ sys-devel/llvm >+ sys-devel/clang" > ;; > esac > CC=clang >@@ -324,10 +334,10 @@ configure_toolchain() { > local cdep="3.5.9999" > compiler_stage1+=" > dev-libs/libffi >- <sys-devel/llvm-${cdep} > <sys-libs/libcxx-headers-${cdep} > <sys-libs/libcxxabi-${cdep} > <sys-libs/libcxx-${cdep} >+ <sys-devel/llvm-${cdep} > <sys-devel/clang-${cdep}" > fi > >@@ -1785,7 +1795,18 @@ bootstrap_stage2() { > EXTRA_ECONF=$(rapx --with-sysroot=/) \ > emerge_pkgs --nodeps ${linker} || return 1 > >+ local save_CPPFLAGS="${CPPFLAGS}" > for pkg in ${compiler_stage1} ; do >+ if [[ "${pkg}" == *sys-libs/libcxx* && ! -z ${libcxx_CPLUS_INCLUDE_PATH+x} ]] ; >+ then >+ # see darwin_include_paths_for_clang >+ export CPLUS_INCLUDE_PATH="${libcxx_CPLUS_INCLUDE_PATH}" >+ elif [[ "${pkg}" == *sys-devel/llvm* || "${pkg}" == *sys-devel/clang* ]] ; >+ then >+ # clang doesn't have the implicit framework paths configured yet. >+ export CPPFLAGS="${save_CPPFLAGS} -F${ROOT}/MacOSX.sdk/System/Library/Frameworks" >+ fi >+ > # <glibc-2.5 does not understand .gnu.hash, use > # --hash-style=both to produce also sysv hash. > EXTRA_ECONF="--disable-bootstrap $(rapx --with-linker-hash-style=both) --with-local-prefix=${ROOT}" \ >@@ -1795,12 +1816,25 @@ bootstrap_stage2() { > PYTHON_COMPAT_OVERRIDE=python${PYTHONMAJMIN} \ > emerge_pkgs --nodeps ${pkg} || return 1 > >- if [[ "${pkg}" == *sys-devel/llvm* || ${pkg} == *sys-devel/clang* ]] ; >+ if [[ "${pkg}" == *sys-libs/libcxx* && ! -z ${post_libcxx_CPLUS_INCLUDE_PATH+x} ]] ; >+ then >+ # see darwin_include_paths_for_clang >+ export CPLUS_INCLUDE_PATH="${post_libcxx_CPLUS_INCLUDE_PATH}" >+ elif [[ "${pkg}" == *sys-devel/llvm* || ${pkg} == *sys-devel/clang* ]] ; > then > # we need llvm/clang ASAP for libcxx* doesn't build > # without C++11 > [[ -x ${ROOT}/tmp/usr/bin/clang ]] && CC=clang > [[ -x ${ROOT}/tmp/usr/bin/clang++ ]] && CXX=clang++ >+ >+ # once clang is installed, drop the INCLUDE_PATH vars >+ # so that we do not duplicate internal include paths >+ # (duplicates can cause system header not found issues) >+ [[ ${INCLUDE_EPREFIX_DARWIN_SDK} == 1 && -d ${ROOT}/tmp/usr/lib/clang ]] \ >+ && unset C_INCLUDE_PATH CPLUS_INCLUDE_PATH >+ >+ # reset CPPFLAGS to drop the framework path >+ export CPPFLAGS="${save_CPPFLAGS}" > fi > done > >-- >2.28.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 758167
:
676360
|
676363
|
676366
|
676369
|
676375
|
676531
|
676534
|
676591
|
677179
|
677248
|
677251
|
677509
|
677512
|
677515
|
677524
|
677527
|
677530
|
678760
|
868834
|
868835
|
869498
|
869500
|
869577
|
870074
|
870075
|
874610
|
881438
|
884642