Advertisement
Guest User

mrustc-0.11.2.ebuild

a guest
Mar 15th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | Software | 0 0
  1. # Copyright 2024-2025 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3.  
  4. EAPI=8
  5.  
  6. inherit edo multiprocessing rust-toolchain toolchain-funcs
  7.  
  8. # The makefile needs to know the version of rust to build
  9. RUST_VERSION=1.74.1
  10. # We need to pretend to be this version of Rust for mrustc build and outputs
  11. MRUSTC_RUST_VER=1.74.0
  12.  
  13. DESCRIPTION="Mutabah's Rust Compiler"
  14. HOMEPAGE="https://github.com/thepowersgang/mrustc"
  15.  
  16. if [[ ${PV} == *"9999"* ]]; then
  17. inherit git-r3
  18. EGIT_REPO_URI="https://github.com/thepowersgang/mrustc.git"
  19. else
  20. SRC_URI="https://github.com/thepowersgang/mrustc/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
  21. https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz
  22. "
  23. KEYWORDS="~amd64"
  24. fi
  25.  
  26. LICENSE="MIT"
  27. SLOT="0"
  28.  
  29. DEPEND="sys-libs/zlib"
  30. # mrustc transpiles Rust to C, and currently the C code it generates doesn't currently work with clang
  31. RDEPEND="
  32. ${DEPEND}
  33. sys-devel/gcc:*
  34. "
  35. BDEPEND="sys-devel/gcc:*"
  36.  
  37. PATCHES=(
  38. "${FILESDIR}/${PN}-0.11.2-gcc15.patch"
  39. "${FILESDIR}/${PN}-0.11.2-dont-strip-bins.patch"
  40. "${FILESDIR}/${PN}-0.11.0-default-to-rust-1_74.patch"
  41. "${FILESDIR}/${PN}-0.11.0-RUSTC_SRC_PROVIDED.patch"
  42. "${FILESDIR}/${PN}-0.10.1-git-be-gone.patch"
  43. )
  44.  
  45. QA_FLAGS_IGNORED="
  46. usr/lib/rust/${P}/bin/mrustc
  47. usr/lib/rust/${P}/bin/minicargo
  48. usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib/*.rlib
  49. "
  50.  
  51. pkg_setup() {
  52. echo "yay no pkg setup"
  53. # if [[ ${MERGE_TYPE} != binary ]] && ! tc-is-gcc; then
  54. # die "mrustc needs to be built using GCC."
  55. # fi
  56. }
  57.  
  58. src_configure() {
  59. :
  60. }
  61.  
  62. src_compile() {
  63. export PARLEVEL=$(makeopts_jobs)
  64. export RUSTC_VERSION=${MRUSTC_RUST_VER} # Pretend that we're using upstream-supported Rust
  65. export MRUSTC_TARGET_VER=${RUSTC_VERSION%.*}
  66. export RUSTCSRC="${WORKDIR}/rustc-${RUST_VERSION}-src"
  67. export RUSTC_SRC_PROVIDED=1
  68. export V='' # echo build commands in makefiles (minicargo still writes commands to file)
  69. # build mrustc & minicargo then use them to build the standard library
  70. # emake -f minicargo.mk will do everything including a full bootstrap
  71. emake all
  72. emake -C tools/minicargo/
  73. # It's not much, but it's enough to do a 'hello world' at least... and build dev-lang/rust!
  74. emake -e -f minicargo.mk LIBS
  75. }
  76.  
  77. src_test() {
  78. # The main makefile test targets just do this, cut out the middleman
  79. emake -e -f minicargo.mk local_tests
  80. # build and run 'hello world' (this is called using 'test' in the makefile, but we can do it manually)
  81. edo "${S}"/bin/mrustc -L "${S}"/output-${MRUSTC_RUST_VER}/ \
  82. -g "${S}/../rustc-${RUST_VERSION}-src/tests/ui/hello_world/main.rs" -o "${T}"/hello
  83. "${T}"/hello || die "Failed to run hello_world built with mrustc"
  84. }
  85.  
  86. src_install() {
  87. # If we're installing into /usr/lib/rust we may as well be consistent
  88. into /usr/lib/rust/${P}
  89. dobin bin/mrustc
  90. dobin bin/minicargo
  91. local lib patch
  92. local libs=( "${S}"/output-*/*.rlib* )
  93. insinto "/usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib"
  94. # If we ever want to support mrustc stdlib for multiple rusts we'll need to
  95. # do something more clever here.
  96. for lib in "${libs[@]}"; do
  97. # We only want .rlib{,.hir,o}
  98. if [[ ${lib} != *.c && ${lib} != *.d && ${lib} != *.txt ]]; then
  99. doins "${lib}"
  100. fi
  101. done
  102. # For convenience, install files required to build various rusts
  103. insinto /usr/share/${P}
  104. doins -r "${S}/script-overrides/"
  105. insinto /usr/share/${P}/patches
  106. for patch in "${S}"/rustc-*.patch "${S}"/rustc-*-overrides.toml; do
  107. doins "${patch}"
  108. done
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement