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 A181215800A for ; Fri, 11 Aug 2023 03:50:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D5D7E2BC077; Fri, 11 Aug 2023 03:48:30 +0000 (UTC) Received: from out-119.mta0.migadu.com (out-119.mta0.migadu.com [91.218.175.119]) (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 9523A2BC074 for ; Fri, 11 Aug 2023 03:48:30 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catcream.org; s=key1; t=1691725709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CqOPHByL3ndGhmUcJGyXr6Z1b8RO6tv/85imeRr3p3A=; b=mesyqAY7K2glfjoMiom1MQ45tZe04xQuSEcuEtwSe6QVyqEvIL7RajEBRlKyrs7LuHUepJ pnyYQdfl7JxBge52HSBGGT/YmlTk2viqUSpt8N3aQo6P9j1FA7XxsKHcBwbOPYyhhY5rez oYn6KdhA45USs/EotDlA4vcwHkAKch7UlmsaybtW0PQF+NBezHsxLtR7DjCGYJGhvTVkIv MTIHQNCBCduNq6iroyCshce+JvXQ6YvlXiQKpi2W3S8H/7OCkfzbGI/j6tYqms4WS8S2gy 9un2z4amHe1TEgZvzyzK/YOdEa3Oi2SDoW8cHvXASIjHbRq+7fkJv3CeoSxTZA== From: Alfred Persson Forsberg To: gentoo-dev@lists.gentoo.org Cc: sam@gentoo.org, llvm@gentoo.org, toolchain@gentoo.org, cross@gentoo.org, Alfred Persson Forsberg Subject: [gentoo-dev] [PATCH 4/4] sys-libs/compiler-rt: Support LLVM/Clang crossdev Date: Fri, 11 Aug 2023 05:48:23 +0200 Message-ID: <20230811034823.34301-6-cat@catcream.org> In-Reply-To: <20230811034823.34301-1-cat@catcream.org> References: <20230811034823.34301-1-cat@catcream.org> 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-Migadu-Flow: FLOW_OUT X-Archives-Salt: b8cf3819-13dd-434c-a28b-8268bf51a296 X-Archives-Hash: 5d104509336bd3e7028e0f7b3b93a1a7 Signed-off-by: Alfred Persson Forsberg --- .../compiler-rt-17.0.0.9999.ebuild | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/sys-libs/compiler-rt/compiler-rt-17.0.0.9999.ebuild b/sys-libs/compiler-rt/compiler-rt-17.0.0.9999.ebuild index f31c17f1962a..6075965a0991 100644 --- a/sys-libs/compiler-rt/compiler-rt-17.0.0.9999.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-17.0.0.9999.ebuild @@ -4,7 +4,7 @@ EAPI=8 PYTHON_COMPAT=( python3_{10..12} ) -inherit cmake flag-o-matic llvm llvm.org python-any-r1 toolchain-funcs +inherit cmake cross flag-o-matic llvm llvm.org python-any-r1 toolchain-funcs DESCRIPTION="Compiler runtime library for clang (built-in part)" HOMEPAGE="https://llvm.org/" @@ -52,10 +52,18 @@ pkg_setup() { if [[ ${CHOST} != *-darwin* ]] || has_version sys-devel/llvm; then LLVM_MAX_SLOT=${LLVM_MAJOR} llvm_pkg_setup fi + + if is_crosscompile || tc-is-cross-compiler ; then + # strips vars like CFLAGS="-march=x86_64-v3" for non-x86 architectures + CHOST=${CTARGET} strip-unsupported-flags + # overrides host docs otherwise + DOCS=() + fi python-any-r1_pkg_setup } test_compiler() { + is_crosscompile && return $(tc-getCC) ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \ <<<'int main() { return 0; }' &>/dev/null } @@ -67,7 +75,7 @@ src_configure() { # pre-set since we need to pass it to cmake BUILD_DIR=${WORKDIR}/${P}_build - if use clang; then + if use clang && ! is_crosspkg_llvm; then # Only do this conditionally to allow overriding with # e.g. CC=clang-13 in case of breakage if ! tc-is-clang ; then @@ -78,7 +86,7 @@ src_configure() { strip-unsupported-flags fi - if ! test_compiler; then + if ! is_crosspkg_llvm && ! test_compiler ; then local nolib_flags=( -nodefaultlibs -lc ) if test_compiler "${nolib_flags[@]}"; then @@ -108,13 +116,33 @@ src_configure() { -DPython3_EXECUTABLE="${PYTHON}" ) - if use amd64; then + if use amd64 && ! is_crosscompile; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg_llvm; then + # Needed to target built libc headers + export CFLAGS="${CFLAGS} -isystem /usr/${CTARGET}/usr/include" + mycmakeargs+=( + # Without this, the compiler will compile a test program + # and fail due to no builtins. + -DCMAKE_C_COMPILER_WORKS=1 + -DCMAKE_CXX_COMPILER_WORKS=1 + + # Without this, compiler-rt install location is not unique + # to target triples, only to architecture. + # Needed if you want to target multiple libcs for one arch. + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON + + -DCMAKE_ASM_COMPILER_TARGET="${CTARGET}" + -DCMAKE_C_COMPILER_TARGET="${CTARGET}" + -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON + ) + fi + if use prefix && [[ "${CHOST}" == *-darwin* ]] ; then mycmakeargs+=( # setting -isysroot is disabled with compiler-rt-prefix-paths.patch -- 2.41.0