The rust language is gaining popularity, so we will reach a point where tools and libraries we want to use will be written in rust. As such, we need a rust compiler in our build system. Building rust is a pain, though, as the compiler is also written in rust. To build it, you need an existing rust compiler. And you generally need a fairly new one. This is a problem for us, as we want a portable and reproducible build system. There exists this project, which is a rust compiler written in C++, that is only meant for bootstrapping the normal rust compiler: https://github.com/thepowersgang/mrustc It doesn't support the latest version of rust, but it might be good enough. Or it could be a springboard to building a newer rust. There is also this project that tries to wrap the above in some convenience script, incrementally building newer and newer versions of rust using the previously built version: https://github.com/dtolnay/bootstrap
I attempted to build mrustc here, but unfortunately it crashes our gcc with some internal error: > In file included from src/trans/codegen_c.cpp:17:0: > src/trans/codegen_c.cpp: In instantiation of '{anonymous}::CodeGenerator_C::emit_struct_inner(const HIR::TypeRef&, const TypeRepr*, unsigned int)::<lambda(auto:7&)> [with auto:7 = std::basic_ostream<char>]': > /usr/include/c++/5.5.0/type_traits:2346:26: required by substitution of 'template<class _Fn, class ... _Args> static std::__success_type<decltype (declval<_Fn>()((declval<_Args>)()...))> std::__result_of_other_impl::_S_test(int) [with _Fn = {anonymous}::CodeGenerator_C::emit_struct_inner(const HIR::TypeRef&, const TypeRepr*, unsigned int)::<lambda(auto:7&)>&; _Args = {std::basic_ostream<char, std::char_traits<char> >&}]' > /usr/include/c++/5.5.0/type_traits:2357:55: required from 'struct std::__result_of_impl<false, false, {anonymous}::CodeGenerator_C::emit_struct_inner(const HIR::TypeRef&, const TypeRepr*, unsigned int)::<lambda(auto:7&)>&, std::basic_ostream<char, std::char_traits<char> >&>' > /usr/include/c++/5.5.0/type_traits:2361:12: required from 'class std::result_of<{anonymous}::CodeGenerator_C::emit_struct_inner(const HIR::TypeRef&, const TypeRepr*, unsigned int)::<lambda(auto:7&)>&(std::basic_ostream<char>&)>' > /usr/include/c++/5.5.0/functional:2053:9: required by substitution of 'template<class _Functor, class, class> std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = {anonymous}::CodeGenerator_C::emit_struct_inner(const HIR::TypeRef&, const TypeRepr*, unsigned int)::<lambda(auto:7&)>; <template-parameter-1-2> = void; <template-parameter-1-3> = <missing>]' > src/trans/codegen_c.cpp:1682:21: required from here > src/trans/codegen_c.cpp:1682:144: internal compiler error: Segmentation fault > MIR_ASSERT(*m_mir_res, cur_ofs <= offset, "Current offset is already past expected (#" << fld << "): " << cur_ofs << " > " << offset); > ^ > src/mir/helpers.hpp:40:159: note: in definition of macro 'MIR_ASSERT' > #define MIR_ASSERT(state, cnd, ...) do { if( !(cnd) ) (state).print_bug( [&](auto& _os){_os << __FILE__ << ":" << __LINE__ << " ASSERT " #cnd " failed - " << __VA_ARGS__; } ); } while(0) > ^ > Please submit a full bug report, > with preprocessed source if appropriate. > See <http://gcc.gnu.org/bugs.html> for instructions. > make[1]: *** [.obj/trans/codegen_c.o] Error 1