Index: lang/rust/Makefile =================================================================== --- lang/rust/Makefile +++ lang/rust/Makefile @@ -47,13 +47,16 @@ PLIST_FILES= lib/rustlib/components \ lib/rustlib/rust-installer-version -OPTIONS_DEFINE= DOCS GDB SOURCES +OPTIONS_DEFINE= DOCS GDB SOURCES WASM GDB_DESC= Install ports gdb (necessary for debugging rust programs) SOURCES_DESC= Install source files +WASM_DESC= Build the WebAssembly target (wasm32-unknown-unknown) DOCS_VARS_OFF= _RUST_BUILD_DOCS=false DOCS_VARS= _RUST_BUILD_DOCS=true GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb +WASM_VARS_OFF= _RUST_BUILD_WASM=false +WASM_VARS= _RUST_BUILD_WASM=true # See WRKSRC/src/stage0.txt for the date and version values. BOOTSTRAPS_DATE?= 2020-01-11 @@ -86,6 +89,17 @@ EXTRA_PATCHES+= ${PATCHDIR}/${ARCH}${BOOTSTRAPS_SUFFIX} .endif +_RUST_TARGETS= ${_RUST_TARGET} +.if ${PORT_OPTIONS:MWASM} +_RUST_TARGETS+= wasm32-unknown-unknown +.endif + +# transform, for example, wasm32-unknown-unknown aarch64-unknown-freebsd to +# a format accepted by config.toml: ["wasm32-unknown-unknown","aarch64-unknown-freebsd"] +RUST_TARGETS!= ${ECHO} ${_RUST_TARGETS} | \ + ${SED} -e 's|[[:space:]]|","|' \ + -e 's|^|["|' -e 's|$$|"]|' + .if ${ARCH} == powerpc64 && ${PPC_ABI} == ELFv1 # The bootstrap is hardcoded to use gcc9 # but we can build with a newer or older compiler as provided by USE_GCC=yes @@ -148,6 +162,7 @@ @${ECHO_CMD} 'python="${PYTHON_CMD}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'docs=${_RUST_BUILD_DOCS}' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'verbose=2' >> ${WRKSRC}/config.toml + @${ECHO_CMD} 'target = ${RUST_TARGETS}' >> ${WRKSRC}/config.toml @${ECHO_CMD} '[install]' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'prefix="${PREFIX}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'sysconfdir="${PREFIX}/etc"' >> ${WRKSRC}/config.toml @@ -155,6 +170,7 @@ @${ECHO_CMD} 'channel="${PKGNAMESUFFIX:Ustable:S/^-//}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'default-linker="${CC}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'verbose-tests=true' >> ${WRKSRC}/config.toml + @${ECHO_CMD} 'lld = ${_RUST_BUILD_WASM}' >> ${WRKSRC}/config.toml @${ECHO_CMD} '[llvm]' >> ${WRKSRC}/config.toml .if defined(WITH_CCACHE_BUILD) && !defined(NO_CCACHE) @${ECHO_CMD} 'ccache="${CCACHE_BIN}"' >> ${WRKSRC}/config.toml