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 5115315800A for ; Tue, 22 Aug 2023 18:04:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DD8422BC068; Tue, 22 Aug 2023 18:04:10 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9E5622BC068 for ; Tue, 22 Aug 2023 18:04:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 smtp.gentoo.org (Postfix) with ESMTPS id 811793412AB for ; Tue, 22 Aug 2023 18:04:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E1E7C106C for ; Tue, 22 Aug 2023 18:04:07 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1692727417.3bc0eebf391b1811343f454314c82402ebc6b38c.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/compiler-rt/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-libs/compiler-rt/compiler-rt-16.0.6.ebuild sys-libs/compiler-rt/compiler-rt-17.0.0.9999.ebuild sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.ebuild sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.ebuild sys-libs/compiler-rt/compiler-rt-18.0.0.9999.ebuild sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230803.ebuild sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230810.ebuild sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230820.ebuild X-VCS-Directories: sys-libs/compiler-rt/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 3bc0eebf391b1811343f454314c82402ebc6b38c X-VCS-Branch: master Date: Tue, 22 Aug 2023 18:04:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ffc1fd94-145a-4137-a50e-5b61d75dff3c X-Archives-Hash: 854ec286fd38e3919f712ce91dcab658 commit: 3bc0eebf391b1811343f454314c82402ebc6b38c Author: Alfred Persson Forsberg catcream org> AuthorDate: Tue Aug 1 22:33:30 2023 +0000 Commit: Sam James gentoo org> CommitDate: Tue Aug 22 18:03:37 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3bc0eebf sys-libs/compiler-rt: Support LLVM/Clang crossdev This adds functionality to cross compile compiler-rt for a target architecture. Needed for LLVM/Clang crossdev. Thanks wikky for help! Signed-off-by: Alfred Persson Forsberg catcream.org> Signed-off-by: Sam James gentoo.org> sys-libs/compiler-rt/compiler-rt-16.0.6.ebuild | 36 +++++++++++++++++++--- .../compiler-rt/compiler-rt-17.0.0.9999.ebuild | 36 +++++++++++++++++++--- sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.ebuild | 36 +++++++++++++++++++--- sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.ebuild | 36 +++++++++++++++++++--- .../compiler-rt/compiler-rt-18.0.0.9999.ebuild | 36 +++++++++++++++++++--- .../compiler-rt-18.0.0_pre20230803.ebuild | 36 +++++++++++++++++++--- .../compiler-rt-18.0.0_pre20230810.ebuild | 36 +++++++++++++++++++--- .../compiler-rt-18.0.0_pre20230820.ebuild | 36 +++++++++++++++++++--- 8 files changed, 256 insertions(+), 32 deletions(-) diff --git a/sys-libs/compiler-rt/compiler-rt-16.0.6.ebuild b/sys-libs/compiler-rt/compiler-rt-16.0.6.ebuild index 50726932b7b2..855c52056bcb 100644 --- a/sys-libs/compiler-rt/compiler-rt-16.0.6.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-16.0.6.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 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..f5ece0834a5e 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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.ebuild b/sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-17.0.0_rc1.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.ebuild b/sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-17.0.0_rc2.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-18.0.0.9999.ebuild b/sys-libs/compiler-rt/compiler-rt-18.0.0.9999.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-18.0.0.9999.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-18.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230803.ebuild b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230803.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230803.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230803.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230810.ebuild b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230810.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230810.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230810.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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 diff --git a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230820.ebuild b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230820.ebuild index f31c17f1962a..f5ece0834a5e 100644 --- a/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230820.ebuild +++ b/sys-libs/compiler-rt/compiler-rt-18.0.0_pre20230820.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 crossdev 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 target_is_not_host || 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() { + target_is_not_host && 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; 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 && ! 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 && ! target_is_not_host; then mycmakeargs+=( -DCAN_TARGET_i386=$(usex abi_x86_32) -DCAN_TARGET_x86_64=$(usex abi_x86_64) ) fi + if is_crosspkg; 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