Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136470596
D31243.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D31243.diff
View Options
Index: Mk/bsd.port.mk
===================================================================
--- Mk/bsd.port.mk
+++ Mk/bsd.port.mk
@@ -2106,6 +2106,7 @@
.endif
.include "${PORTSDIR}/Mk/bsd.ccache.mk"
+.include "${PORTSDIR}/Mk/bsd.sccache.mk"
.if !make(makesum)
FETCH_ENV?= SSL_NO_VERIFY_PEER=1 SSL_NO_VERIFY_HOSTNAME=1
@@ -5306,7 +5307,7 @@
300:pre-configure 450:pre-configure-script \
490:run-autotools-fixup 500:do-configure 700:post-configure \
850:post-configure-script \
- ${_OPTIONS_configure} ${_USES_configure}
+ ${_OPTIONS_configure} ${_USES_configure} ${_SCCACHE_START_SEQ}
_BUILD_DEP= configure
_BUILD_SEQ= 100:build-message 300:pre-build 450:pre-build-script \
500:do-build 700:post-build 850:post-build-script \
@@ -5324,7 +5325,7 @@
900:add-plist-info 910:add-plist-docs 920:add-plist-examples \
930:add-plist-data 940:add-plist-post ${POST_PLIST:C/^/990:/} \
${_OPTIONS_install} ${_USES_install} \
- ${_OPTIONS_stage} ${_USES_stage}
+ ${_OPTIONS_stage} ${_USES_stage} ${_SCCACHE_STOP_SEQ}
.if defined(DEVELOPER)
_STAGE_SEQ+= 995:stage-qa
.else
Index: Mk/bsd.sccache.mk
===================================================================
--- /dev/null
+++ Mk/bsd.sccache.mk
@@ -0,0 +1,59 @@
+# Note: the binary needs to be provided by the system, as to avoid a
+# chicken-egg problem in lang/rust, which itself can greatly benefit from being
+# compiled using sccache.
+#
+# User settable:
+#
+# - SCCACHE_DIR - path to the sccache directory
+# - SCCACHE_BIN - path to the sccache binary - defaults to ${SCCACHE_DIR}/sccache
+# this makes it easy to inject sccache into poudriere
+# - SCCACHE_SIZE - size of the cache - defaults to 16G
+#
+# Usable by ports:
+#
+# - SCCACHE_ENABLED - set if SCCACHE is usable (read only)
+# - NO_SCCACHE - disable sccache for the port (write only)
+#
+
+COMMANDS_Include_MAINTAINER= portmgr@FreeBSD.org
+
+.if !defined(_SCCACHE_INCLUDED)
+_SCCACHE_INCLUDED= yes
+_SCCACHE_SIZE_DEFAULT= 16G
+
+. if defined(SCCACHE_DIR)
+SCCACHE_BIN?= ${SCCACHE_DIR}/sccache
+. endif
+
+. if !defined(NO_SCCACHE)
+. if defined(SCCACHE_BIN) && exists(${SCCACHE_BIN})
+SCCACHE_ENABLED= y
+SCCACHE_SIZE?= ${_SCCACHE_SIZE_DEFAULT}
+
+_SCCACHE_ENV= RUSTC_WRAPPER="${SCCACHE_BIN}" \
+ SCCACHE_DIR="${SCCACHE_DIR}" \
+ SCCACHE_CACHE_SIZE="${SCCACHE_SIZE}" \
+ SCCACHE_MAX_FRAME_LENGTH=104857600
+
+CONFIGURE_ENV+= ${_SCCACHE_ENV}
+MAKE_ENV+= ${_SCCACHE_ENV}
+
+# Added to _CONFIGURE_SEQ
+_SCCACHE_START_SEQ= 450:sccache-start
+# Added to _STAGE_SEQ
+_SCCACHE_STOP_SEQ= 950:sccache-stop
+
+# Enusure that the sccache is properly stopped when stopping the build
+sccache-start:
+ @echo "==========================================================================="
+ @echo "==> starting sccache"
+ @${SETENV} ${_SCCACHE_ENV} ${SCCACHE_BIN} --start-server
+ @echo "==========================================================================="
+sccache-stop:
+ @echo "==========================================================================="
+ @echo "==> stopping sccache"
+ @${SETENV} ${_SCCACHE_ENV} ${SCCACHE_BIN} --stop-server
+ @echo "==========================================================================="
+. endif
+. endif
+.endif
Index: lang/rust/Makefile
===================================================================
--- lang/rust/Makefile
+++ lang/rust/Makefile
@@ -161,6 +161,9 @@
@${ECHO_CMD} 'target=[${_RUST_TARGETS:@.target.@"${.target.}"@:ts,}]' >> ${WRKSRC}/config.toml
@${ECHO_CMD} 'cargo="${WRKDIR}/bootstrap/bin/cargo"' >> ${WRKSRC}/config.toml
@${ECHO_CMD} 'rustc="${WRKDIR}/bootstrap/bin/rustc"' >> ${WRKSRC}/config.toml
+.if defined(SCCACHE_ENABLED)
+ @${ECHO_CMD} 'rustc-wrapper="${SCCACHE_BIN}"' >> ${WRKSRC}/config.toml
+.endif
@${ECHO_CMD} 'tools=[${_RUST_TOOLS:@.tool.@"${.tool.}"@:ts,}]' >> ${WRKSRC}/config.toml
@${ECHO_CMD} '[install]' >> ${WRKSRC}/config.toml
@${ECHO_CMD} 'prefix="${PREFIX}"' >> ${WRKSRC}/config.toml
@@ -221,6 +224,18 @@
@${ECHO_CMD} 'missing-tools=true' >> ${WRKSRC}/config.toml
.endif
+.if defined(SCCACHE_ENABLE)
+EXTRA_PATCHES+= ${FILES_DIR}/extra-patch-sccache
+.endif
+
+pre-configure:
+.if defined(SCCACHE_ENABLE)
+ ${REINPLACE_CMD} -e 's|%%SCCACHE_DIR%%|${SCCACHE_DIR}|' \
+ -e 's|%%SCCACHE_BIN%%|${SCCACHE_BIN}|' \
+ -e 's|%%SCCACHE_SIZE%%|${SCCACHE_SIZE}|' \
+ ${CONFIGURE_WRKSRC}/src/bootstrap/builder.rs
+.endif
+
do-build:
@cd ${WRKSRC} && \
${SETENV} ${MAKE_ENV} ${PYTHON_CMD} x.py build --jobs=${MAKE_JOBS_NUMBER}
Index: lang/rust/files/extra-patch-sccache
===================================================================
--- /dev/null
+++ lang/rust/files/extra-patch-sccache
@@ -0,0 +1,12 @@
+--- src/bootstrap/builder.rs.orig 2021-07-20 13:51:10 UTC
++++ src/bootstrap/builder.rs
+@@ -1068,6 +1068,9 @@ impl<'a> Builder<'a> {
+ if cmd != "clippy" {
+ cargo.env("RUSTC", self.out.join("bootstrap/debug/rustc"));
+ }
++ cargo.env("RUSTC_WRAPPER", "%%SCCACHE_BIN%%");
++ cargo.env("SCCACHE_DIR", "%%SCCACHE_DIR%%");
++ cargo.env("SCCACHE_CACHE_SIZE", "%%SCCACHE_SIZE%%");
+
+ // Dealing with rpath here is a little special, so let's go into some
+ // detail. First off, `-rpath` is a linker option on Unix platforms
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 18, 10:56 PM (9 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25559292
Default Alt Text
D31243.diff (5 KB)
Attached To
Mode
D31243: framework: add support for using sccache during port builds
Attached
Detach File
Event Timeline
Log In to Comment