Message ID | 20220726140245.692606-1-romain.naour@smile.fr |
---|---|
State | Superseded |
Headers | show |
Series | [PATCHv2] package/rustc: needs C++ compiler with musl based toolchain | expand |
Romain, All, On 2022-07-26 16:02 +0200, Romain Naour spake thusly: > 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. > > We could add the C++ dependency direclty to host-rustc but it would > requires adding the C++ reverse dependencies to all rust packages. > > Instread, we add the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS > only when a musl toolchain is used. So we can still install a prebuilt > rust compiler but without the rust standard library (rust-std). > > 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. > > Fixes: > http://autobuild.buildroot.org/results/636/636fb39c8f1b8c05e4ca451ac506cd63c7166d82 > > Signed-off-by: Romain Naour <romain.naour@smile.fr> > --- > v2: move the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS > after James's review and discussion with Thomas and Arnout > --- > package/rustc/Config.in.host | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host > index fec8726aee..32decba7c1 100644 > --- a/package/rustc/Config.in.host > +++ b/package/rustc/Config.in.host > @@ -110,11 +110,17 @@ config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS > default y if BR2_sparc64 && BR2_TOOLCHAIN_USES_GLIBC > > # All target rust packages should depend on this option > +# Note: With musl based toolchain, we need a C++ compiler on the host to > +# build host-rust some target libraries (libunwind) from llvm source code > +# bundled in rust sources. > config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS > bool > - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS > - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS > - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS > + 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 I think it would be much nicer to add a global dependency: config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS bool default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS depends on BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL And that's all... Also, as reported on IRC, rustc fails to link with our libz: error: linking with `cc` failed: exit status: 1 | = note: "cc" [...] = note: /usr/bin/ld: cannot find -lz collect2: error: ld returned 1 exit status error: could not compile `rustc_driver` due to previous error But earlier duing the build: -- Found ZLIB: /home/ymorin/dev/buildroot/O/master/host/lib/libz.so (found version "1.2.12") I've run out of time today to look into that... Regards, Yann E. MORIN. > config BR2_PACKAGE_HOST_RUSTC_ARCH > -- > 2.34.3 > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Yann, Le 26/07/2022 à 16:36, Yann E. MORIN a écrit : > Romain, All, > > On 2022-07-26 16:02 +0200, Romain Naour spake thusly: >> 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. >> >> We could add the C++ dependency direclty to host-rustc but it would >> requires adding the C++ reverse dependencies to all rust packages. >> >> Instread, we add the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS >> only when a musl toolchain is used. So we can still install a prebuilt >> rust compiler but without the rust standard library (rust-std). >> >> 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. >> >> Fixes: >> http://autobuild.buildroot.org/results/636/636fb39c8f1b8c05e4ca451ac506cd63c7166d82 >> >> Signed-off-by: Romain Naour <romain.naour@smile.fr> >> --- >> v2: move the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS >> after James's review and discussion with Thomas and Arnout >> --- >> package/rustc/Config.in.host | 12 +++++++++--- >> 1 file changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host >> index fec8726aee..32decba7c1 100644 >> --- a/package/rustc/Config.in.host >> +++ b/package/rustc/Config.in.host >> @@ -110,11 +110,17 @@ config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS >> default y if BR2_sparc64 && BR2_TOOLCHAIN_USES_GLIBC >> >> # All target rust packages should depend on this option >> +# Note: With musl based toolchain, we need a C++ compiler on the host to >> +# build host-rust some target libraries (libunwind) from llvm source code >> +# bundled in rust sources. >> config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS >> bool >> - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS >> - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS >> - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS >> + 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 > > I think it would be much nicer to add a global dependency: > > config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS > bool > default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS > default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS > default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS > depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS > depends on BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL > > And that's all... Ok > > Also, as reported on IRC, rustc fails to link with our libz: > > error: linking with `cc` failed: exit status: 1 > | > = note: "cc" [...] > = note: /usr/bin/ld: cannot find -lz > collect2: error: ld returned 1 exit status > error: could not compile `rustc_driver` due to previous error > > But earlier duing the build: > > -- Found ZLIB: /home/ymorin/dev/buildroot/O/master/host/lib/libz.so (found version "1.2.12") I can't reproduce locally, but it's reproduced on autobuilders: http://autobuild.buildroot.org/results/724/7248c264c9f4fcbb95f111736d20f8af31678502/build-end.log Since host-zlib is already build, maybe rust try to link with libz installed on the build machine? Best regards, Romain > > I've run out of time today to look into that... > > Regards, > Yann E. MORIN. > >> config BR2_PACKAGE_HOST_RUSTC_ARCH >> -- >> 2.34.3 >> >> _______________________________________________ >> buildroot mailing list >> buildroot@buildroot.org >> https://lists.buildroot.org/mailman/listinfo/buildroot >
diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host index fec8726aee..32decba7c1 100644 --- a/package/rustc/Config.in.host +++ b/package/rustc/Config.in.host @@ -110,11 +110,17 @@ config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS default y if BR2_sparc64 && BR2_TOOLCHAIN_USES_GLIBC # All target rust packages should depend on this option +# Note: With musl based toolchain, we need a C++ compiler on the host to +# build host-rust some target libraries (libunwind) from llvm source code +# bundled in rust sources. config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS bool - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS - default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS + 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 config BR2_PACKAGE_HOST_RUSTC_ARCH
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. We could add the C++ dependency direclty to host-rustc but it would requires adding the C++ reverse dependencies to all rust packages. Instread, we add the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS only when a musl toolchain is used. So we can still install a prebuilt rust compiler but without the rust standard library (rust-std). 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. Fixes: http://autobuild.buildroot.org/results/636/636fb39c8f1b8c05e4ca451ac506cd63c7166d82 Signed-off-by: Romain Naour <romain.naour@smile.fr> --- v2: move the C++ dependency to BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS after James's review and discussion with Thomas and Arnout --- package/rustc/Config.in.host | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)