Index: lang/rust/Makefile =================================================================== --- lang/rust/Makefile +++ lang/rust/Makefile @@ -48,10 +48,11 @@ # ?= to allow users to still overwrite it in make.conf. TMPDIR?= ${WRKDIR} -OPTIONS_DEFINE= DOCS GDB LTO SOURCES WASM +OPTIONS_DEFINE= DOCS GDB LTO PORT_LLVM SOURCES WASM OPTIONS_DEFAULT= SOURCES WASM GDB_DESC= Install ports gdb (necessary for debugging rust programs) +PORT_LLVM_DESC= Build against devel/llvm instead of bundled copy (experimental) SOURCES_DESC= Install source files WASM_DESC= Build the WebAssembly target (wasm32-unknown-unknown) @@ -60,6 +61,8 @@ _RUST_TOOLS+=rustdoc DOCS_VARS_OFF= _RUST_BUILD_DOCS=false GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb +PORT_LLVM_USES= llvm:min=14,lib,noexport +PORT_LLVM_MAKE_ENV= RUSTFLAGS="-Lnative=${LOCALBASE}/lib" SOURCES_VARS= _COMPONENTS+=rust-src-${_PACKAGE_VERS} \ _RUST_TOOLS+=src WASM_VARS= _COMPONENTS+="rust-analysis-${_PACKAGE_VERS}-wasm32-unknown-unknown rust-std-${_PACKAGE_VERS}-wasm32-unknown-unknown" \ @@ -95,6 +98,12 @@ .include +.ifndef NIGHTLY_DATE +PATCH_SITES= https://github.com/rust-lang/rust/commit/ +PATCHFILES= 71958da4854176c50a8b12470b956d5c7ed11817.patch:-p1 \ + 6ddf9128b2b55f9def80af57f7353d2521527c6a.patch:-p1 +.endif + .if ${OPSYS} != FreeBSD IGNORE= is only for FreeBSD .endif @@ -156,6 +165,11 @@ @${REINPLACE_CMD} 's,"files":{[^}]*},"files":{},' \ ${CARGO_VENDOR_DIR}/*/.cargo-checksum.json +post-patch-PORT_LLVM-on: + # WASM target hardcodes bundled lld + ${REINPLACE_CMD} 's|"rust-lld"|"wasm-ld${LLVM_DEFAULT}"|' \ + ${WRKSRC}/compiler/rustc_target/src/spec/wasm_base.rs + do-configure: # Check that the running kernel has COMPAT_FREEBSD11 required by lang/rust post-ino64 @${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}" WRKDIR="${WRKDIR}" \ @@ -190,7 +204,9 @@ @${ECHO_CMD} 'default-linker="${CC}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'deny-warnings=false' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'verbose-tests=true' >> ${WRKSRC}/config.toml +.if !${PORT_OPTIONS:MPORT_LLVM} @${ECHO_CMD} 'lld=${_RUST_BUILD_WASM}' >> ${WRKSRC}/config.toml +.endif .if ${PORT_OPTIONS:MLTO} @${ECHO_CMD} 'lto="thin"' >> ${WRKSRC}/config.toml .endif @@ -230,6 +246,9 @@ .else @${ECHO_CMD} 'linker="${CC}"' >> ${WRKSRC}/config.toml .endif +.if ${PORT_OPTIONS:MPORT_LLVM} + @${ECHO_CMD} 'llvm-config="${LOCALBASE}/bin/${LLVM_CONFIG}"' >> ${WRKSRC}/config.toml +.endif .endfor @${ECHO_CMD} '[dist]' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'src-tarball=false' >> ${WRKSRC}/config.toml Index: lang/rust/distinfo =================================================================== --- lang/rust/distinfo +++ lang/rust/distinfo @@ -49,3 +49,7 @@ SIZE (rust/2023-07-13/rust-std-1.71.0-riscv64gc-unknown-freebsd.tar.xz) = 24375500 SHA256 (rust/2023-07-13/cargo-1.71.0-riscv64gc-unknown-freebsd.tar.xz) = b49977e17a42a9175cfa016941a6006f8e188f610f4ed59945f114fcb9f04820 SIZE (rust/2023-07-13/cargo-1.71.0-riscv64gc-unknown-freebsd.tar.xz) = 10130160 +SHA256 (rust/71958da4854176c50a8b12470b956d5c7ed11817.patch) = 5a6b67dfc1218ea953421816834ffe3aa8ac1fc078dfaea4ebab121460ca5211 +SIZE (rust/71958da4854176c50a8b12470b956d5c7ed11817.patch) = 2007 +SHA256 (rust/6ddf9128b2b55f9def80af57f7353d2521527c6a.patch) = 6eaaaf6714c496b610712aa9ecbe1a1614e042323ec872fbf31a0a74c9020f29 +SIZE (rust/6ddf9128b2b55f9def80af57f7353d2521527c6a.patch) = 1278