summaryrefslogtreecommitdiff
path: root/dev-lang/mrustc
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/mrustc')
-rw-r--r--dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround-more.patch79
-rw-r--r--dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround.patch12
-rw-r--r--dev-lang/mrustc/mrustc-0.11.2-r1.ebuild110
-rw-r--r--dev-lang/mrustc/mrustc-9999.ebuild2
4 files changed, 203 insertions, 0 deletions
diff --git a/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround-more.patch b/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround-more.patch
new file mode 100644
index 000000000000..a9207f79472a
--- /dev/null
+++ b/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround-more.patch
@@ -0,0 +1,79 @@
+Pass -U_GLIBCXX_ASSERTIONS when building mrustc as a workaround (not yet
+reported, sorry).
+--- a/Makefile
++++ b/Makefile
+@@ -47,7 +47,7 @@ CXXFLAGS := -g -Wall
+ CXXFLAGS += -std=c++14
+ #CXXFLAGS += -Wextra
+ CXXFLAGS += -O2
+-CXXFLAGS += $(CXXFLAGS_EXTRA)
++CXXFLAGS += $(CXXFLAGS_EXTRA) -U_GLIBCXX_ASSERTIONS
+
+ CPPFLAGS := -I src/include/ -I src/
+ CPPFLAGS += -I tools/common/
+--- a/tools/common/Makefile
++++ b/tools/common/Makefile
+@@ -12,7 +12,7 @@ OBJS += jobserver.o
+
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+
+-CXXFLAGS += $(CXXFLAGS_EXTRA)
++CXXFLAGS += $(CXXFLAGS_EXTRA) -U_GLIBCXX_ASSERTIONS
+
+ OBJS := $(OBJS:%=$(OBJDIR)%)
+
+--- a/tools/dump_hirfile/Makefile
++++ b/tools/dump_hirfile/Makefile
+@@ -16,7 +16,7 @@ OBJS := main.o
+
+ LINKFLAGS := -g -lpthread -lz
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+-CXXFLAGS += -I ../common -I ../../src -I ../../src/include
++CXXFLAGS += -I ../common -I ../../src -I ../../src/include -U_GLIBCXX_ASSERTIONS
+
+ CXXFLAGS += $(CXXFLAGS_EXTRA)
+ LINKFLAGS += $(LINKFLAGS_EXTRA)
+--- a/tools/minicargo/Makefile
++++ b/tools/minicargo/Makefile
+@@ -23,7 +23,7 @@ OBJS += file_timestamp.o os.o
+
+ LINKFLAGS := -g -lpthread
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+-CXXFLAGS += -I ../common
++CXXFLAGS += -I ../common -U_GLIBCXX_ASSERTIONS
+
+ CXXFLAGS += $(CXXFLAGS_EXTRA)
+ LINKFLAGS += $(LINKFLAGS_EXTRA)
+--- a/tools/mir_opt_test/Makefile
++++ b/tools/mir_opt_test/Makefile
+@@ -16,7 +16,7 @@ LIBS := ../../bin/mrustc.a ../../bin/common_lib.a
+
+ LINKFLAGS := -g -lpthread -lz
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+-CXXFLAGS += -I ../common -I ../../src/include -I ../../src -I .
++CXXFLAGS += -I ../common -I ../../src/include -I ../../src -I . -U_GLIBCXX_ASSERTIONS
+ CXXFLAGS += -Wno-misleading-indentation # Gets REALLY confused by the TU_ARM macro
+
+ CXXFLAGS += $(CXXFLAGS_EXTRA)
+--- a/tools/standalone_miri/Makefile
++++ b/tools/standalone_miri/Makefile
+@@ -16,7 +16,7 @@ OBJS += miri.o miri_extern.o miri_intrinsic.o
+
+ LINKFLAGS := -g -lpthread
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+-CXXFLAGS += -I ../common -I ../../src/include -I .
++CXXFLAGS += -I ../common -I ../../src/include -I . -U_GLIBCXX_ASSERTIONS
+ CXXFLAGS += -Wno-misleading-indentation # Gets REALLY confused by the TU_ARM macro
+
+ CXXFLAGS += $(CXXFLAGS_EXTRA)
+--- a/tools/testrunner/Makefile
++++ b/tools/testrunner/Makefile
+@@ -8,7 +8,7 @@ OBJS := main.o path.o
+ LINKFLAGS := -g
+ CXXFLAGS := -Wall -std=c++14 -g -O2
+
+-CXXFLAGS += $(CXXFLAGS_EXTRA)
++CXXFLAGS += $(CXXFLAGS_EXTRA) -U_GLIBCXX_ASSERTIONS
+ LINKFLAGS += $(LINKFLAGS_EXTRA)
+
+ OBJS := $(OBJS:%=$(OBJDIR)%)
diff --git a/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround.patch b/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround.patch
new file mode 100644
index 000000000000..516bca4ac13c
--- /dev/null
+++ b/dev-lang/mrustc/files/mrustc-0.11.2-no-glibcxx-assertions-workaround.patch
@@ -0,0 +1,12 @@
+We need this otherwise the built code will assert when building dev-lang/rust
+later. Not yet reported upstream.
+--- a/src/trans/codegen_c.cpp
++++ b/src/trans/codegen_c.cpp
+@@ -1274,6 +1274,7 @@ namespace {
+ {
+ args.push_back( a.c_str() );
+ }
++ args.push_back("-U_GLIBCXX_ASSERTIONS"); // TODO
+ args.push_back("-Wno-psabi"); // Suppress "note: the ABI for passing parameters with 128-byte alignment has changed in GCC 4.6"
+ switch(opt.opt_level)
+ {
diff --git a/dev-lang/mrustc/mrustc-0.11.2-r1.ebuild b/dev-lang/mrustc/mrustc-0.11.2-r1.ebuild
new file mode 100644
index 000000000000..12add5b79790
--- /dev/null
+++ b/dev-lang/mrustc/mrustc-0.11.2-r1.ebuild
@@ -0,0 +1,110 @@
+# Copyright 2024-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit edo multiprocessing rust-toolchain toolchain-funcs
+
+# The makefile needs to know the version of rust to build
+RUST_VERSION=1.74.1
+# We need to pretend to be this version of Rust for mrustc build and outputs
+MRUSTC_RUST_VER=1.74.0
+
+DESCRIPTION="Mutabah's Rust Compiler"
+HOMEPAGE="https://github.com/thepowersgang/mrustc"
+
+if [[ ${PV} == *"9999"* ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/thepowersgang/mrustc.git"
+else
+ SRC_URI="https://github.com/thepowersgang/mrustc/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
+ https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz
+ "
+ KEYWORDS="~amd64"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+
+DEPEND="sys-libs/zlib"
+# mrustc transpiles Rust to C, and currently the C code it generates doesn't currently work with clang
+RDEPEND="
+ ${DEPEND}
+ sys-devel/gcc:*
+"
+BDEPEND="sys-devel/gcc:*"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.11.2-gcc15.patch"
+ "${FILESDIR}/${PN}-0.11.2-dont-strip-bins.patch"
+ "${FILESDIR}/${PN}-0.11.0-default-to-rust-1_74.patch"
+ "${FILESDIR}/${PN}-0.11.0-RUSTC_SRC_PROVIDED.patch"
+ "${FILESDIR}/${PN}-0.10.1-git-be-gone.patch"
+ "${FILESDIR}/${PN}-0.11.2-no-glibcxx-assertions-workaround.patch"
+ "${FILESDIR}/${PN}-0.11.2-no-glibcxx-assertions-workaround-more.patch"
+)
+
+QA_FLAGS_IGNORED="
+ usr/lib/rust/${P}/bin/mrustc
+ usr/lib/rust/${P}/bin/minicargo
+ usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib/*.rlib
+"
+
+pkg_setup() {
+ if [[ ${MERGE_TYPE} != binary ]] && ! tc-is-gcc; then
+ die "mrustc needs to be built using GCC."
+ fi
+}
+
+src_configure() {
+ :
+}
+
+src_compile() {
+ export PARLEVEL=$(makeopts_jobs)
+ export RUSTC_VERSION=${MRUSTC_RUST_VER} # Pretend that we're using upstream-supported Rust
+ export MRUSTC_TARGET_VER=${RUSTC_VERSION%.*}
+ export RUSTCSRC="${WORKDIR}/rustc-${RUST_VERSION}-src"
+ export RUSTC_SRC_PROVIDED=1
+ export V='' # echo build commands in makefiles (minicargo still writes commands to file)
+ # build mrustc & minicargo then use them to build the standard library
+ # emake -f minicargo.mk will do everything including a full bootstrap
+ emake all
+ emake -C tools/minicargo/
+ # It's not much, but it's enough to do a 'hello world' at least... and build dev-lang/rust!
+ emake -e -f minicargo.mk LIBS
+}
+
+src_test() {
+ # The main makefile test targets just do this, cut out the middleman
+ emake -e -f minicargo.mk local_tests
+ # build and run 'hello world' (this is called using 'test' in the makefile, but we can do it manually)
+ edo "${S}"/bin/mrustc -L "${S}"/output-${MRUSTC_RUST_VER}/ \
+ -g "${S}/../rustc-${RUST_VERSION}-src/tests/ui/hello_world/main.rs" -o "${T}"/hello
+ "${T}"/hello || die "Failed to run hello_world built with mrustc"
+}
+
+src_install() {
+ # If we're installing into /usr/lib/rust we may as well be consistent
+ into /usr/lib/rust/${P}
+ dobin bin/mrustc
+ dobin bin/minicargo
+ local lib patch
+ local libs=( "${S}"/output-*/*.rlib* )
+ insinto "/usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib"
+ # If we ever want to support mrustc stdlib for multiple rusts we'll need to
+ # do something more clever here.
+ for lib in "${libs[@]}"; do
+ # We only want .rlib{,.hir,o}
+ if [[ ${lib} != *.c && ${lib} != *.d && ${lib} != *.txt ]]; then
+ doins "${lib}"
+ fi
+ done
+ # For convenience, install files required to build various rusts
+ insinto /usr/share/${P}
+ doins -r "${S}/script-overrides/"
+ insinto /usr/share/${P}/patches
+ for patch in "${S}"/rustc-*.patch "${S}"/rustc-*-overrides.toml; do
+ doins "${patch}"
+ done
+}
diff --git a/dev-lang/mrustc/mrustc-9999.ebuild b/dev-lang/mrustc/mrustc-9999.ebuild
index 2d39a52cbcb6..8a3d460ca787 100644
--- a/dev-lang/mrustc/mrustc-9999.ebuild
+++ b/dev-lang/mrustc/mrustc-9999.ebuild
@@ -37,6 +37,8 @@ BDEPEND="sys-devel/gcc:*"
PATCHES=(
"${FILESDIR}/${PN}-0.11.0-default-to-rust-1_74.patch"
"${FILESDIR}/${PN}-0.11.0-RUSTC_SRC_PROVIDED.patch"
+ "${FILESDIR}/${PN}-0.11.2-no-glibcxx-assertions-workaround.patch"
+ "${FILESDIR}/${PN}-0.11.2-no-glibcxx-assertions-workaround-more.patch"
)
QA_FLAGS_IGNORED="