From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4EAAE158008 for ; Thu, 15 Jun 2023 21:55:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B0835E093E; Thu, 15 Jun 2023 21:55:17 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 760C1E088B for ; Thu, 15 Jun 2023 21:55:17 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: Raul E Rangel , James Le Cuirot Subject: [gentoo-dev] [PATCH] cmake.eclass: Set CMAKE_SYSROOT when building with SYSROOT= Date: Thu, 15 Jun 2023 22:54:38 +0100 Message-Id: <20230615215438.2485-1-chewi@gentoo.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: bc8de9fc-5ce0-4263-9840-23e3c82b9cef X-Archives-Hash: 1ce79c2d125ac97642097ffacacf624b From: Raul E Rangel 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 Closes: https://github.com/gentoo/gentoo/pull/30658 Signed-off-by: James Le Cuirot --- 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