summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Floyd <cognifloyd@gmail.com>2020-12-18 18:53:24 -0600
committerFabian Groffen <grobian@gentoo.org>2020-12-27 10:49:32 +0100
commit1b2b62e093d789f6b1a4609c866581991e287b88 (patch)
treed003ed70504bf2dc50ab5c5d36bc64622329f443 /sys-devel
parentsys-libs/libcxx: fix prefix bootstrap (diff)
downloadgentoo-1b2b62e093d789f6b1a4609c866581991e287b88.tar.gz
gentoo-1b2b62e093d789f6b1a4609c866581991e287b88.tar.bz2
gentoo-1b2b62e093d789f6b1a4609c866581991e287b88.zip
sys-devel/clang: fix bootstrap on darwin prefix
Adjust the clang internal header/framework search paths when building on darwin prefix. We symlink the selected MacOSX.sdk to EPREFIX/MacOSX.sdk during bootstrap, so that is the correct place to get system headers, such as those for libc, or for system framework headers, that we do not replace in prefix. Bug: https://bugs.gentoo.org/758167 Signed-off-by: Jacob Floyd <cognifloyd@gmail.com> Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/clang/clang-11.0.0.ebuild13
-rw-r--r--sys-devel/clang/clang-11.0.1.9999.ebuild11
-rw-r--r--sys-devel/clang/clang-11.0.1_rc1.ebuild11
-rw-r--r--sys-devel/clang/clang-11.0.1_rc2.ebuild11
-rw-r--r--sys-devel/clang/clang-12.0.0.9999.ebuild11
-rw-r--r--sys-devel/clang/files/9999/prefix-dirs.patch75
6 files changed, 126 insertions, 6 deletions
diff --git a/sys-devel/clang/clang-11.0.0.ebuild b/sys-devel/clang/clang-11.0.0.ebuild
index cf0dde1f1604..1d4f4bad16c9 100644
--- a/sys-devel/clang/clang-11.0.0.ebuild
+++ b/sys-devel/clang/clang-11.0.0.ebuild
@@ -5,7 +5,7 @@ EAPI=7
PYTHON_COMPAT=( python3_{6..9} )
inherit cmake llvm llvm.org multilib-minimal pax-utils \
- python-single-r1 toolchain-funcs
+ prefix python-single-r1 toolchain-funcs
DESCRIPTION="C language family frontend for LLVM"
HOMEPAGE="https://llvm.org/"
@@ -30,7 +30,7 @@ ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT"
SLOT="$(ver_cut 1)"
-KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux"
+KEYWORDS="amd64 arm arm64 ppc64 ~riscv x86 ~amd64-linux ~x64-macos"
IUSE="debug default-compiler-rt default-libcxx default-lld
doc +static-analyzer test xml kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}"
REQUIRED_USE="${PYTHON_REQUIRED_USE}
@@ -75,6 +75,10 @@ PDEPEND="
# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
# multilib clang* libraries (not runtime, not wrappers).
+PATCHES=(
+ "${FILESDIR}"/9999/prefix-dirs.patch
+)
+
pkg_setup() {
LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
python-single-r1_pkg_setup
@@ -88,6 +92,11 @@ src_prepare() {
llvm.org_src_prepare
mv ../clang-tools-extra tools/extra || die
+
+ # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
+ eprefixify \
+ lib/Frontend/InitHeaderSearch.cpp \
+ lib/Driver/ToolChains/Darwin.cpp || die
}
check_distribution_components() {
diff --git a/sys-devel/clang/clang-11.0.1.9999.ebuild b/sys-devel/clang/clang-11.0.1.9999.ebuild
index 4a3a05b4df86..c5362450b519 100644
--- a/sys-devel/clang/clang-11.0.1.9999.ebuild
+++ b/sys-devel/clang/clang-11.0.1.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=7
PYTHON_COMPAT=( python3_{6..9} )
inherit cmake llvm llvm.org multilib-minimal pax-utils \
- python-single-r1 toolchain-funcs
+ prefix python-single-r1 toolchain-funcs
DESCRIPTION="C language family frontend for LLVM"
HOMEPAGE="https://llvm.org/"
@@ -77,6 +77,10 @@ llvm.org_set_globals
# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
# multilib clang* libraries (not runtime, not wrappers).
+PATCHES=(
+ "${FILESDIR}"/9999/prefix-dirs.patch
+)
+
pkg_setup() {
LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
python-single-r1_pkg_setup
@@ -90,6 +94,11 @@ src_prepare() {
llvm.org_src_prepare
mv ../clang-tools-extra tools/extra || die
+
+ # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
+ eprefixify \
+ lib/Frontend/InitHeaderSearch.cpp \
+ lib/Driver/ToolChains/Darwin.cpp || die
}
check_distribution_components() {
diff --git a/sys-devel/clang/clang-11.0.1_rc1.ebuild b/sys-devel/clang/clang-11.0.1_rc1.ebuild
index 4a3a05b4df86..c5362450b519 100644
--- a/sys-devel/clang/clang-11.0.1_rc1.ebuild
+++ b/sys-devel/clang/clang-11.0.1_rc1.ebuild
@@ -5,7 +5,7 @@ EAPI=7
PYTHON_COMPAT=( python3_{6..9} )
inherit cmake llvm llvm.org multilib-minimal pax-utils \
- python-single-r1 toolchain-funcs
+ prefix python-single-r1 toolchain-funcs
DESCRIPTION="C language family frontend for LLVM"
HOMEPAGE="https://llvm.org/"
@@ -77,6 +77,10 @@ llvm.org_set_globals
# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
# multilib clang* libraries (not runtime, not wrappers).
+PATCHES=(
+ "${FILESDIR}"/9999/prefix-dirs.patch
+)
+
pkg_setup() {
LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
python-single-r1_pkg_setup
@@ -90,6 +94,11 @@ src_prepare() {
llvm.org_src_prepare
mv ../clang-tools-extra tools/extra || die
+
+ # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
+ eprefixify \
+ lib/Frontend/InitHeaderSearch.cpp \
+ lib/Driver/ToolChains/Darwin.cpp || die
}
check_distribution_components() {
diff --git a/sys-devel/clang/clang-11.0.1_rc2.ebuild b/sys-devel/clang/clang-11.0.1_rc2.ebuild
index 4a3a05b4df86..c5362450b519 100644
--- a/sys-devel/clang/clang-11.0.1_rc2.ebuild
+++ b/sys-devel/clang/clang-11.0.1_rc2.ebuild
@@ -5,7 +5,7 @@ EAPI=7
PYTHON_COMPAT=( python3_{6..9} )
inherit cmake llvm llvm.org multilib-minimal pax-utils \
- python-single-r1 toolchain-funcs
+ prefix python-single-r1 toolchain-funcs
DESCRIPTION="C language family frontend for LLVM"
HOMEPAGE="https://llvm.org/"
@@ -77,6 +77,10 @@ llvm.org_set_globals
# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
# multilib clang* libraries (not runtime, not wrappers).
+PATCHES=(
+ "${FILESDIR}"/9999/prefix-dirs.patch
+)
+
pkg_setup() {
LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
python-single-r1_pkg_setup
@@ -90,6 +94,11 @@ src_prepare() {
llvm.org_src_prepare
mv ../clang-tools-extra tools/extra || die
+
+ # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
+ eprefixify \
+ lib/Frontend/InitHeaderSearch.cpp \
+ lib/Driver/ToolChains/Darwin.cpp || die
}
check_distribution_components() {
diff --git a/sys-devel/clang/clang-12.0.0.9999.ebuild b/sys-devel/clang/clang-12.0.0.9999.ebuild
index e5da1c5cedb4..8ebb9ceea5ec 100644
--- a/sys-devel/clang/clang-12.0.0.9999.ebuild
+++ b/sys-devel/clang/clang-12.0.0.9999.ebuild
@@ -5,7 +5,7 @@ EAPI=7
PYTHON_COMPAT=( python3_{6..9} )
inherit cmake llvm llvm.org multilib-minimal pax-utils \
- python-single-r1 toolchain-funcs
+ prefix python-single-r1 toolchain-funcs
DESCRIPTION="C language family frontend for LLVM"
HOMEPAGE="https://llvm.org/"
@@ -77,6 +77,10 @@ llvm.org_set_globals
# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need
# multilib clang* libraries (not runtime, not wrappers).
+PATCHES=(
+ "${FILESDIR}"/9999/prefix-dirs.patch
+)
+
pkg_setup() {
LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
python-single-r1_pkg_setup
@@ -88,6 +92,11 @@ src_prepare() {
BUILD_DIR=${WORKDIR}/x/y/clang
llvm.org_src_prepare
+
+ # add Gentoo Portage Prefix for Darwin (see prefix-dirs.patch)
+ eprefixify \
+ lib/Frontend/InitHeaderSearch.cpp \
+ lib/Driver/ToolChains/Darwin.cpp || die
}
check_distribution_components() {
diff --git a/sys-devel/clang/files/9999/prefix-dirs.patch b/sys-devel/clang/files/9999/prefix-dirs.patch
new file mode 100644
index 000000000000..0f7b5ca31ebc
--- /dev/null
+++ b/sys-devel/clang/files/9999/prefix-dirs.patch
@@ -0,0 +1,75 @@
+This mirrors cmake-*-prefix-dirs.patch
+
+It add EPREFIX to search paths for c/cxx headers.
+It also adds EPREFIX/MacOSX.sdk to search paths for c and Frameworks.
+Assumes that c++ lib and headers will be installed in the prefix.
+
+Also, a couple of args are populated by inspecting the SDK,
+so, default to EPREFIX/MacOSX.sdk when the sysroot is not specified.
+(This does NOT set sysroot).
+
+The ebuild adds an extra / at the end of EPREFIX so that it is never
+an empty string.
+
+--- a/clang/lib/Frontend/InitHeaderSearch.cpp 2020-11-30 12:53:42.000000000 -0600
++++ b/clang/lib/Frontend/InitHeaderSearch.cpp 2020-11-30 13:57:52.000000000 -0600
+@@ -445,6 +445,9 @@
+ // All header search logic is handled in the Driver for Darwin.
+ if (triple.isOSDarwin()) {
+ if (HSOpts.UseStandardSystemIncludes) {
++ // Add Gentoo Prefix framework dirs first
++ AddPath("@GENTOO_PORTAGE_EPREFIX@MacOSX.sdk/System/Library/Frameworks", System, true);
++ AddPath("@GENTOO_PORTAGE_EPREFIX@MacOSX.sdk/Library/Frameworks", System, true);
+ // Add the default framework include paths on Darwin.
+ AddPath("/System/Library/Frameworks", System, true);
+ AddPath("/Library/Frameworks", System, true);
+--- a/clang/lib/Driver/ToolChains/Darwin.cpp 2020-10-07 05:10:48.000000000 -0500
++++ b/clang/lib/Driver/ToolChains/Darwin.cpp 2020-11-30 12:57:15.000000000 -0600
+@@ -1737,9 +1737,9 @@
+ const ArgList &Args,
+ const Driver &TheDriver) {
+ const Arg *A = Args.getLastArg(options::OPT_isysroot);
+- if (!A)
+- return None;
+- StringRef isysroot = A->getValue();
++ //if (!A)
++ // return None;
++ StringRef isysroot = A ? A->getValue() : "@GENTOO_PORTAGE_EPREFIX@MacOSX.sdk";
+ auto SDKInfoOrErr = driver::parseDarwinSDKInfo(VFS, isysroot);
+ if (!SDKInfoOrErr) {
+ llvm::consumeError(SDKInfoOrErr.takeError());
+@@ -1921,13 +1921,14 @@
+ return DriverArgs.getLastArgValue(options::OPT_isysroot);
+ if (!getDriver().SysRoot.empty())
+ return getDriver().SysRoot;
+- return "/";
++ return "@GENTOO_PORTAGE_EPREFIX@";
+ }
+
+ void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ const Driver &D = getDriver();
+
++ // Sysroot is effectively Gentoo EPREFIX when -isysroot/-sysroot is not defined
+ llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
+
+ bool NoStdInc = DriverArgs.hasArg(options::OPT_nostdinc);
+@@ -1969,6 +1970,10 @@
+ SmallString<128> P(Sysroot);
+ llvm::sys::path::append(P, "usr", "include");
+ addExternCSystemInclude(DriverArgs, CC1Args, P.str());
++ // And add <sysroot>/MacOSX.sdk/usr/include.
++ SmallString<128> Psdk(Sysroot);
++ llvm::sys::path::append(Psdk, "MacOSX.sdk", "usr", "include");
++ addExternCSystemInclude(DriverArgs, CC1Args, Psdk.str());
+ }
+ }
+
+@@ -2017,6 +2022,7 @@
+ DriverArgs.hasArg(options::OPT_nostdincxx))
+ return;
+
++ // Sysroot is effectively Gentoo EPREFIX when -isysroot/-sysroot is not defined
+ llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
+
+ switch (GetCXXStdlibType(DriverArgs)) {