Hi,

I would like to change the bootstrap method used in lang/rust.

Currently, I strictly follow the vanilla build method: in order to build
rustc stable X.Y, you need a specific previous version of rustc called
"snapshot" (which itself needs a specific previous version...).

In order to simplify the port maintenance, I would like to use another
way: rebuild rustc stable X.Y with rustc stable X.Y. It makes bootstrap
rebuilding more simple, as the port itself will be able to rebuild a new
bootstrap, and I will no more need to keep several previous versions to
be able to rebuild the bootstrap.

I based my work on a feature commited in rustc 1.11.0 which permit
rebuilding rustc with same version. So I partially backported the
feature (only the part I actually use): it is the change in mk/main.mk.

I added a 'bootstrap' target which permit to rebuild a bootstrap. It is
mostly the same way that snapshot were previously builded.

I didn't bump REVISION as the change is a build change only, and it
shouldn't have any impact on the package itself.

Comments or OK ?
-- 
Sebastien Marie

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/rust/Makefile,v
retrieving revision 1.23
diff -u -p -r1.23 Makefile
--- Makefile    29 May 2016 07:26:46 -0000      1.23
+++ Makefile    8 Jun 2016 04:36:57 -0000
@@ -8,6 +8,7 @@ COMMENT-main =          compiler for Rust Langua
 COMMENT-doc =          html documentation for rustc
 
 V =                    1.9.0
+BV =                   ${V}-20160608
 DISTNAME =             rustc-${V}-src
 
 RUST_HASH !=           echo -n ${V} | md5 | cut -c1-8
@@ -19,9 +20,6 @@ PKGNAME-doc =         rust-doc-${V}
 
 MULTI_PACKAGES =       -main -doc
 
-# the snapshot version should be the version in src/snapshots.txt
-SNAPSHOT-amd64 =       
rust-stage0-2016-03-18-235d774-openbsd-x86_64-6d5adfe4301d158be8a5a33fb2e11bf857475cb3.tar.bz2
-
 CATEGORIES =           lang
 
 HOMEPAGE =             http://www.rust-lang.org/
@@ -40,11 +38,9 @@ MASTER_SITES0 =              http://semarie.free.fr/
 
 DIST_SUBDIR =          rust
 DISTFILES =            ${DISTNAME}${EXTRACT_SUFX}
-.if defined(SNAPSHOT-${MACHINE_ARCH})
-DISTFILES +=            ${SNAPSHOT-${MACHINE_ARCH}}:0
-.endif
+DISTFILES +=           rustc-bootstrap-${MACHINE_ARCH}-${BV}.tar.gz:0
 
-SUPDISTFILES =         ${SNAPSHOT-amd64}:0
+SUPDISTFILES =         rustc-bootstrap-amd64-${BV}.tar.gz:0
 
 WRKDIST =              ${WRKDIR}/${DISTNAME:S/-src//}
 
@@ -109,7 +105,7 @@ pre-configure:
 # - copy libestdc++ from MODGCC4 to specific directory
 #   in order to disambiguate version linking (having multiple libestdc++
 #   at build time)
-# - copy snapshot in stage0 (avoid downloading a snapshot)
+# - copy bootstrap in stage0 (avoid downloading)
 post-configure:
 .for _v in CFG_CURLORWGET CFG_GIT CFG_CLANG CFG_VALGRIND CFG_PERF CFG_ISCC \
        CFG_JAVAC CFG_ANTLR4 CFG_BISON CFG_PANDOC CFG_GDB CFG_LLDB \
@@ -119,13 +115,27 @@ post-configure:
        rm -rf ${WRKDIR}/modgcc-libs
        mkdir ${WRKDIR}/modgcc-libs
        cp ${LOCALBASE}/lib/libestdc++.so.${LIBESTDC_VERSION} 
${WRKDIR}/modgcc-libs
-       cp ${WRKDIR}/rust-stage0/bin/rustc \
+       cp ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${BV}/bin/rustc \
                ${WRKBUILD}/${TRIPLE_ARCH}/stage0/bin
-       cp ${WRKDIR}/rust-stage0/lib/lib*.so* \
+       cp ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${BV}/lib/lib*.so* \
                ${WRKBUILD}/${TRIPLE_ARCH}/stage0/lib
 
 post-install:
        # cleanup
        rm 
${PREFIX}/lib/rustlib/{install.log,uninstall.sh,rust-installer-version}
-       
+
+
+# bootstrap target permits to regenerate the bootstrap archive
+# it is based on stage3 binary
+BOOTSTRAPDIR=${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${V}-new
+bootstrap: configure
+       rm -rf ${BOOTSTRAPDIR}
+       mkdir -p ${BOOTSTRAPDIR}/{bin,lib}
+       cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} ${GMAKE} rustc-stage3
+       cp ${WRKBUILD}/${TRIPLE_ARCH}/stage3/bin/rustc ${BOOTSTRAPDIR}/bin
+       ldd ${BOOTSTRAPDIR}/bin/rustc \
+               | sed -ne 's,.* \(/.*/lib/lib.*\.so.[.0-9]*\)$$,\1,p' \
+               | xargs -r -J % cp % \
+                       ${BOOTSTRAPDIR}/lib
+
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/lang/rust/distinfo,v
retrieving revision 1.14
diff -u -p -r1.14 distinfo
--- distinfo    29 May 2016 07:26:46 -0000      1.14
+++ distinfo    8 Jun 2016 04:36:57 -0000
@@ -1,4 +1,4 @@
-SHA256 
(rust/rust-stage0-2016-03-18-235d774-openbsd-x86_64-6d5adfe4301d158be8a5a33fb2e11bf857475cb3.tar.bz2)
 = 8QZ/pf8S9dkMdbFw5kIU/x4VkwT51I9W1gyoFDt9tOQ=
 SHA256 (rust/rustc-1.9.0-src.tar.gz) = 
sZshGT19NgOd6+qqH2HL+YeH4M6UvYXFy+KllGLXz80=
-SIZE 
(rust/rust-stage0-2016-03-18-235d774-openbsd-x86_64-6d5adfe4301d158be8a5a33fb2e11bf857475cb3.tar.bz2)
 = 21260143
+SHA256 (rust/rustc-bootstrap-amd64-1.9.0-20160608.tar.gz) = 
+1dvjutKxR/9eBKi46JfFqgFWbkMYH/21zN24Rvhi5Y=
 SIZE (rust/rustc-1.9.0-src.tar.gz) = 25859714
+SIZE (rust/rustc-bootstrap-amd64-1.9.0-20160608.tar.gz) = 24387449
Index: patches/patch-mk_main_mk
===================================================================
RCS file: patches/patch-mk_main_mk
diff -N patches/patch-mk_main_mk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-mk_main_mk    8 Jun 2016 04:36:57 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+partial backport of 
https://github.com/rust-lang/rust/commit/dd6e8d45e183861d44ed91a99f0a50403b2776a3
+--- mk/main.mk.orig    Tue Jun  7 17:45:06 2016
++++ mk/main.mk Tue Jun  7 17:58:02 2016
+@@ -525,6 +525,9 @@ ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
+ CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
+ 
+ RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR1_T_$(2)_H_$$(CFG_BUILD))
++else
++# Assume the rustc already has stage1 features too.
++CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
+ endif
+ endif
+ 
Index: patches/patch-src_librustdoc_test_rs
===================================================================
RCS file: /cvs/ports/lang/rust/patches/patch-src_librustdoc_test_rs,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_librustdoc_test_rs
--- patches/patch-src_librustdoc_test_rs        25 May 2016 06:39:35 -0000      
1.1
+++ patches/patch-src_librustdoc_test_rs        8 Jun 2016 04:36:57 -0000
@@ -1,8 +1,8 @@
 $OpenBSD: patch-src_librustdoc_test_rs,v 1.1 2016/05/25 06:39:35 semarie Exp $
 fallback to CFG_PREFIX as default sysroot.
---- src/librustdoc/test.rs.orig        Mon Apr 11 23:22:04 2016
-+++ src/librustdoc/test.rs     Mon May 16 21:01:26 2016
-@@ -64,9 +64,16 @@ pub fn run(input: &str,
+--- src/librustdoc/test.rs.orig        Mon May 23 18:29:00 2016
++++ src/librustdoc/test.rs     Tue Jun  7 17:36:10 2016
+@@ -62,9 +62,16 @@ pub fn run(input: &str,
      let input_path = PathBuf::from(input);
      let input = config::Input::File(input_path.clone());
  
Index: patches/patch-src_libstd_sys_unix_os_rs
===================================================================
RCS file: /cvs/ports/lang/rust/patches/patch-src_libstd_sys_unix_os_rs,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_libstd_sys_unix_os_rs
--- patches/patch-src_libstd_sys_unix_os_rs     25 May 2016 06:39:35 -0000      
1.1
+++ patches/patch-src_libstd_sys_unix_os_rs     8 Jun 2016 04:36:57 -0000
@@ -1,8 +1,8 @@
 $OpenBSD: patch-src_libstd_sys_unix_os_rs,v 1.1 2016/05/25 06:39:35 semarie 
Exp $
 argv0 isn't suitable as current_exe() in all cases.
---- src/libstd/sys/unix/os.rs.orig     Mon Apr 11 23:22:04 2016
-+++ src/libstd/sys/unix/os.rs  Tue May 17 13:56:41 2016
-@@ -225,13 +225,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
+--- src/libstd/sys/unix/os.rs.orig     Mon May 23 18:29:00 2016
++++ src/libstd/sys/unix/os.rs  Tue Jun  7 17:36:10 2016
+@@ -235,13 +235,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
          argv.set_len(argv_len as usize);
          if argv[0].is_null() {
              return Err(io::Error::new(io::ErrorKind::Other,

Reply via email to