git: 009e302df60f - main - lang/rust: really fix WASM with PORT_LLVM

From: Charlie Li <vishwin_at_FreeBSD.org>
Date: Sat, 20 Dec 2025 03:04:08 UTC
The branch main has been updated by vishwin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=009e302df60f057f12c4c243da653d256fb3e3de

commit 009e302df60f057f12c4c243da653d256fb3e3de
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2025-12-20 02:57:14 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2025-12-20 02:57:14 +0000

    lang/rust: really fix WASM with PORT_LLVM
    
    Bundled LLVM is never built when llvm-config is specified in
    config.toml, ie PORT_LLVM, and base system LLVM doesn't support
    wasm32-unknown-unknown triple. Restore the previous behaviour of
    using clang from the LLVM port when PORT_LLVM is enabled. Also
    really fix the ${LLVM_VERSION} logic, as the variable is from
    USES=llvm.
---
 lang/rust/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 2843e9e1bc0c..d77d89e0d15a 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -147,7 +147,7 @@ post-patch:
 
 post-patch-PORT_LLVM-on:
 # WASM target hardcodes bundled lld
-	@${REINPLACE_CMD} 's|"rust-lld"|"wasm-ld${_LLVM_VERSION}"|' \
+	@${REINPLACE_CMD} 's|"rust-lld"|"wasm-ld${LLVM_VERSION}"|' \
 		${WRKSRC}/compiler/rustc_target/src/spec/base/wasm.rs
 
 do-configure:
@@ -224,11 +224,17 @@ do-configure:
 	@${ECHO_CMD} 'cxx="${WRKDIR}/cxx-wrapper"' >> ${WRKSRC}/config.toml
 	@${ECHO_CMD} 'linker="${CC}"' >> ${WRKSRC}/config.toml
 .else
-# use the builtin clang
+# use the builtin clang when not using PORT_LLVM
 .if ${_target} == "wasm32-unknown-unknown"
+.if ${PORT_OPTIONS:MPORT_LLVM}
+	@${ECHO_CMD} 'cc="${LOCALBASE}/bin/clang${LLVM_VERSION}"' >> ${WRKSRC}/config.toml
+	@${ECHO_CMD} 'cxx="${LOCALBASE}/bin/clang++${LLVM_VERSION}"' >> ${WRKSRC}/config.toml
+	@${ECHO_CMD} 'linker="${LOCALBASE}/bin/clang${LLVM_VERSION}"' >> ${WRKSRC}/config.toml
+.else
 	@${ECHO_CMD} 'cc="${WRKDIR}/_build/${_RUST_TARGET}/llvm/bin/clang"' >> ${WRKSRC}/config.toml
 	@${ECHO_CMD} 'cxx="${WRKDIR}/_build/${_RUST_TARGET}/llvm/bin/clang++"' >> ${WRKSRC}/config.toml
 	@${ECHO_CMD} 'linker="${WRKDIR}/_build/${_RUST_TARGET}/llvm/bin/clang"' >> ${WRKSRC}/config.toml
+.endif
 .else
 	@${ECHO_CMD} 'cc="${CC}"' >> ${WRKSRC}/config.toml
 	@${ECHO_CMD} 'cxx="${CXX}"' >> ${WRKSRC}/config.toml