commit: a2e6ca5dd5a1e9eb1fac68856a8bac5120a845d4 Author: Michal Rostecki <vadorovsky <AT> protonmail <DOT> com> AuthorDate: Tue Aug 26 17:01:00 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Tue Sep 2 13:59:05 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a2e6ca5d
llvm-runtimes/libunwind: Use the partial clang configuration files Initial installation or upgrade of libunwind happens before before the main slotted clang configuration file is created by llvm-core/clang-runtime. Building libunwind requires only the linker (`-fuse-ld`) and rtlib (`--rtlib`) configuration to be present. To fix the initial builds, we can use the partial configuration provided by llvm-core/clang-linker-config and llvm-runtimes/clang-rtlib-config. Signed-off-by: Michal Rostecki <vadorovsky <AT> protonmail.com> Closes: https://bugs.gentoo.org/951445 Part-of: https://github.com/gentoo/gentoo/pull/42663 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> Part-of: https://github.com/gentoo/gentoo/pull/42663 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> ....0.0.9999.ebuild => libunwind-20.1.8-r1.ebuild} | 57 +++++++++++++++++++--- ....0.0.9999.ebuild => libunwind-21.1.0-r1.ebuild} | 50 +++++++++++++++++-- .../libunwind/libunwind-22.0.0.9999.ebuild | 47 +++++++++++++++++- .../libunwind/libunwind-22.0.0_pre20250831.ebuild | 47 +++++++++++++++++- 4 files changed, 187 insertions(+), 14 deletions(-) diff --git a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild b/llvm-runtimes/libunwind/libunwind-20.1.8-r1.ebuild similarity index 64% copy from llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild copy to llvm-runtimes/libunwind/libunwind-20.1.8-r1.ebuild index 1aba2f538f51..fac5970f4e66 100644 --- a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild +++ b/llvm-runtimes/libunwind/libunwind-20.1.8-r1.ebuild @@ -12,7 +12,8 @@ HOMEPAGE="https://llvm.org/docs/ExceptionHandling.html" LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )" SLOT="0" -IUSE="+clang +debug static-libs test" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~arm64-macos ~x64-macos" +IUSE="+clang debug static-libs test" REQUIRED_USE="test? ( clang )" RESTRICT="!test? ( test )" @@ -25,6 +26,8 @@ DEPEND=" BDEPEND=" clang? ( llvm-core/clang:${LLVM_MAJOR} + llvm-core/clang-linker-config:${LLVM_MAJOR} + llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR} ) !test? ( ${PYTHON_DEPS} @@ -43,6 +46,14 @@ python_check_deps() { python_has_version "dev-python/lit[${PYTHON_USEDEP}]" } +test_compiler() { + target_is_not_host && return + local compiler=${1} + shift + ${compiler} ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \ + <<<'int main() { return 0; }' &>/dev/null +} + multilib_src_configure() { if use clang; then llvm_prepend_path -b "${LLVM_MAJOR}" @@ -61,9 +72,42 @@ multilib_src_configure() { fi if use clang; then - local -x CC=${CTARGET}-clang - local -x CXX=${CTARGET}-clang++ + local -x CC=${CTARGET}-clang-${LLVM_MAJOR} + local -x CXX=${CTARGET}-clang++-${LLVM_MAJOR} strip-unsupported-flags + + # The full clang configuration might not be ready yet. Use the partial + # configuration files that are guaranteed to exist even during initial + # installations and upgrades. + local flags=( + --config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,linker}.cfg + ) + local -x CFLAGS="${CFLAGS} ${flags[@]}" + local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}" + local -x LDFLAGS="${LDFLAGS} ${flags[@]}" + fi + + # Check whether C compiler runtime is available. + if ! test_compiler "$(tc-getCC)"; then + local nolib_flags=( -nodefaultlibs -lc ) + if test_compiler "$(tc-getCC)" "${nolib_flags[@]}"; then + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + elif test_compiler "$(tc-getCC)" "${nolib_flags[@]}" -nostartfiles; then + # Avoiding -nostartfiles earlier on for bug #862540, + # and set available entry symbol for bug #862798. + nolib_flags+=( -nostartfiles -e main ) + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + fi + fi + # Check whether C++ standard library is available, + local nostdlib_flags=( -nostdlib++ ) + if ! test_compiler "$(tc-getCXX)" && + test_compiler "$(tc-getCXX)" "${nostdlib_flags[@]}" + then + local -x LDFLAGS="${LDFLAGS} ${nostdlib_flags[*]}" + ewarn "${CXX} seems to lack runtime, trying with ${nostdlib_flags[*]}" fi # link to compiler-rt @@ -94,10 +138,9 @@ multilib_src_configure() { -DLIBUNWIND_INCLUDE_TESTS=$(usex test) -DLIBUNWIND_INSTALL_HEADERS=ON - # cross-unwinding increases unwinding footprint (to account - # for the worst case) and causes some breakage on AArch64 - # https://github.com/llvm/llvm-project/issues/152549 - -DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF + # support non-native unwinding; given it's small enough, + # enable it unconditionally + -DLIBUNWIND_ENABLE_CROSS_UNWINDING=ON # avoid dependency on libgcc_s if compiler-rt is used -DLIBUNWIND_USE_COMPILER_RT=${use_compiler_rt} diff --git a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild b/llvm-runtimes/libunwind/libunwind-21.1.0-r1.ebuild similarity index 67% copy from llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild copy to llvm-runtimes/libunwind/libunwind-21.1.0-r1.ebuild index 1aba2f538f51..dfc694046f38 100644 --- a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild +++ b/llvm-runtimes/libunwind/libunwind-21.1.0-r1.ebuild @@ -12,7 +12,8 @@ HOMEPAGE="https://llvm.org/docs/ExceptionHandling.html" LICENSE="Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT )" SLOT="0" -IUSE="+clang +debug static-libs test" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~arm64-macos ~x64-macos" +IUSE="+clang debug static-libs test" REQUIRED_USE="test? ( clang )" RESTRICT="!test? ( test )" @@ -25,6 +26,8 @@ DEPEND=" BDEPEND=" clang? ( llvm-core/clang:${LLVM_MAJOR} + llvm-core/clang-linker-config:${LLVM_MAJOR} + llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR} ) !test? ( ${PYTHON_DEPS} @@ -43,6 +46,14 @@ python_check_deps() { python_has_version "dev-python/lit[${PYTHON_USEDEP}]" } +test_compiler() { + target_is_not_host && return + local compiler=${1} + shift + ${compiler} ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \ + <<<'int main() { return 0; }' &>/dev/null +} + multilib_src_configure() { if use clang; then llvm_prepend_path -b "${LLVM_MAJOR}" @@ -61,9 +72,42 @@ multilib_src_configure() { fi if use clang; then - local -x CC=${CTARGET}-clang - local -x CXX=${CTARGET}-clang++ + local -x CC=${CTARGET}-clang-${LLVM_MAJOR} + local -x CXX=${CTARGET}-clang++-${LLVM_MAJOR} strip-unsupported-flags + + # The full clang configuration might not be ready yet. Use the partial + # configuration files that are guaranteed to exist even during initial + # installations and upgrades. + local flags=( + --config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,linker}.cfg + ) + local -x CFLAGS="${CFLAGS} ${flags[@]}" + local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}" + local -x LDFLAGS="${LDFLAGS} ${flags[@]}" + fi + + # Check whether C compiler runtime is available. + if ! test_compiler "$(tc-getCC)"; then + local nolib_flags=( -nodefaultlibs -lc ) + if test_compiler "$(tc-getCC)" "${nolib_flags[@]}"; then + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + elif test_compiler "$(tc-getCC)" "${nolib_flags[@]}" -nostartfiles; then + # Avoiding -nostartfiles earlier on for bug #862540, + # and set available entry symbol for bug #862798. + nolib_flags+=( -nostartfiles -e main ) + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + fi + fi + # Check whether C++ standard library is available, + local nostdlib_flags=( -nostdlib++ ) + if ! test_compiler "$(tc-getCXX)" && + test_compiler "$(tc-getCXX)" "${nostdlib_flags[@]}" + then + local -x LDFLAGS="${LDFLAGS} ${nostdlib_flags[*]}" + ewarn "${CXX} seems to lack runtime, trying with ${nostdlib_flags[*]}" fi # link to compiler-rt diff --git a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild b/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild index 1aba2f538f51..95ce2986a0f9 100644 --- a/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild +++ b/llvm-runtimes/libunwind/libunwind-22.0.0.9999.ebuild @@ -25,6 +25,8 @@ DEPEND=" BDEPEND=" clang? ( llvm-core/clang:${LLVM_MAJOR} + llvm-core/clang-linker-config:${LLVM_MAJOR} + llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR} ) !test? ( ${PYTHON_DEPS} @@ -43,6 +45,14 @@ python_check_deps() { python_has_version "dev-python/lit[${PYTHON_USEDEP}]" } +test_compiler() { + target_is_not_host && return + local compiler=${1} + shift + ${compiler} ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \ + <<<'int main() { return 0; }' &>/dev/null +} + multilib_src_configure() { if use clang; then llvm_prepend_path -b "${LLVM_MAJOR}" @@ -61,9 +71,42 @@ multilib_src_configure() { fi if use clang; then - local -x CC=${CTARGET}-clang - local -x CXX=${CTARGET}-clang++ + local -x CC=${CTARGET}-clang-${LLVM_MAJOR} + local -x CXX=${CTARGET}-clang++-${LLVM_MAJOR} strip-unsupported-flags + + # The full clang configuration might not be ready yet. Use the partial + # configuration files that are guaranteed to exist even during initial + # installations and upgrades. + local flags=( + --config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,linker}.cfg + ) + local -x CFLAGS="${CFLAGS} ${flags[@]}" + local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}" + local -x LDFLAGS="${LDFLAGS} ${flags[@]}" + fi + + # Check whether C compiler runtime is available. + if ! test_compiler "$(tc-getCC)"; then + local nolib_flags=( -nodefaultlibs -lc ) + if test_compiler "$(tc-getCC)" "${nolib_flags[@]}"; then + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + elif test_compiler "$(tc-getCC)" "${nolib_flags[@]}" -nostartfiles; then + # Avoiding -nostartfiles earlier on for bug #862540, + # and set available entry symbol for bug #862798. + nolib_flags+=( -nostartfiles -e main ) + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + fi + fi + # Check whether C++ standard library is available, + local nostdlib_flags=( -nostdlib++ ) + if ! test_compiler "$(tc-getCXX)" && + test_compiler "$(tc-getCXX)" "${nostdlib_flags[@]}" + then + local -x LDFLAGS="${LDFLAGS} ${nostdlib_flags[*]}" + ewarn "${CXX} seems to lack runtime, trying with ${nostdlib_flags[*]}" fi # link to compiler-rt diff --git a/llvm-runtimes/libunwind/libunwind-22.0.0_pre20250831.ebuild b/llvm-runtimes/libunwind/libunwind-22.0.0_pre20250831.ebuild index 1aba2f538f51..95ce2986a0f9 100644 --- a/llvm-runtimes/libunwind/libunwind-22.0.0_pre20250831.ebuild +++ b/llvm-runtimes/libunwind/libunwind-22.0.0_pre20250831.ebuild @@ -25,6 +25,8 @@ DEPEND=" BDEPEND=" clang? ( llvm-core/clang:${LLVM_MAJOR} + llvm-core/clang-linker-config:${LLVM_MAJOR} + llvm-runtimes/clang-rtlib-config:${LLVM_MAJOR} ) !test? ( ${PYTHON_DEPS} @@ -43,6 +45,14 @@ python_check_deps() { python_has_version "dev-python/lit[${PYTHON_USEDEP}]" } +test_compiler() { + target_is_not_host && return + local compiler=${1} + shift + ${compiler} ${CFLAGS} ${LDFLAGS} "${@}" -o /dev/null -x c - \ + <<<'int main() { return 0; }' &>/dev/null +} + multilib_src_configure() { if use clang; then llvm_prepend_path -b "${LLVM_MAJOR}" @@ -61,9 +71,42 @@ multilib_src_configure() { fi if use clang; then - local -x CC=${CTARGET}-clang - local -x CXX=${CTARGET}-clang++ + local -x CC=${CTARGET}-clang-${LLVM_MAJOR} + local -x CXX=${CTARGET}-clang++-${LLVM_MAJOR} strip-unsupported-flags + + # The full clang configuration might not be ready yet. Use the partial + # configuration files that are guaranteed to exist even during initial + # installations and upgrades. + local flags=( + --config="${ESYSROOT}"/etc/clang/"${LLVM_MAJOR}"/gentoo-{rtlib,linker}.cfg + ) + local -x CFLAGS="${CFLAGS} ${flags[@]}" + local -x CXXFLAGS="${CXXFLAGS} ${flags[@]}" + local -x LDFLAGS="${LDFLAGS} ${flags[@]}" + fi + + # Check whether C compiler runtime is available. + if ! test_compiler "$(tc-getCC)"; then + local nolib_flags=( -nodefaultlibs -lc ) + if test_compiler "$(tc-getCC)" "${nolib_flags[@]}"; then + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + elif test_compiler "$(tc-getCC)" "${nolib_flags[@]}" -nostartfiles; then + # Avoiding -nostartfiles earlier on for bug #862540, + # and set available entry symbol for bug #862798. + nolib_flags+=( -nostartfiles -e main ) + local -x LDFLAGS="${LDFLAGS} ${nolib_flags[*]}" + ewarn "${CC} seems to lack runtime, trying with ${nolib_flags[*]}" + fi + fi + # Check whether C++ standard library is available, + local nostdlib_flags=( -nostdlib++ ) + if ! test_compiler "$(tc-getCXX)" && + test_compiler "$(tc-getCXX)" "${nostdlib_flags[@]}" + then + local -x LDFLAGS="${LDFLAGS} ${nostdlib_flags[*]}" + ewarn "${CXX} seems to lack runtime, trying with ${nostdlib_flags[*]}" fi # link to compiler-rt
