pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
mrust: new sub-package "mrust-rustclibs"
Module Name: pkgsrc-wip
Committed By: Dave Berger <pkgsrc-mrust%web5by5.com@localhost>
Pushed By: dave
Date: Thu Mar 30 14:11:02 2023 -0400
Changeset: ad93124f53ee30bc6e16dd024afaf414c104f287
Modified Files:
Makefile
mrust/Makefile
mrust/Makefile.common
Added Files:
mrust-rustclibs/DESCR
mrust-rustclibs/Makefile
mrust-rustclibs/PLIST
mrust-rustclibs/distinfo
mrust-rustclibs/patches/patch-.._rustc-1.54.0-src_library_std_src_sys_unix_thread.rs
Log Message:
mrust: new sub-package "mrust-rustclibs"
mrust-rustclibs provides the standard rust libraries needed
by mrust-rustc to compile a .rs file (e.g.,
rustc-1.54.0-src/src/test/ui/hello.rs) into a working
executable. The build of the pkg libraries is coordinated
by minicargo (as opposed to real cargo), but the actual code
is compiled by mrust-rustc (as opposed to mrustc).
Note that mrust-rustc, approximately, IS rustc: it's a full
build of, currently, version 1.54.0 of the compiler--from an
almost pristine rust-lang.org src tree (although the build
is of course done with mrustc & minicargo rather than with
an existing, official rustc & cargo, and there are therefore
a handful of needed patches applied to the tree first... see
rustc-1.54.0-src.patch in the mrustc src dist). mrustc,
OTOH, is a stripped-down, C++ implementation of a rust
compiler, developed mainly for bootstrapping rustc from
(rust-lang.org) src without rust binaries.
My hope, as a result, is that between mrust-rustc,
mrust-cargo & mrust-rustclibs, there is enough scaffolding
to bootstrap to rust 1.55 via the rust-lang.org srcs & the
appropriate vintage of pkgsrc/lang/rust; except, in this
case, without ANY other rust infrastructure: i.e., no
rust-lang.org binaries, nor a NetBSD rustc binary bootstrap
kit.
Wisdom from the author of mrustc, however, suggests that a
few more stages of the mrustc -> ... -> rustc 1.54 bootstrap
will likely be needed--so as to include some final elements
of a fully functional rustc toolchain--before the above will
work. If that turns out to be the case, mrust-rustclibs
will need to be updated to do a bunch more work...
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=ad93124f53ee30bc6e16dd024afaf414c104f287
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
mrust-rustclibs/DESCR | 23 ++++
mrust-rustclibs/Makefile | 137 +++++++++++++++++++++
mrust-rustclibs/PLIST | 16 +++
mrust-rustclibs/distinfo | 9 ++
...c-1.54.0-src_library_std_src_sys_unix_thread.rs | 43 +++++++
mrust/Makefile | 1 +
mrust/Makefile.common | 2 +
8 files changed, 232 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index b3663d7c67..c14da24c7c 100644
--- a/Makefile
+++ b/Makefile
@@ -2452,6 +2452,7 @@ SUBDIR+= mrust-llvm
SUBDIR+= mrust-minicargo
SUBDIR+= mrust-mrustc
SUBDIR+= mrust-rustc
+SUBDIR+= mrust-rustclibs
SUBDIR+= msgpack-git
SUBDIR+= mst-bench
SUBDIR+= msworkbench
diff --git a/mrust-rustclibs/DESCR b/mrust-rustclibs/DESCR
new file mode 100644
index 0000000000..d8fd76162d
--- /dev/null
+++ b/mrust-rustclibs/DESCR
@@ -0,0 +1,23 @@
+Mutabah's Rust Compiler
+
+ _In-progress_ alternative rust compiler. Capable of building a
+ fully-working copy of rustc, but not suitable for everyday use
+ (due to terrible error messages).
+
+This project is a "simple" rust compiler written in C++ that is
+able to bootstrap a "recent" rustc, but may eventually become a
+full separate re-implementation.
+
+`mrustc`'s primary goal is bootstrapping `rustc`, and as such it
+tends to assume that the code it's compiling is valid (and any
+errors in the generated code are mrustc bugs). Code generation is
+done by emitting a high-level assembly (currently very ugly C, but
+LLVM/cretone/GIMPLE/... could work) and getting an external tool
+(i.e. `gcc`) to do the heavy-lifting of optimising and machine code
+generation.
+
+=====
+
+This is the mrust rustc libs package. It contains the libraries
+(built by mrust-rustc) necessary to build executables using
+mrust-rustc.
diff --git a/mrust-rustclibs/Makefile b/mrust-rustclibs/Makefile
new file mode 100644
index 0000000000..9f0c0be1fb
--- /dev/null
+++ b/mrust-rustclibs/Makefile
@@ -0,0 +1,137 @@
+# $NetBSD: Makefile,v 1.1 2021/10/12 08:50:00 dlb Exp $
+
+.include "../../wip/mrust/Makefile.common"
+
+PKGNAME= mrust-rustclibs-${SNAPSTAMP}
+COMMENT= Rustc libraries & crates compiled using mrust-rustc
+
+DISTFILES= ${DEFAULT_DISTFILES} ${RUSTSRC_DIST}
+MRUST_DISTDIR= ${DISTDIR}/${DIST_SUBDIR}
+RUSTSRC_LINK= ${DISTDIR}/${DIST_SUBDIR}/${RUSTSRC_DIST}
+RUSTC_TARG= ${MACHINE_ARCH}-unknown-${OPSYS:tl}
+RUSTC_SRC= ${WRKSRC}/rustc-${RUSTVER}-src
+RUSTC_SRC_LIB= ${RUSTC_SRC}/library
+RUSTC_SRC_VEND= ${RUSTC_SRC}/vendor
+PREFIX_S= ${MR_OUTDIR}prefix-s
+LIBDIR_S= ${PREFIX_S}/lib/rustlib/${RUSTC_TARG}/lib
+RUSTC_S= ${WRKSRC}/bin/rustc
+####BUILD_TARGET= ${PREFIX_S}/lib/rustlib/${RUSTC_TARG}/lib/libstd.rlib
+##TEST_TARGET= test
+##TEST_MAKE_FLAGS= -o bin/mrustc -o LIBS
+MAKE_FILE= run_rustc/Makefile
+##MAKE_ENV+= LD_RUN_PATH=${PREFIX}/lib
+MAKE_ENV+= RUSTC_TARGET=${RUSTC_TARG}-unknown-${OPSYS:tl}
+##BUILD_MAKE_FLAGS+= MINICARGO_FLAGS="-L ${PREFIX}/lib/"
+
+##MAKE_JOBS_SAFE= no # DLBFLAG: this may be needed
+
+##UNLIMIT_RESOURCES= stacksize # DLBFLAG: stacksize doesn't need to
+ # be unlimited, but does seem to
+ # need to be higher than the default.
+ # The value that worked for me was
+ # 14m--but that probably could be
+ # tuned (or, simply use this UNLIMIT
+ # feature...?).
+
+USE_TOOLS+= gmake
+USE_LANGUAGES+= c c++14
+
+RUSTBIN= mrust-rustc
+RUSTCLIBS= ${PREFIX}/lib/mrust/rustc
+
+.if ${OPSYS:tl} == "macos" || ${OPSYS:tl} == "windows"
+MR_OVERRIDES= ${WRKSRC}/script-overrides/stable-${RUSTVER}-${OPSYS:tl}
+.else
+MR_OVERRIDES= ${WRKSRC}/script-overrides/stable-${RUSTVER}-linux
+.endif
+
+#* (no options yet) *#.include "options.mk"
+
+
+#
+# "De-duplicate" the rust source tarball.
+#
+# Without the following pre-fetch and pre-extract targets,
+# the mrust build infrastructure will needlessly download its
+# own, duplicate copy of the rust-lang source tarball into
+# distinfo/mrustc. Instead, this makes a hardlink from the
+# canonical location, if the tarball already exists there.
+#
+pre-fetch:
+ [ -e "${MRUST_DISTDIR}" ] || ${MKDIR} "${MRUST_DISTDIR}"
+ if [ -e "${DISTDIR}/${RUSTSRC_DIST}" ]; then \
+ ${LN} -f "${DISTDIR}/${RUSTSRC_DIST}" "${MRUST_DISTDIR}"; \
+ fi
+
+
+#
+# Once the checksum is verified, also make the rust source tarball
+# available in the expected location for real rust-src builds.
+# Note: be certain the checksum for the rust-lang tarball
+# in the mrust* distinfo files matches the one in the rust-src
+# distinfo files.
+#
+pre-extract:
+ [ -e ${DISTDIR}/${RUSTSRC_DIST} ] || \
+ ${LN} ${RUSTSRC_LINK} ${DISTDIR}/
+
+
+#
+# "put" (link?) mrustc & minicargo binaries and libraries into
+# directories where minicargo.mk will look for them.
+# Could buildlink3 help with this? (Probably not without changing
+# upstream Makefile[s]?)
+#
+# Extract & patch rustc src into the mrustc staging area
+#
+pre-build:
+ ${MKDIR} ${WRKSRC}/bin
+ ${MKDIR} ${WRKSRC}/run_rustc/${LIBDIR_S}
+ for ff in mrustc minicargo; do \
+ [ -e ${WRKSRC}/bin/$${ff} ] || \
+ ${LN} -s ${PREFIX}/bin/$${ff} ${WRKSRC}/bin; \
+ done
+ [ -e ${RUSTC_S} ] || \
+ ${LN} -s ${PREFIX}/bin/${RUSTBIN} ${RUSTC_S}
+ [ -d ${RUSTC_SRC} ] || \
+ ${MV} ${WRKDIR}/rustc-${RUSTVER}-src ${RUSTC_SRC}
+## ( cd ${WRKSRC} && ${PKGSRC_SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} \
+## ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} RUSTCSRC_Q )
+
+do-build:
+ ( cd ${WRKSRC}/run_rustc; \
+ for targ in std panic_unwind; do \
+ MRUSTC_PATH=${RUSTC_S} minicargo -j ${MAKE_JOBS:U1} \
+ --vendor-dir ${RUSTC_SRC_VEND} \
+ --script-overrides ${MR_OVERRIDES} \
+ --output-dir ${LIBDIR_S} ${RUSTC_SRC_LIB}/$$targ; \
+ done; )
+
+do-test:
+ ( cd ${WRKSRC} && \
+ ${PKGSRC_SETENV} ${TEST_ENV} \
+ ${MAKE_PROGRAM} ${MAKE_FLAGS} ${TEST_MAKE_FLAGS} \
+ ${TEST_TARGET} )
+
+
+####
+# The source Makefile doesn't have an "install:" target.
+# Use a simplistic workaround here.
+# [DLBFLAG:] Lacks support for MS Windows STYLE ".EXE" suffixes.
+##
+do-install:
+ ${PKGSRC_SETENV} ${INSTALL_ENV} \
+ ${INSTALL_LIB_DIR} ${DESTDIR}${RUSTCLIBS}
+ ( cd ${WRKSRC}/run_rustc/${LIBDIR_S} && \
+ for ff in lib*.rlib ; do \
+ ${PKGSRC_SETENV} ${INSTALL_ENV} \
+ ${INSTALL_LIB} $$ff \
+ ${DESTDIR}${RUSTCLIBS}; \
+ done )
+
+BUILD_DEPENDS+= mrust-rustc>=${SNAPSTAMP}:../../wip/mrust-rustc
+BUILD_DEPENDS+= mrust-minicargo>=${SNAPSTAMP}:../../wip/mrust-minicargo
+
+##.include "../../devel/libatomic/buildlink3.mk"
+##.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mrust-rustclibs/PLIST b/mrust-rustclibs/PLIST
new file mode 100644
index 0000000000..28da3e5a75
--- /dev/null
+++ b/mrust-rustclibs/PLIST
@@ -0,0 +1,16 @@
+@comment $NetBSD$
+lib/mrust/rustc/liballoc.rlib
+lib/mrust/rustc/libcfg_if-0_1_10.rlib
+lib/mrust/rustc/libcfg_if-0_1_10_H3.rlib
+lib/mrust/rustc/libcompiler_builtins-0_1_45_H82.rlib
+lib/mrust/rustc/libcore.rlib
+lib/mrust/rustc/libhashbrown-0_11_0_H328.rlib
+lib/mrust/rustc/liblibc-0_2_95_H19.rlib
+lib/mrust/rustc/libpanic_abort.rlib
+lib/mrust/rustc/libpanic_unwind.rlib
+lib/mrust/rustc/librustc_demangle-0_1_19_H3.rlib
+lib/mrust/rustc/librustc_std_workspace_alloc-1_99_0.rlib
+lib/mrust/rustc/librustc_std_workspace_core-1_99_0.rlib
+lib/mrust/rustc/libstd.rlib
+lib/mrust/rustc/libstd_detect-0_1_5_H5.rlib
+lib/mrust/rustc/libunwind.rlib
diff --git a/mrust-rustclibs/distinfo b/mrust-rustclibs/distinfo
new file mode 100644
index 0000000000..95dd6438b0
--- /dev/null
+++ b/mrust-rustclibs/distinfo
@@ -0,0 +1,9 @@
+$NetBSD$
+
+BLAKE2s (mrustc/998dc164309d7d707e5c1c38dd61c0b95169cbcf-998dc164309d7d707e5c1c38dd61c0b95169cbcf.zip) = 1fe2a83390c442e81df1b69d8d5e704e7f6001e4f3a04f5f54b9c48701b299ba
+SHA512 (mrustc/998dc164309d7d707e5c1c38dd61c0b95169cbcf-998dc164309d7d707e5c1c38dd61c0b95169cbcf.zip) = ede7bee90a5b14548fb86c91b78d20a0c7847ab6795040399bbb6d6435985470f175ffe26262e3a86ab1c33a7ffa011ba09cddd6857ca8b5d3c1d7d9cfd96b09
+Size (mrustc/998dc164309d7d707e5c1c38dd61c0b95169cbcf-998dc164309d7d707e5c1c38dd61c0b95169cbcf.zip) = 1454068 bytes
+BLAKE2s (mrustc/rustc-1.54.0-src.tar.gz) = 32d3daf2fd75236ca054e86eb31c570fb70c813f1ab6a28ea211416aa4529a74
+SHA512 (mrustc/rustc-1.54.0-src.tar.gz) = f6a1d925e233ef40351193e5507d74b1aed13ce516679558c246e6b6955a6ef393d7e61e6c51a0c5696a7e40a9dcee026bea938b954f5ea5394854cc3ca67f90
+Size (mrustc/rustc-1.54.0-src.tar.gz) = 170480637 bytes
+SHA1 (patch-.._rustc-1.54.0-src_library_std_src_sys_unix_thread.rs) = 56f21806645071eebccfdbc0fdfdbfc071f59e9e
diff --git a/mrust-rustclibs/patches/patch-.._rustc-1.54.0-src_library_std_src_sys_unix_thread.rs b/mrust-rustclibs/patches/patch-.._rustc-1.54.0-src_library_std_src_sys_unix_thread.rs
new file mode 100644
index 0000000000..84663ada52
--- /dev/null
+++ b/mrust-rustclibs/patches/patch-.._rustc-1.54.0-src_library_std_src_sys_unix_thread.rs
@@ -0,0 +1,43 @@
+$NetBSD$
+
+--- ../rustc-1.54.0-src/library/std/src/sys/unix/thread.rs.orig 2021-07-26 14:43:02.000000000 +0000
++++ ../rustc-1.54.0-src/library/std/src/sys/unix/thread.rs
+@@ -357,6 +357,21 @@ pub mod guard {
+ const GUARD_PAGES: usize = 1;
+ let guard = guardaddr..guardaddr + GUARD_PAGES * page_size;
+ Some(guard)
++ } else if cfg!(target_os = "netbsd") {
++ // [The following should be reviewed/confirmed, -DLB]:
++ // Using the default else clause below, sporadic guard page
++ // errors were occurring during builds of rustc & cargo with
++ // mrustc on NetBSD; however, NetBSD has a kernel-based
++ // guard area mechanism too. Therefore, try relying on that
++ // instead of the default mmap/mprotect solution; but note:
++ // if userland code changes the stack address, the NetBSD
++ // kernel-based guard mechanism is deactivated (see
++ // pthread_attr_getstack(3)) and the userland code must
++ // manage a guard area itself. Fortunately, the stack
++ // appears to be unchanged by this version of thread.rs
++ let stackaddr = get_stack_start_aligned()?;
++ let stackaddr = stackaddr as usize;
++ Some(stackaddr - page_size..stackaddr)
+ } else {
+ // Reallocate the last page of the stack.
+ // This ensures SIGBUS will be raised on
+@@ -376,11 +391,16 @@ pub mod guard {
+ 0,
+ );
+ if result != stackaddr || result == MAP_FAILED {
++ println!( "stackaddr = {}", stackaddr as u64 );
++ println!( "mmap() -> result {}", result as u64 );
++ println!( "mmap() -> ERRNO {}", os::errno() as u64 );
+ panic!("failed to allocate a guard page: {}", io::Error::last_os_error());
+ }
+
+ let result = mprotect(stackaddr, page_size, PROT_NONE);
+ if result != 0 {
++ println!( "stackaddr = {}", stackaddr as u64 );
++ println!( "mprotect() -> ERRNO {}", os::errno() as u64 );
+ panic!("failed to protect the guard page: {}", io::Error::last_os_error());
+ }
+
diff --git a/mrust/Makefile b/mrust/Makefile
index 37450676ad..9e0170da1c 100644
--- a/mrust/Makefile
+++ b/mrust/Makefile
@@ -16,6 +16,7 @@ DEPENDS+= mrust-minicargo>=${SNAPSTAMP}:../../wip/mrust-minicargo
DEPENDS+= mrust-libs>=${SNAPSTAMP}:../../wip/mrust-libs
DEPENDS+= mrust-rustc>=${SNAPSTAMP}:../../wip/mrust-rustc
DEPENDS+= mrust-cargo>=${SNAPSTAMP}:../../wip/mrust-cargo
+DEPENDS+= mrust-rustclibs>=${SNAPSTAMP}:../../wip/mrust-rustclibs
do-build:
diff --git a/mrust/Makefile.common b/mrust/Makefile.common
index 9f8347f824..0e62457f9b 100644
--- a/mrust/Makefile.common
+++ b/mrust/Makefile.common
@@ -5,6 +5,7 @@
### used by lang/mrust-libs/Makefile
### used by lang/mrust-rustc/Makefile
### used by lang/mrust-cargo/Makefile
+### used by lang/mrust-rustclibs/Makefile
### used by lang/mrust/Makefile
#
# used by wip/mrust-mrustc/Makefile
@@ -12,6 +13,7 @@
# used by wip/mrust-libs/Makefile
# used by wip/mrust-rustc/Makefile
# used by wip/mrust-cargo/Makefile
+# used by wip/mrust-rustclibs/Makefile
# used by wip/mrust/Makefile
# used by (etc)
Home |
Main Index |
Thread Index |
Old Index