[Buildroot] [PATCH] package/rustc: needs C++

Romain Naour romain.naour at smile.fr
Tue Jul 26 09:51:31 UTC 2022


Hello James,

Le 25/07/2022 à 20:41, James Hilliard a écrit :
> On Mon, Jul 25, 2022 at 9:36 AM Romain Naour <romain.naour at smile.fr> wrote:
>>
>> While building host-rust with a musl based toolchain without C++ compiler,
>> the build fail since libunwind bundled in rust sources needs a C++ compiler.
>>
>> cargo:warning=i686-buildroot-linux-musl-gcc.br_real: error: [...]/host-rust-1.62.0/src/llvm-project/libunwind/src/Unwind-EHABI.cpp: C++ compiler not installed on this system
>>
>> Note: the issues can't be reproduced with a glibc based toolchain without
>> C++ probaly due to extra steps required to support musl libc.
> 
> Is this because glibc provides libunwind so it's not required there?
> 
>>
>> Actually, rust compiler is based on LLVM so it likely depends on the same
>> dependencies as host-llvm package.
> 
> This doesn't really look correct, I mean we always assume the build host has
> C++ support right? This patch adds a target C++ dependency not a host C++
> build dependency.

Actually BR2_INSTALL_LIBSTDCPP is probably one of the oldest Buildroot option
(added by [1]) that means "Build/install c++ compiler and libstdc++".

So you're right when you say it add a target C++ dependency but the option also
means having a C++ compiler on the host.

In this patch we want to make sure to have a toolchain with C++ support to build
host-rust package. Adding C++ dependency globally (even if only musl is
affected) would avoid handly musl case with rust based packages.

But adding C++ reverse dependency is not nice either...

Instead we could add the C++ dependency directly on
BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS.

# All target rust packages should depend on this option
config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
	bool
	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS && \
		(BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL)
	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS && \
		(BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL)
	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS && \
		(BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL)
	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS

Usually we should not add toolchain dependencies in a _ARCH_SUPPORTS option but
BR2_PACKAGE_HOST_RUSTC_TARGET_TIER... options contains already some
BR2_TOOLCHAIN_USES_GLIBC or BR2_TOOLCHAIN_USES_MUSL.

Doing so would avoid the C++ reverse dependencies and disable rustc for musl
toolchain without a C++ compiler.

I'll send a v2.

[1]
https://git.buildroot.net/buildroot/commit/?id=2d523c23175b8e8772c2e223d92513f836cde8a6

[2]
https://git.buildroot.net/buildroot/tree/package/rustc/Config.in.host?h=2022.05.1#n113

Best regards,
Romain


> 
>>
>> Add C++ dependency to rustc virtual package and its reverse dependencies.
>>
>> Fixes:
>> http://autobuild.buildroot.org/results/636/636fb39c8f1b8c05e4ca451ac506cd63c7166d82
>>
>> Signed-off-by: Romain Naour <romain.naour at smile.fr>
>> ---
>>  package/bat/Config.in             | 4 ++++
>>  package/hyperfine/Config.in       | 4 ++++
>>  package/librsvg/Config.in         | 2 +-
>>  package/ripgrep/Config.in         | 4 ++++
>>  package/rustc/Config.in.host      | 4 ++++
>>  package/sentry-cli/Config.in.host | 4 ++++
>>  package/suricata/Config.in        | 5 +++--
>>  7 files changed, 24 insertions(+), 3 deletions(-)
>>
>> diff --git a/package/bat/Config.in b/package/bat/Config.in
>> index 515eaf591a..8b95f253ad 100644
>> --- a/package/bat/Config.in
>> +++ b/package/bat/Config.in
>> @@ -1,6 +1,7 @@
>>  config BR2_PACKAGE_BAT
>>         bool "bat"
>>         depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
>> +       depends on BR2_INSTALL_LIBSTDCPP # host-rustc
>>         select BR2_PACKAGE_HOST_RUSTC
>>         # we need a full version of less
>>         select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
>> @@ -9,3 +10,6 @@ config BR2_PACKAGE_BAT
>>           A cat(1) clone with syntax highlighting and Git integration.
>>
>>           https://github.com/sharkdp/bat
>> +
>> +comment "bat needs a toolchain w/ C++"
>> +       depends on !BR2_INSTALL_LIBSTDCPP
>> diff --git a/package/hyperfine/Config.in b/package/hyperfine/Config.in
>> index 527e978146..c052ba8242 100644
>> --- a/package/hyperfine/Config.in
>> +++ b/package/hyperfine/Config.in
>> @@ -1,6 +1,7 @@
>>  config BR2_PACKAGE_HYPERFINE
>>         bool "hyperfine"
>>         depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
>> +       depends on BR2_INSTALL_LIBSTDCPP # host-rustc
>>         select BR2_PACKAGE_HOST_RUSTC
>>         help
>>           hyperfine is a benchmark tool written in Rust. It evaluates
>> @@ -9,3 +10,6 @@ config BR2_PACKAGE_HYPERFINE
>>           same time.
>>
>>           https://github.com/sharkdp/hyperfine
>> +
>> +comment "hyperfine needs a toolchain w/ C++"
>> +       depends on !BR2_INSTALL_LIBSTDCPP
>> diff --git a/package/librsvg/Config.in b/package/librsvg/Config.in
>> index 270b524b37..91a8d4fe95 100644
>> --- a/package/librsvg/Config.in
>> +++ b/package/librsvg/Config.in
>> @@ -4,7 +4,7 @@ config BR2_PACKAGE_LIBRSVG
>>         depends on BR2_USE_WCHAR # glib2
>>         depends on BR2_TOOLCHAIN_HAS_THREADS # glib2
>>         depends on BR2_USE_MMU # glib2
>> -       depends on BR2_INSTALL_LIBSTDCPP # pango
>> +       depends on BR2_INSTALL_LIBSTDCPP # pango, host-rustc
>>         depends on BR2_TOOLCHAIN_HAS_SYNC_4 # pango -> harfbuzz
>>         depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # pango -> harfbuzz
>>         select BR2_PACKAGE_CAIRO
>> diff --git a/package/ripgrep/Config.in b/package/ripgrep/Config.in
>> index 0ea2902b34..352f38a9a4 100644
>> --- a/package/ripgrep/Config.in
>> +++ b/package/ripgrep/Config.in
>> @@ -1,6 +1,7 @@
>>  config BR2_PACKAGE_RIPGREP
>>         bool "ripgrep"
>>         depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
>> +       depends on BR2_INSTALL_LIBSTDCPP # host-rustc
>>         select BR2_PACKAGE_HOST_RUSTC
>>         help
>>           ripgrep is a line-oriented search tool that
>> @@ -12,3 +13,6 @@ config BR2_PACKAGE_RIPGREP
>>           The Silver Searcher, ack and grep.
>>
>>           https://github.com/BurntSushi/ripgrep
>> +
>> +comment "ripgrep needs a toolchain w/ C++"
>> +       depends on !BR2_INSTALL_LIBSTDCPP
>> diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host
>> index fec8726aee..1aa5405abf 100644
>> --- a/package/rustc/Config.in.host
>> +++ b/package/rustc/Config.in.host
>> @@ -135,11 +135,15 @@ config BR2_PACKAGE_HOST_RUSTC_ABI
>>  config BR2_PACKAGE_HOST_RUSTC
>>         bool "host rustc"
>>         depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
>> +       depends on BR2_INSTALL_LIBSTDCPP # llvm
>>         help
>>           Compiler for the Rust language
>>
>>           http://www.rust-lang.org
>>
>> +comment "host-rustc needs a toolchain w/ C++"
>> +       depends on !BR2_INSTALL_LIBSTDCPP
>> +
>>  if BR2_PACKAGE_HOST_RUSTC
>>
>>  choice
>> diff --git a/package/sentry-cli/Config.in.host b/package/sentry-cli/Config.in.host
>> index 3124015367..d32c962338 100644
>> --- a/package/sentry-cli/Config.in.host
>> +++ b/package/sentry-cli/Config.in.host
>> @@ -1,6 +1,7 @@
>>  config BR2_PACKAGE_HOST_SENTRY_CLI
>>         bool "host sentry-cli"
>>         depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
>> +       depends on BR2_INSTALL_LIBSTDCPP # host-rustc
>>         select BR2_PACKAGE_HOST_RUSTC
>>         help
>>           Official Sentry command line interface
>> @@ -8,3 +9,6 @@ config BR2_PACKAGE_HOST_SENTRY_CLI
>>           For managing debug information files and source maps.
>>
>>           https://docs.sentry.io/cli/
>> +
>> +comment "host sentry-cli needs a toolchain w/ C++"
>> +       depends on !BR2_INSTALL_LIBSTDCPP
>> diff --git a/package/suricata/Config.in b/package/suricata/Config.in
>> index 5f7eb21da0..cdeba3f103 100644
>> --- a/package/suricata/Config.in
>> +++ b/package/suricata/Config.in
>> @@ -4,6 +4,7 @@ config BR2_PACKAGE_SURICATA
>>         depends on BR2_USE_MMU # fork()
>>         depends on BR2_USE_WCHAR
>>         depends on BR2_TOOLCHAIN_HAS_THREADS
>> +       depends on BR2_INSTALL_LIBSTDCPP # host-rustc
>>         select BR2_PACKAGE_HOST_RUSTC
>>         select BR2_PACKAGE_JANSSON
>>         select BR2_PACKAGE_LIBHTP
>> @@ -20,7 +21,7 @@ config BR2_PACKAGE_SURICATA
>>
>>           https://suricata-ids.org
>>
>> -comment "suricata needs a toolchain w/ wchar, threads"
>> +comment "suricata needs a toolchain w/ C++, wchar, threads"
>>         depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
>>         depends on BR2_USE_MMU
>> -       depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
>> +       depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || !BR2_INSTALL_LIBSTDCPP
>> --
>> 2.34.3
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot at buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot




More information about the buildroot mailing list