From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev <gentoo-dev@lists.gentoo.org>
Cc: Raul E Rangel <rrangel@chromium.org>, James Le Cuirot <chewi@gentoo.org>
Subject: [gentoo-dev] [PATCH] cmake.eclass: Set CMAKE_SYSROOT when building with SYSROOT=
Date: Thu, 15 Jun 2023 22:54:38 +0100 [thread overview]
Message-ID: <20230615215438.2485-1-chewi@gentoo.org> (raw)
From: Raul E Rangel <rrangel@chromium.org>
When performing a SYSROOT= build, the --sysroot parameter was not
getting passed to the compiler if the CBUILD and CHOST matched. This
results in the build attempting to use BROOT libraries and headers
instead of the ones from the SYSROOT.
This change will allow `llvm` to be built into a new SYSROOT.
ROOT=/build/amd64-host emerge sys-devel/llvm
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Closes: https://github.com/gentoo/gentoo/pull/30658
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
eclass/cmake.eclass | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 24787f1c2a49..1cdbc123a243 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -484,17 +484,17 @@ cmake_src_configure() {
cat >> "${toolchain_file}" <<- _EOF_ || die
set(CMAKE_SYSTEM_NAME "${sysname}")
_EOF_
+ fi
- if [ "${SYSROOT:-/}" != "/" ] ; then
- # When cross-compiling with a sysroot (e.g. with crossdev's emerge wrappers)
- # we need to tell cmake to use libs/headers from the sysroot but programs from / only.
- cat >> "${toolchain_file}" <<- _EOF_ || die
- set(CMAKE_SYSROOT "${ESYSROOT}")
- set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
- set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
- set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- _EOF_
- fi
+ if [[ ${SYSROOT:-/} != / ]] ; then
+ # When building with a sysroot (e.g. with crossdev's emerge wrappers)
+ # we need to tell cmake to use libs/headers from the sysroot but programs from / only.
+ cat >> "${toolchain_file}" <<- _EOF_ || die
+ set(CMAKE_SYSROOT "${ESYSROOT}")
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+ _EOF_
fi
if use prefix-guest; then
--
2.40.1
reply other threads:[~2023-06-15 21:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230615215438.2485-1-chewi@gentoo.org \
--to=chewi@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=rrangel@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox