git: e38b3857f20a - main - wasi: update libc to sdk-20 and modularise LLVM bits

From: Charlie Li <vishwin_at_FreeBSD.org>
Date: Mon, 20 Nov 2023 21:33:02 UTC
The branch main has been updated by vishwin:

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

commit e38b3857f20acc9b1db1f0e2faf416c7b46e73a8
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2023-11-20 21:29:34 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2023-11-20 21:32:36 +0000

    wasi: update libc to sdk-20 and modularise LLVM bits
    
    wasi-libcxx and wasi-compiler-rt now meta ports (similar to u-boot);
    the build process is the same for each LLVM version so child ports
    are minimal. Minimum supported LLVM version is 12, thus its
    corresponding child ports are resurrected and LLVM 11 child ports
    are removed.
    
    Since all supported LLVM versions are made available at once, remove
    restriction in bsd.gecko.mk and switch to USES=llvm throughout. LTO
    on gecko ports should now work with later LLVM versions so long as
    ${DEFAULT_VERSIONS} is set properly and matches the LLVM used in
    rust (if not using the PORT_LLVM option).
    
    Reviewed by: brooks (LLVM ports interactions)
    Tested by: Eric Camachat <eric[at]camachat[dot]org>
    Approved by: maintainer timeout (gecko@ portion, 2+ weeks)
    PR: 274896
    Differential Revision: https://reviews.freebsd.org/D40098
---
 MOVED                                              |    2 +-
 Mk/bsd.gecko.mk                                    |   24 +-
 devel/Makefile                                     |   13 +-
 devel/wasi-compiler-rt/Makefile                    |   70 ++
 .../pkg-descr                                      |    0
 devel/wasi-compiler-rt11/Makefile                  |   63 --
 devel/wasi-compiler-rt11/distinfo                  |    3 -
 devel/wasi-compiler-rt12/Makefile                  |    6 +
 devel/wasi-compiler-rt13/Makefile                  |   60 +-
 devel/wasi-compiler-rt13/distinfo                  |    3 -
 devel/wasi-compiler-rt13/pkg-descr                 |    5 -
 devel/wasi-compiler-rt14/Makefile                  |    6 +
 devel/wasi-compiler-rt15/Makefile                  |    6 +
 devel/wasi-compiler-rt16/Makefile                  |    6 +
 devel/wasi-compiler-rt17/Makefile                  |    6 +
 devel/wasi-libc/Makefile                           |   27 +-
 devel/wasi-libc/distinfo                           |   10 +-
 devel/wasi-libc/files/patch-Makefile               |   13 -
 devel/wasi-libcxx/Makefile                         |  155 +--
 devel/wasi-libcxx/distinfo                         |    3 -
 devel/wasi-libcxx12/Makefile                       |    6 +
 devel/wasi-libcxx12/pkg-plist                      |  191 ++++
 devel/wasi-libcxx13/Makefile                       |    6 +
 devel/{wasi-libcxx => wasi-libcxx13}/pkg-plist     |    0
 devel/wasi-libcxx14/Makefile                       |    6 +
 devel/wasi-libcxx14/pkg-plist                      |  544 +++++++++++
 devel/wasi-libcxx15/Makefile                       |    6 +
 devel/wasi-libcxx15/pkg-plist                      |  795 +++++++++++++++
 devel/wasi-libcxx16/Makefile                       |    6 +
 devel/wasi-libcxx16/pkg-plist                      |  877 +++++++++++++++++
 devel/wasi-libcxx17/Makefile                       |    6 +
 devel/wasi-libcxx17/pkg-plist                      | 1017 ++++++++++++++++++++
 mail/thunderbird/Makefile                          |    4 +-
 www/firefox-esr/Makefile                           |    4 +-
 www/firefox/Makefile                               |    4 +-
 www/librewolf/Makefile                             |    8 +-
 www/tor-browser/Makefile                           |    4 +-
 37 files changed, 3655 insertions(+), 310 deletions(-)

diff --git a/MOVED b/MOVED
index 830ae4d3c1f4..5f6887d104dc 100644
--- a/MOVED
+++ b/MOVED
@@ -6296,7 +6296,6 @@ security/rubygem-bcrypt_pbkdf10|security/rubygem-bcrypt_pbkdf|2022-01-11|Remove
 math/gotoblas|math/openblas|2022-01-15|Remove obsoleted port. Use math/openblas instead
 net/pipsecd||2022-01-15|Has expired: Abandonware, current release is from 1999 and uses insecure encryption algorithms
 devel/maven31|devel/maven|2022-01-15|Has expired: Outdated, unsupported upstream
-devel/wasi-compiler-rt12||2022-01-15|Has expired: this ports exists solely for building Firefox 95+ in 2021Q4
 devel/e2fsprogs-libss||2022-01-17|Folded back into sysutils/e2fsprogs, which was the sole user
 lang/spidermonkey60|lang/spidermonkey78|2022-01-18|Has expired: Requires python2 to build
 shells/ammonite|devel/ammonite|2022-01-18|Ammonite dropped built-in shell support
@@ -8078,3 +8077,4 @@ x11-toolkits/fpc-xforms|lang/fpc|2023-11-12|This port was merged into lang/fpc
 x11-toolkits/fpc-gtk2|lang/fpc|2023-11-12|This port was merged into lang/fpc
 sysutils/fpc-users|lang/fpc|2023-11-14|This port was merged into lang/fpc
 net/py-ldap|net/py-python-ldap|2023-11-17|Rename to conform upstream name
+devel/wasi-compiler-rt11||2023-11-20|Version no longer supported as a WASI component
diff --git a/Mk/bsd.gecko.mk b/Mk/bsd.gecko.mk
index b994ba61fce3..edde78933267 100644
--- a/Mk/bsd.gecko.mk
+++ b/Mk/bsd.gecko.mk
@@ -60,8 +60,8 @@ MOZILLA?=	${PORTNAME}
 MOZILLA_VER?=	${PORTVERSION}
 MOZILLA_BIN?=	${PORTNAME}-bin
 MOZILLA_EXEC_NAME?=${MOZILLA}
-USES+=		compiler:c++17-lang cpe gl gmake gnome iconv localbase pkgconfig \
-			python:build desktop-file-utils
+USES+=		compiler:c++17-lang cpe gl gmake gnome iconv llvm:noexport localbase \
+			pkgconfig python:build desktop-file-utils
 CPE_VENDOR?=mozilla
 USE_GL=		gl
 USE_GNOME=	cairo gdkpixbuf2 gtk30
@@ -73,8 +73,7 @@ BINARY_ALIAS+=	python3=${PYTHON_CMD}
 
 BUNDLE_LIBS=	yes
 
-BUILD_DEPENDS+=	llvm${LLVM_DEFAULT}>0:devel/llvm${LLVM_DEFAULT} \
-				rust-cbindgen>=0.26.0:devel/rust-cbindgen \
+BUILD_DEPENDS+=	rust-cbindgen>=0.26.0:devel/rust-cbindgen \
 				${RUST_DEFAULT}>=1.72.0:lang/${RUST_DEFAULT} \
 				node:www/node
 LIB_DEPENDS+=	libdrm.so:graphics/libdrm
@@ -86,22 +85,15 @@ MOZ_EXPORT+=	${CONFIGURE_ENV} \
 MOZ_OPTIONS+=	--prefix="${PREFIX}"
 MOZ_MK_OPTIONS+=MOZ_OBJDIR="${BUILD_WRKSRC}"
 
-MOZ_OPTIONS+=	--with-libclang-path="${LOCALBASE}/llvm${LLVM_DEFAULT}/lib"
+MOZ_OPTIONS+=	--with-libclang-path="${LLVM_PREFIX:S/${PREFIX}/${LOCALBASE}/}/lib"
 .    if !exists(/usr/bin/llvm-objdump)
-MOZ_EXPORT+=	LLVM_OBJDUMP="${LOCALBASE}/bin/llvm-objdump${LLVM_DEFAULT}"
+MOZ_EXPORT+=	LLVM_OBJDUMP="${LOCALBASE}/bin/llvm-objdump${LLVM_VERSION}"
 .    endif
-# fix LLVM to version 13, as that's the only reasonable wasi-toolchain
-# we currently have
-#    if !defined(DEFAULT_VERSIONS) || ! ${DEFAULT_VERSIONS:Mllvm*} || ${PORT_OPTIONS:MLTO}
-LLVM_DEFAULT=	13 # chase bundled LLVM in lang/rust for LTO
-LLVM_VERSION=	13.0.1 # keep in sync with devel/wasi-compiler-rt${LLVM_DEFAULT}
-#    endif
 # Require newer Clang than what's in base system unless user opted out
 .    if ${CC} == cc && ${CXX} == c++ && exists(/usr/lib/libc++.so)
-BUILD_DEPENDS+=	${LOCALBASE}/bin/clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
-CPP=			${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT}
-CC=				${LOCALBASE}/bin/clang${LLVM_DEFAULT}
-CXX=			${LOCALBASE}/bin/clang++${LLVM_DEFAULT}
+CPP=			${LOCALBASE}/bin/clang-cpp${LLVM_VERSION}
+CC=				${LOCALBASE}/bin/clang${LLVM_VERSION}
+CXX=			${LOCALBASE}/bin/clang++${LLVM_VERSION}
 USES:=			${USES:Ncompiler\:*} # XXX avoid warnings
 .    endif
 
diff --git a/devel/Makefile b/devel/Makefile
index b78a81e3dc21..c1a34e7b8620 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -7807,10 +7807,21 @@
     SUBDIR += vxlog
     SUBDIR += wand-libconfig
     SUBDIR += wandio
-    SUBDIR += wasi-compiler-rt11
+    SUBDIR += wasi-compiler-rt
+    SUBDIR += wasi-compiler-rt12
     SUBDIR += wasi-compiler-rt13
+    SUBDIR += wasi-compiler-rt14
+    SUBDIR += wasi-compiler-rt15
+    SUBDIR += wasi-compiler-rt16
+    SUBDIR += wasi-compiler-rt17
     SUBDIR += wasi-libc
     SUBDIR += wasi-libcxx
+    SUBDIR += wasi-libcxx12
+    SUBDIR += wasi-libcxx13
+    SUBDIR += wasi-libcxx14
+    SUBDIR += wasi-libcxx15
+    SUBDIR += wasi-libcxx16
+    SUBDIR += wasi-libcxx17
     SUBDIR += wasm3
     SUBDIR += wasmer
     SUBDIR += websocketpp
diff --git a/devel/wasi-compiler-rt/Makefile b/devel/wasi-compiler-rt/Makefile
new file mode 100644
index 000000000000..fee5f003ed9a
--- /dev/null
+++ b/devel/wasi-compiler-rt/Makefile
@@ -0,0 +1,70 @@
+PORTNAME=	compiler-rt
+DISTVERSION?=	0
+PORTREVISION?=	0
+CATEGORIES=	devel lang
+MASTER_SITES=	https://github.com/llvm/llvm-project/releases/download/llvmorg-${DISTVERSION:S/rc/-rc/}/ \
+		https://${PRE_}releases.llvm.org/${LLVM_RELEASE}/${RCDIR}/
+PKGNAMEPREFIX=	wasi-
+PKGNAMESUFFIX=	${LLVM_VERSION}
+DISTNAME=	llvm-project-${DISTVERSION}.src
+DISTFILES=	llvm-project-${DISTVERSION}.src${EXTRACT_SUFX}
+
+MAINTAINER=	vishwin@FreeBSD.org
+COMMENT=	Clang builtins library for WebAssembly System Interface
+WWW=		https://llvm.org/
+
+LICENSE=	LLVM2
+LICENSE_NAME=	Apache License 2.0 with LLVM Exceptions
+LICENSE_FILE=	${WRKSRC}/llvm/LICENSE.TXT
+LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+.if ${DISTVERSION} == 0
+IGNORE=		is a meta-port; there is nothing to build
+.endif
+
+BUILD_DEPENDS=	${WASI_SYSROOT}/include/stdarg.h:devel/wasi-libc
+
+USES=		cmake llvm:${LLVM_SUFFIX} tar:xz
+
+LLVM_RELEASE=	${DISTVERSION:C/rc.*//}
+LLVM_SUFFIX=	${LLVM_RELEASE:C/\.[0-9]\.[0-9]$//}
+DISTINFO_FILE=	${PORTSDIR}/${LLVM_PORT}/distinfo
+NO_ARCH=	yes
+
+CC=		${LOCALBASE}/bin/clang${LLVM_VERSION}
+CXX=		${LOCALBASE}/bin/clang++${LLVM_VERSION}
+WASI_SYSROOT=	${LOCALBASE}/share/wasi-sysroot
+TRIPLE=		wasm32-wasi
+WITHOUT_CPU_CFLAGS=	yes
+# try to sync with https://github.com/WebAssembly/wasi-sdk
+# Makefile and wasi-sdk.cmake
+CMAKE_SOURCE_PATH=	${WRKSRC}/compiler-rt/lib/builtins
+CMAKE_ARGS=	-DCMAKE_AR=${LOCALBASE}/bin/llvm-ar${LLVM_VERSION} \
+		-DCMAKE_RANLIB=${LOCALBASE}/bin/llvm-ranlib${LLVM_VERSION} \
+		-DCMAKE_C_COMPILER_TARGET=${TRIPLE} \
+		-DCMAKE_CXX_COMPILER_TARGET=${TRIPLE} \
+		-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+		-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
+		-DCMAKE_SYSROOT=${WASI_SYSROOT} \
+		-DCMAKE_C_COMPILER_WORKS=ON \
+		-DCOMPILER_RT_BAREMETAL_BUILD=ON \
+		-DCOMPILER_RT_INCLUDE_TESTS=OFF \
+		-DCOMPILER_RT_HAS_FPIC_FLAG=ON \
+		-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
+		-DCOMPILER_RT_OS_DIR=wasi
+
+.include <bsd.port.pre.mk>
+
+.if ${LLVM_VERSION} < 16
+CMAKE_ARGS+=	-DLLVM_CONFIG_PATH=${LLVM_CONFIG}
+CMAKE_INSTALL_PREFIX=	${LLVM_PREFIX}/lib/clang/${LLVM_RELEASE}
+PLIST_FILES=	${LLVM_PREFIX}/lib/clang/${LLVM_RELEASE}/lib/wasi/libclang_rt.builtins-wasm32.a
+.else
+CMAKE_ARGS+=	-DLLVM_CMAKE_DIR=${LLVM_PREFIX}
+CMAKE_INSTALL_PREFIX=	${LLVM_PREFIX}/lib/clang/${LLVM_VERSION}
+PLIST_FILES=	${LLVM_PREFIX}/lib/clang/${LLVM_VERSION}/lib/wasi/libclang_rt.builtins-wasm32.a
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/devel/wasi-compiler-rt11/pkg-descr b/devel/wasi-compiler-rt/pkg-descr
similarity index 100%
rename from devel/wasi-compiler-rt11/pkg-descr
rename to devel/wasi-compiler-rt/pkg-descr
diff --git a/devel/wasi-compiler-rt11/Makefile b/devel/wasi-compiler-rt11/Makefile
deleted file mode 100644
index 025ccca8f2e9..000000000000
--- a/devel/wasi-compiler-rt11/Makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-PORTNAME=	compiler-rt
-DISTVERSION=	11.0.1
-CATEGORIES=	devel lang
-.if ${DISTVERSION:M*rc*}
-MASTER_SITES=	https://prereleases.llvm.org/${LLVM_RELEASE}/${RCDIR}
-.else
-MASTER_SITES=	https://releases.llvm.org/${LLVM_RELEASE}/
-.endif
-PKGNAMEPREFIX=	wasi-
-PKGNAMESUFFIX=	${LLVM_SUFFIX}
-DISTNAME=	${PORTNAME}-${DISTVERSION}.src
-DISTFILES=	${PORTNAME}-${DISTVERSION}.src${EXTRACT_SUFX}
-
-MAINTAINER=	vishwin@FreeBSD.org
-COMMENT=	Clang builtins library for WebAssembly System Interface
-WWW=		https://llvm.org/
-
-LICENSE=	LLVM2
-LICENSE_FILE=	${WRKSRC}/LICENSE.TXT
-LICENSE_NAME=	Apache License 2.0 with LLVM Exceptions
-LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
-
-LLVM_RELEASE=	${DISTVERSION:C/rc.*//}
-LLVM_SUFFIX=	${LLVM_RELEASE:C/\.[0-9]\.[0-9]$//}
-LLVM_PREFIX=	${PREFIX}/llvm${LLVM_SUFFIX}
-
-WASI_SYSROOT=	${LOCALBASE}/share/wasi-sysroot
-
-BUILD_DEPENDS=	${WASI_SYSROOT}/include/stdarg.h:devel/wasi-libc \
-		clang${LLVM_SUFFIX}:devel/llvm${LLVM_SUFFIX}
-
-USES=		cmake tar:xz
-NO_ARCH=	yes
-
-PLIST_FILES=	llvm${LLVM_SUFFIX}/lib/clang/${LLVM_RELEASE}/lib/wasi/libclang_rt.builtins-wasm32.a
-
-CC=		${LOCALBASE}/bin/clang${LLVM_SUFFIX}
-CXX=		${LOCALBASE}/bin/clang++${LLVM_SUFFIX}
-
-CMAKE_SOURCE_PATH=	${WRKSRC}/lib/builtins
-CMAKE_INSTALL_PREFIX=	${LLVM_PREFIX}/lib/clang/${LLVM_RELEASE}
-CMAKE_ARGS=	-DCMAKE_C_COMPILER_WORKS=1 \
-		-DCMAKE_SYSROOT=${WASI_SYSROOT} \
-		-DLLVM_CONFIG_PATH=${LOCALBASE}/bin/llvm-config${LLVM_SUFFIX} \
-		-DCOMPILER_RT_OS_DIR=wasi \
-		-DCOMPILER_RT_BAREMETAL_BUILD=TRUE \
-		-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=wasm32-wasi \
-		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=TRUE \
-		-DCOMPILER_RT_HAS_FPIC_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FPIE_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FNO_BUILTIN_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_STD_C11_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FREESTANDING_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_XRAY_COMPILER_FLAG:BOOL=OFF \
-		-DCOMPILER_RT_HAS_ATOMIC_KEYWORD:BOOL=ON \
-		-DCOMPILER_RT_HAS_FLOAT16:BOOL=OFF \
-		-DCOMPILER_RT_HAS_ASM_LSE:BOOL=OFF
-
-post-build:
-	${LOCALBASE}/bin/llvm-ranlib${LLVM_SUFFIX} ${CONFIGURE_WRKSRC}/lib/wasi/*.a
-
-.include <bsd.port.mk>
diff --git a/devel/wasi-compiler-rt11/distinfo b/devel/wasi-compiler-rt11/distinfo
deleted file mode 100644
index f131fdcd91d8..000000000000
--- a/devel/wasi-compiler-rt11/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1610626559
-SHA256 (compiler-rt-11.0.1.src.tar.xz) = 087be3f1116e861cd969c9b0b0903c27028b52eaf45157276f50a9c2500687fc
-SIZE (compiler-rt-11.0.1.src.tar.xz) = 2136216
diff --git a/devel/wasi-compiler-rt12/Makefile b/devel/wasi-compiler-rt12/Makefile
new file mode 100644
index 000000000000..e945f2b9ff76
--- /dev/null
+++ b/devel/wasi-compiler-rt12/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm12
+DISTVERSION=	12.0.1
+
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-compiler-rt13/Makefile b/devel/wasi-compiler-rt13/Makefile
index 70db20f7a136..4ba8f8909e6d 100644
--- a/devel/wasi-compiler-rt13/Makefile
+++ b/devel/wasi-compiler-rt13/Makefile
@@ -1,60 +1,6 @@
-PORTNAME=	compiler-rt
+# must sync with devel/llvm13
 DISTVERSION=	13.0.1
-CATEGORIES=	devel lang
-MASTER_SITES=	https://github.com/llvm/llvm-project/releases/download/llvmorg-${DISTVERSION:S/rc/-rc/}/ \
-		https://${PRE_}releases.llvm.org/${LLVM_RELEASE}/${RCDIR}
-PKGNAMEPREFIX=	wasi-
-PKGNAMESUFFIX=	${LLVM_SUFFIX}
-DISTNAME=	llvm-project-${DISTVERSION}.src
-DISTFILES=	llvm-project-${DISTVERSION}.src${EXTRACT_SUFX}
 
-MAINTAINER=	vishwin@FreeBSD.org
-COMMENT=	Clang builtins library for WebAssembly System Interface
-WWW=		https://llvm.org/
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
 
-LICENSE=	LLVM2
-LICENSE_FILE=	${WRKSRC}/llvm/LICENSE.TXT
-LICENSE_NAME=	Apache License 2.0 with LLVM Exceptions
-LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
-
-LLVM_RELEASE=	${DISTVERSION:C/rc.*//}
-LLVM_SUFFIX=	${LLVM_RELEASE:C/\.[0-9]\.[0-9]$//}
-LLVM_PREFIX=	${PREFIX}/llvm${LLVM_SUFFIX}
-
-WASI_SYSROOT=	${LOCALBASE}/share/wasi-sysroot
-
-BUILD_DEPENDS=	${WASI_SYSROOT}/include/stdarg.h:devel/wasi-libc \
-		clang${LLVM_SUFFIX}:devel/llvm${LLVM_SUFFIX}
-
-USES=		cmake tar:xz
-NO_ARCH=	yes
-
-PLIST_FILES=	llvm${LLVM_SUFFIX}/lib/clang/${LLVM_RELEASE}/lib/wasi/libclang_rt.builtins-wasm32.a
-
-CC=		${LOCALBASE}/bin/clang${LLVM_SUFFIX}
-CXX=		${LOCALBASE}/bin/clang++${LLVM_SUFFIX}
-
-CMAKE_SOURCE_PATH=	${WRKSRC}/compiler-rt/lib/builtins
-CMAKE_INSTALL_PREFIX=	${LLVM_PREFIX}/lib/clang/${LLVM_RELEASE}
-CMAKE_ARGS=	-DCMAKE_C_COMPILER_WORKS=1 \
-		-DCMAKE_SYSROOT=${WASI_SYSROOT} \
-		-DLLVM_CONFIG_PATH=${LOCALBASE}/bin/llvm-config${LLVM_SUFFIX} \
-		-DCOMPILER_RT_OS_DIR=wasi \
-		-DCOMPILER_RT_BAREMETAL_BUILD=TRUE \
-		-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=wasm32-wasi \
-		-DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=TRUE \
-		-DCOMPILER_RT_HAS_FPIC_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FPIE_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FNO_BUILTIN_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_STD_C11_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_FREESTANDING_FLAG:BOOL=ON \
-		-DCOMPILER_RT_HAS_XRAY_COMPILER_FLAG:BOOL=OFF \
-		-DCOMPILER_RT_HAS_ATOMIC_KEYWORD:BOOL=ON \
-		-DCOMPILER_RT_HAS_FLOAT16:BOOL=OFF \
-		-DCOMPILER_RT_HAS_ASM_LSE:BOOL=OFF
-
-post-build:
-	${LOCALBASE}/bin/llvm-ranlib${LLVM_SUFFIX} ${CONFIGURE_WRKSRC}/lib/wasi/*.a
-
-.include <bsd.port.mk>
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-compiler-rt13/distinfo b/devel/wasi-compiler-rt13/distinfo
deleted file mode 100644
index 81d8f09ceaf2..000000000000
--- a/devel/wasi-compiler-rt13/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1644329424
-SHA256 (llvm-project-13.0.1.src.tar.xz) = 326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
-SIZE (llvm-project-13.0.1.src.tar.xz) = 97584928
diff --git a/devel/wasi-compiler-rt13/pkg-descr b/devel/wasi-compiler-rt13/pkg-descr
deleted file mode 100644
index 214255430767..000000000000
--- a/devel/wasi-compiler-rt13/pkg-descr
+++ /dev/null
@@ -1,5 +0,0 @@
-The LLVM Project is a collection of modular and reusable compiler and
-toolchain technologies.
-
-This port includes Clang builtins for WASI
-(WebAssembly System Interface).
diff --git a/devel/wasi-compiler-rt14/Makefile b/devel/wasi-compiler-rt14/Makefile
new file mode 100644
index 000000000000..7b9b4fa5aadd
--- /dev/null
+++ b/devel/wasi-compiler-rt14/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm14
+DISTVERSION=	14.0.6
+
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-compiler-rt15/Makefile b/devel/wasi-compiler-rt15/Makefile
new file mode 100644
index 000000000000..b3d91b783001
--- /dev/null
+++ b/devel/wasi-compiler-rt15/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm15
+DISTVERSION=	15.0.7
+
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-compiler-rt16/Makefile b/devel/wasi-compiler-rt16/Makefile
new file mode 100644
index 000000000000..e5b0d916bf64
--- /dev/null
+++ b/devel/wasi-compiler-rt16/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm16
+DISTVERSION=	16.0.6
+
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-compiler-rt17/Makefile b/devel/wasi-compiler-rt17/Makefile
new file mode 100644
index 000000000000..e4fb5420f0f2
--- /dev/null
+++ b/devel/wasi-compiler-rt17/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm17
+DISTVERSION=	17.0.5
+
+MASTERDIR=	${.CURDIR}/../wasi-compiler-rt
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-libc/Makefile b/devel/wasi-libc/Makefile
index 85ea9846fbc7..861ea01a01cd 100644
--- a/devel/wasi-libc/Makefile
+++ b/devel/wasi-libc/Makefile
@@ -1,10 +1,11 @@
 PORTNAME=	wasi-libc
-DISTVERSION=	g20210923
+DISTVERSION=	20-13
+DISTVERSIONSUFFIX=	-gce2f157
 CATEGORIES=	devel
 
 MAINTAINER=	vishwin@FreeBSD.org
 COMMENT=	C standard library for WebAssembly System Interface
-WWW=		https://github.com/CraneStation/wasi-libc
+WWW=		https://github.com/WebAssembly/wasi-libc
 
 LICENSE=	APACHE20 MIT LLVM2
 LICENSE_COMB=	multi
@@ -14,33 +15,29 @@ LICENSE_FILE_LLVM2=	${WRKSRC}/LICENSE-APACHE-LLVM
 LICENSE_NAME_LLVM2=	Apache License 2.0 with LLVM Exceptions
 LICENSE_PERMS_LLVM2=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
 
-BUILD_DEPENDS=	clang${LLVM_VERSION}:devel/llvm${LLVM_VERSION}
-
-USES=		gmake
+USES=		gmake llvm:min=12
 USE_GITHUB=	yes
 GH_ACCOUNT=	WebAssembly
-GH_TAGNAME=	ad5133410f66b93a2381db5b542aad5e0964db96
-GH_TUPLE=	WebAssembly:WASI:ef8c1a53fe:wasi/tools/wasi-headers/WASI
+GH_TAGNAME=	wasi-sdk-${DISTVERSION}${DISTVERSIONSUFFIX}
+GH_TUPLE=	WebAssembly:WASI:59cbe14:wasi/tools/wasi-headers/WASI
 NO_ARCH=	yes
-LLVM_VERSION?=	13
 
 ALL_TARGET=	finish
 
-# NOTE: matches the https://github.com/CraneStation/wasi-sdk
+# NOTE: matches the https://github.com/WebAssembly/wasi-sdk
 WASI_SYSROOT=	${PREFIX}/share/wasi-sysroot
 
 # NOTE: our llvm ports don't ship stdarg/stddef clang headers, so they're in FILESDIR
 #       and we install them to the sysroot
 
 MAKE_ENV=	INSTALL_DIR=${STAGEDIR}${WASI_SYSROOT} \
-		WASM_AR=${LOCALBASE}/bin/llvm-ar${LLVM_VERSION} \
-		WASM_CC=${LOCALBASE}/bin/clang${LLVM_VERSION} \
-		WASM_CFLAGS="-O2 -DNDEBUG -isystem ${FILESDIR}" \
-		WASM_NM=${LOCALBASE}/bin/llvm-nm${LLVM_VERSION}
+		EXTRA_CFLAGS="-O2 -DNDEBUG -isystem ${FILESDIR}" \
+		AR=${LOCALBASE}/bin/llvm-ar${LLVM_VERSION} \
+		NM=${LOCALBASE}/bin/llvm-nm${LLVM_VERSION} \
 
-# NOTE: phony targets cause make install to rebuild everything
-#       https://github.com/CraneStation/wasi-libc/issues/156
 post-patch:
+# NOTE: phony targets cause make install to rebuild everything
+#       https://github.com/WebAssembly/wasi-libc/issues/156
 	${REINPLACE_CMD} -e 's|install: finish|install:|' ${WRKSRC}/Makefile
 
 post-install:
diff --git a/devel/wasi-libc/distinfo b/devel/wasi-libc/distinfo
index eb971b47b154..bdb9ce2bcd26 100644
--- a/devel/wasi-libc/distinfo
+++ b/devel/wasi-libc/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1633602535
-SHA256 (WebAssembly-wasi-libc-g20210923-ad5133410f66b93a2381db5b542aad5e0964db96_GH0.tar.gz) = 085ab45e0591041a8dc104978ad3ff72589072161a922011762d53bf07169ac2
-SIZE (WebAssembly-wasi-libc-g20210923-ad5133410f66b93a2381db5b542aad5e0964db96_GH0.tar.gz) = 1251318
-SHA256 (WebAssembly-WASI-ef8c1a53fe_GH0.tar.gz) = 38be36dc47d79f60aadd1bb3deff391594ff6797260c4810cec0e781ad90ec3c
-SIZE (WebAssembly-WASI-ef8c1a53fe_GH0.tar.gz) = 334921
+TIMESTAMP = 1695350727
+SHA256 (WebAssembly-wasi-libc-20-13-gce2f157-wasi-sdk-20-13-gce2f157_GH0.tar.gz) = 0fa54e7536108eff99af04945d5d8facdc34e120179f622484ef9c7b799032f4
+SIZE (WebAssembly-wasi-libc-20-13-gce2f157-wasi-sdk-20-13-gce2f157_GH0.tar.gz) = 1312723
+SHA256 (WebAssembly-WASI-59cbe14_GH0.tar.gz) = 4e36c4add2421b44ccdded83d442d9aadf02ffa8b534d94016fad2bb7b781cc6
+SIZE (WebAssembly-WASI-59cbe14_GH0.tar.gz) = 162059
diff --git a/devel/wasi-libc/files/patch-Makefile b/devel/wasi-libc/files/patch-Makefile
deleted file mode 100644
index f51f34f38246..000000000000
--- a/devel/wasi-libc/files/patch-Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-complains about: __arraycount
-
---- Makefile.orig	2020-05-16 19:12:43 UTC
-+++ Makefile
-@@ -515,7 +515,7 @@ finish: startup_files libc
- 
- 	# Check that the computed metadata matches the expected metadata.
- 	# This ignores whitespace because on Windows the output has CRLF line endings.
--	diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
-+	# diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
- 
- 	#
- 	# The build succeeded! The generated sysroot is in $(SYSROOT).
diff --git a/devel/wasi-libcxx/Makefile b/devel/wasi-libcxx/Makefile
index be2a46882f65..b270c9d06d5d 100644
--- a/devel/wasi-libcxx/Makefile
+++ b/devel/wasi-libcxx/Makefile
@@ -1,9 +1,11 @@
 PORTNAME=	libcxx
-DISTVERSION=	13.0.1
+DISTVERSION?=	0
+PORTREVISION?=	0
 CATEGORIES=	devel lang
 MASTER_SITES=	https://github.com/llvm/llvm-project/releases/download/llvmorg-${DISTVERSION:S/rc/-rc/}/ \
-		https://${PRE_}releases.llvm.org/${LLVM_RELEASE}/${RCDIR}
+		https://${PRE_}releases.llvm.org/${LLVM_RELEASE}/${RCDIR}/
 PKGNAMEPREFIX=	wasi-
+PKGNAMESUFFIX=	${LLVM_VERSION}
 DISTNAME=	llvm-project-${DISTVERSION}.src
 DISTFILES=	llvm-project-${DISTVERSION}.src${EXTRACT_SUFX}
 
@@ -13,44 +15,54 @@ WWW=		https://llvm.org/
 
 LICENSE=	LLVM2
 LICENSE_NAME=	Apache License 2.0 with LLVM Exceptions
-LICENSE_FILE=	${WRKSRC}/LICENSE.TXT
+LICENSE_FILE=	${WRKSRC}/llvm/LICENSE.TXT
 LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
 
+.if ${DISTVERSION} == 0
+IGNORE=		is a meta port; there is nothing to build
+.endif
+
 BUILD_DEPENDS=	${WASI_SYSROOT}/include/stdarg.h:devel/wasi-libc \
-		clang${LLVM_SUFFIX}:devel/llvm${LLVM_SUFFIX}
+		wasi-compiler-rt${LLVM_VERSION}>0:devel/wasi-compiler-rt${LLVM_VERSION}
 
-USES=		cmake tar:xz
-NO_ARCH=	yes
+USES=		cmake llvm:${LLVM_SUFFIX} tar:xz
 
-SSP_UNSAFE=	yes
-CC=		${LOCALBASE}/bin/clang${LLVM_SUFFIX}
-CXX=		${LOCALBASE}/bin/clang++${LLVM_SUFFIX}
 LLVM_RELEASE=	${DISTVERSION:C/rc.*//}
 LLVM_SUFFIX=	${LLVM_RELEASE:C/\.[0-9]\.[0-9]$//}
-LLVM_PREFIX=	${PREFIX}/llvm${LLVM_SUFFIX}
-WASI_SYSROOT=	${LOCALBASE}/share/wasi-sysroot
-WRKSRC=		${WRKDIR}/${DISTNAME}/libcxx
-
-CONFIGURE_ENV+=	CC="${CC}" CFLAGS="${CFLAGS}"
-CONFIGURE_ENV+=	CXX="${CXX}" CXXFLAGS="${CXXFLAGS}"
+DISTINFO_FILE=	${PORTSDIR}/${LLVM_PORT}/distinfo
+SSP_UNSAFE=	yes
+NO_ARCH=	yes
+PLIST=		${.CURDIR}/pkg-plist
 
+CONFIGURE_ENV+=	CC="${CC}" CFLAGS="${CFLAGS}" \
+		CXX="${CXX}" CXXFLAGS="${CXXFLAGS}"
+CC=		${LOCALBASE}/bin/clang${LLVM_VERSION}
+CXX=		${LOCALBASE}/bin/clang++${LLVM_VERSION}
+WASI_SYSROOT=	${LOCALBASE}/share/wasi-sysroot
+TRIPLE=		wasm32-wasi
+WITHOUT_CPU_CFLAGS=	yes
+# try to sync with https://github.com/WebAssembly/wasi-sdk
+# Makefile and wasi-sdk.cmake
 CMAKE_INSTALL_PREFIX=	${PREFIX}/share/wasi-sysroot
-CMAKE_ARGS=	-DCMAKE_C_COMPILER_WORKS=1 \
-		-DCMAKE_CXX_COMPILER_WORKS=1 \
+CMAKE_SOURCE_PATH=	${WRKSRC}/runtimes
+CMAKE_ARGS=	-DCMAKE_AR=${LOCALBASE}/bin/llvm-ar${LLVM_VERSION} \
+		-DCMAKE_RANLIB=${LOCALBASE}/bin/llvm-ranlib${LLVM_VERSION} \
+		-DCMAKE_C_COMPILER_TARGET=${TRIPLE} \
+		-DCMAKE_CXX_COMPILER_TARGET=${TRIPLE} \
+		-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
+		-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
+		-DCMAKE_C_COMPILER_WORKS=ON \
+		-DCMAKE_CXX_COMPILER_WORKS=ON \
+		-DCMAKE_STAGING_PREFIX=${CMAKE_INSTALL_PREFIX} \
+		-DLLVM_CONFIG_PATH=${LOCALBASE}/bin/${LLVM_CONFIG} \
 		-DCXX_SUPPORTS_CXX11=ON \
-		-DLLVM_COMPILER_CHECKED=ON \
-		-DUNIX:BOOL=ON \
-		-DCMAKE_SYSROOT=${WASI_SYSROOT} \
-		-DCMAKE_CXX_COMPILER_TARGET=wasm32-wasi \
-		-DLLVM_CONFIG_PATH=${LOCALBASE}/bin/llvm-config${LLVM_SUFFIX} \
-		-DLIBCXX_LIBDIR_SUFFIX=/wasm32-wasi \
-		-DLIBCXX_INCLUDE_BENCHMARKS:BOOL=FALSE \
-		-DLIBCXX_INCLUDE_TESTS:BOOL=FALSE \
 		-DLIBCXX_ENABLE_THREADS:BOOL=OFF \
 		-DLIBCXX_HAS_PTHREAD_API:BOOL=OFF \
 		-DLIBCXX_HAS_EXTERNAL_THREAD_API:BOOL=OFF \
 		-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \
 		-DLIBCXX_HAS_WIN32_THREAD_API:BOOL=OFF \
+		-DLLVM_COMPILER_CHECKED=ON \
 		-DLIBCXX_ENABLE_SHARED:BOOL=OFF \
 		-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL=OFF \
 		-DLIBCXX_ENABLE_EXCEPTIONS:BOOL=OFF \
@@ -58,7 +70,6 @@ CMAKE_ARGS=	-DCMAKE_C_COMPILER_WORKS=1 \
 		-DLIBCXX_CXX_ABI=libcxxabi \
 		-DLIBCXX_HAS_MUSL_LIBC:BOOL=ON \
 		-DLIBCXX_ABI_VERSION=2 \
-		-DLIBCXXABI_LIBDIR_SUFFIX=/wasm32-wasi \
 		-DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF \
 		-DLIBCXXABI_ENABLE_SHARED:BOOL=OFF \
 		-DLIBCXXABI_SILENT_TERMINATE:BOOL=ON \
@@ -67,92 +78,10 @@ CMAKE_ARGS=	-DCMAKE_C_COMPILER_WORKS=1 \
 		-DLIBCXXABI_HAS_EXTERNAL_THREAD_API:BOOL=OFF \
 		-DLIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY:BOOL=OFF \
 		-DLIBCXXABI_HAS_WIN32_THREAD_API:BOOL=OFF \
-		-DLIBCXXABI_LIBCXX_INCLUDES=${CONFIGURE_WRKSRC}/include/c++/v1 \
-		-DLIBCXX_SUPPORTS_FNO_EXCEPTIONS_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_NOSTDLIBXX_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG:BOOL=ON \
-		-DLIBCXX_HAS_COMMENT_LIB_PRAGMA:BOOL=ON \
-		-DLIBCXX_SUPPORTS_FALIGNED_ALLOCATION_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_NOSTDINCXX_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_FVISIBILITY_EQ_HIDDEN_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WALL_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WEXTRA_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_W_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WWRITE_STRINGS_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_LONG_LONG_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WEXTRA_SEMI_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WUNDEF_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_USER_DEFINED_LITERALS_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_COVERED_SWITCH_DEFAULT_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_SUGGEST_OVERRIDE_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_IGNORED_ATTRIBUTES_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_WNO_ERROR_FLAG:BOOL=ON \
-		-DLIBCXX_SUPPORTS_EHS_FLAG:BOOL=OFF \
-		-DLIBCXX_SUPPORTS_EHA_FLAG:BOOL=OFF \
-		-DLIBCXX_SUPPORTS_ZL_FLAG:BOOL=OFF \
-		-DLIBCXX_SUPPORTS_NODEFAULTLIB_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_FNO_EXCEPTIONS_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG:BOOL=ON \
-		-DLIBCXXABI_HAS_COMMENT_LIB_PRAGMA:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_FALIGNED_ALLOCATION_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_NOSTDINCXX_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_FVISIBILITY_EQ_HIDDEN_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WALL_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WEXTRA_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_W_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WWRITE_STRINGS_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_UNUSED_PARAMETER_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_LONG_LONG_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WERROR_EQ_RETURN_TYPE_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WEXTRA_SEMI_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WUNDEF_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_USER_DEFINED_LITERALS_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_COVERED_SWITCH_DEFAULT_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_SUGGEST_OVERRIDE_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_IGNORED_ATTRIBUTES_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNO_ERROR_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_EHS_FLAG:BOOL=OFF \
-		-DLIBCXXABI_SUPPORTS_EHA_FLAG:BOOL=OFF \
-		-DLIBCXXABI_SUPPORTS_ZL_FLAG:BOOL=OFF \
-		-DLIBCXXABI_SUPPORTS_NODEFAULTLIB_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WCHAR_SUBSCRIPTS_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WCONVERSION_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WMISMATCHED_TAGS_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WMISSING_BRACES_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WNEWLINE_EOF_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WUNUSED_FUNCTION_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSHADOW_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSHORTEN_64_TO_32_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSIGN_COMPARE_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSIGN_CONVERSION_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSTRICT_ALIASING_EQ_2_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WSTRICT_OVERFLOW_EQ_4_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WUNUSED_PARAMETER_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WUNUSED_VARIABLE_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_WX_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_PEDANTIC_FLAG:BOOL=ON \
-		-DLIBCXXABI_SUPPORTS_FSTRICT_ALIASING_FLAG:BOOL=ON
-
-post-extract:
-	@${MKDIR} ${WRKDIR}/.build_cxxabi
-
-post-configure:
-	@cd ${WRKDIR}/.build_cxxabi  && \
-		${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${WRKDIR}/${DISTNAME}/libcxxabi
-
-post-build:
-	@${LOCALBASE}/bin/llvm-ranlib${LLVM_SUFFIX} ${CONFIGURE_WRKSRC}/lib/wasm32-wasi/*.a
-	@cd ${WRKDIR}/.build_cxxabi && \
-		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${ALL_TARGET}
-	@${LOCALBASE}/bin/llvm-ranlib${LLVM_SUFFIX} ${WRKDIR}/.build_cxxabi/lib/wasm32-wasi/*.a
-
-post-install:
-	@cd ${WRKDIR}/.build_cxxabi && \
-		${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${INSTALL_TARGET}
+		-DUNIX:BOOL=ON \
+		-DCMAKE_SYSROOT=${WASI_SYSROOT} \
+		-DLIBCXX_LIBDIR_SUFFIX=/${TRIPLE} \
+		-DLIBCXXABI_LIBDIR_SUFFIX=/${TRIPLE} \
+		-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
 
 .include <bsd.port.mk>
diff --git a/devel/wasi-libcxx/distinfo b/devel/wasi-libcxx/distinfo
deleted file mode 100644
index bea44b0abafa..000000000000
--- a/devel/wasi-libcxx/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1644329406
-SHA256 (llvm-project-13.0.1.src.tar.xz) = 326335a830f2e32d06d0a36393b5455d17dc73e0bd1211065227ee014f92cbf8
-SIZE (llvm-project-13.0.1.src.tar.xz) = 97584928
diff --git a/devel/wasi-libcxx12/Makefile b/devel/wasi-libcxx12/Makefile
new file mode 100644
index 000000000000..0cbe734219a7
--- /dev/null
+++ b/devel/wasi-libcxx12/Makefile
@@ -0,0 +1,6 @@
+# must sync with devel/llvm12
+DISTVERSION=	12.0.1
+
+MASTERDIR=	${.CURDIR}/../wasi-libcxx
+
+.include "${MASTERDIR}/Makefile"
diff --git a/devel/wasi-libcxx12/pkg-plist b/devel/wasi-libcxx12/pkg-plist
new file mode 100644
index 000000000000..93aa4e682b3f
--- /dev/null
+++ b/devel/wasi-libcxx12/pkg-plist
@@ -0,0 +1,191 @@
+share/wasi-sysroot/include/c++/v1/__availability
+share/wasi-sysroot/include/c++/v1/__bit_reference
+share/wasi-sysroot/include/c++/v1/__bits
+share/wasi-sysroot/include/c++/v1/__bsd_locale_defaults.h
+share/wasi-sysroot/include/c++/v1/__bsd_locale_fallbacks.h
+share/wasi-sysroot/include/c++/v1/__config
+share/wasi-sysroot/include/c++/v1/__cxxabi_config.h
+share/wasi-sysroot/include/c++/v1/__debug
+share/wasi-sysroot/include/c++/v1/__errc
+share/wasi-sysroot/include/c++/v1/__functional_03
+share/wasi-sysroot/include/c++/v1/__functional_base
+share/wasi-sysroot/include/c++/v1/__functional_base_03
+share/wasi-sysroot/include/c++/v1/__hash_table
+share/wasi-sysroot/include/c++/v1/__libcpp_version
+share/wasi-sysroot/include/c++/v1/__locale
+share/wasi-sysroot/include/c++/v1/__memory/allocator_traits.h
+share/wasi-sysroot/include/c++/v1/__memory/base.h
+share/wasi-sysroot/include/c++/v1/__memory/pointer_traits.h
+share/wasi-sysroot/include/c++/v1/__memory/utilities.h
+share/wasi-sysroot/include/c++/v1/__mutex_base
+share/wasi-sysroot/include/c++/v1/__node_handle
+share/wasi-sysroot/include/c++/v1/__nullptr
+share/wasi-sysroot/include/c++/v1/__split_buffer
+share/wasi-sysroot/include/c++/v1/__sso_allocator
+share/wasi-sysroot/include/c++/v1/__std_stream
+share/wasi-sysroot/include/c++/v1/__string
+share/wasi-sysroot/include/c++/v1/__support/android/locale_bionic.h
+share/wasi-sysroot/include/c++/v1/__support/fuchsia/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/ibm/limits.h
+share/wasi-sysroot/include/c++/v1/__support/ibm/locale_mgmt_aix.h
+share/wasi-sysroot/include/c++/v1/__support/ibm/nanosleep.h
+share/wasi-sysroot/include/c++/v1/__support/ibm/support.h
+share/wasi-sysroot/include/c++/v1/__support/ibm/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/musl/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/newlib/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/nuttx/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/openbsd/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/solaris/floatingpoint.h
+share/wasi-sysroot/include/c++/v1/__support/solaris/wchar.h
+share/wasi-sysroot/include/c++/v1/__support/solaris/xlocale.h
+share/wasi-sysroot/include/c++/v1/__support/win32/limits_msvc_win32.h
+share/wasi-sysroot/include/c++/v1/__support/win32/locale_win32.h
+share/wasi-sysroot/include/c++/v1/__support/xlocale/__nop_locale_mgmt.h
+share/wasi-sysroot/include/c++/v1/__support/xlocale/__posix_l_fallback.h
+share/wasi-sysroot/include/c++/v1/__support/xlocale/__strtonum_fallback.h
+share/wasi-sysroot/include/c++/v1/__threading_support
+share/wasi-sysroot/include/c++/v1/__tree
+share/wasi-sysroot/include/c++/v1/__tuple
+share/wasi-sysroot/include/c++/v1/__undef_macros
+share/wasi-sysroot/include/c++/v1/algorithm
+share/wasi-sysroot/include/c++/v1/any
+share/wasi-sysroot/include/c++/v1/array
+share/wasi-sysroot/include/c++/v1/atomic
+share/wasi-sysroot/include/c++/v1/barrier
+share/wasi-sysroot/include/c++/v1/bit
+share/wasi-sysroot/include/c++/v1/bitset
+share/wasi-sysroot/include/c++/v1/cassert
+share/wasi-sysroot/include/c++/v1/ccomplex
+share/wasi-sysroot/include/c++/v1/cctype
+share/wasi-sysroot/include/c++/v1/cerrno
+share/wasi-sysroot/include/c++/v1/cfenv
+share/wasi-sysroot/include/c++/v1/cfloat
+share/wasi-sysroot/include/c++/v1/charconv
+share/wasi-sysroot/include/c++/v1/chrono
+share/wasi-sysroot/include/c++/v1/cinttypes
+share/wasi-sysroot/include/c++/v1/ciso646
+share/wasi-sysroot/include/c++/v1/climits
+share/wasi-sysroot/include/c++/v1/clocale
+share/wasi-sysroot/include/c++/v1/cmath
+share/wasi-sysroot/include/c++/v1/codecvt
+share/wasi-sysroot/include/c++/v1/compare
+share/wasi-sysroot/include/c++/v1/complex
+share/wasi-sysroot/include/c++/v1/complex.h
+share/wasi-sysroot/include/c++/v1/concepts
+share/wasi-sysroot/include/c++/v1/condition_variable
+share/wasi-sysroot/include/c++/v1/csetjmp
+share/wasi-sysroot/include/c++/v1/csignal
+share/wasi-sysroot/include/c++/v1/cstdarg
+share/wasi-sysroot/include/c++/v1/cstdbool
+share/wasi-sysroot/include/c++/v1/cstddef
+share/wasi-sysroot/include/c++/v1/cstdint
+share/wasi-sysroot/include/c++/v1/cstdio
+share/wasi-sysroot/include/c++/v1/cstdlib
+share/wasi-sysroot/include/c++/v1/cstring
+share/wasi-sysroot/include/c++/v1/ctgmath
+share/wasi-sysroot/include/c++/v1/ctime
+share/wasi-sysroot/include/c++/v1/ctype.h
+share/wasi-sysroot/include/c++/v1/cwchar
+share/wasi-sysroot/include/c++/v1/cwctype
+share/wasi-sysroot/include/c++/v1/cxxabi.h
+share/wasi-sysroot/include/c++/v1/deque
+share/wasi-sysroot/include/c++/v1/errno.h
+share/wasi-sysroot/include/c++/v1/exception
+share/wasi-sysroot/include/c++/v1/execution
+share/wasi-sysroot/include/c++/v1/experimental/__config
+share/wasi-sysroot/include/c++/v1/experimental/__memory
+share/wasi-sysroot/include/c++/v1/experimental/algorithm
+share/wasi-sysroot/include/c++/v1/experimental/coroutine
+share/wasi-sysroot/include/c++/v1/experimental/deque
+share/wasi-sysroot/include/c++/v1/experimental/filesystem
+share/wasi-sysroot/include/c++/v1/experimental/forward_list
+share/wasi-sysroot/include/c++/v1/experimental/functional
+share/wasi-sysroot/include/c++/v1/experimental/iterator
+share/wasi-sysroot/include/c++/v1/experimental/list
+share/wasi-sysroot/include/c++/v1/experimental/map
+share/wasi-sysroot/include/c++/v1/experimental/memory_resource
+share/wasi-sysroot/include/c++/v1/experimental/propagate_const
+share/wasi-sysroot/include/c++/v1/experimental/regex
+share/wasi-sysroot/include/c++/v1/experimental/set
+share/wasi-sysroot/include/c++/v1/experimental/simd
+share/wasi-sysroot/include/c++/v1/experimental/string
+share/wasi-sysroot/include/c++/v1/experimental/type_traits
+share/wasi-sysroot/include/c++/v1/experimental/unordered_map
+share/wasi-sysroot/include/c++/v1/experimental/unordered_set
+share/wasi-sysroot/include/c++/v1/experimental/utility
+share/wasi-sysroot/include/c++/v1/experimental/vector
+share/wasi-sysroot/include/c++/v1/ext/__hash
+share/wasi-sysroot/include/c++/v1/ext/hash_map
+share/wasi-sysroot/include/c++/v1/ext/hash_set
+share/wasi-sysroot/include/c++/v1/fenv.h
+share/wasi-sysroot/include/c++/v1/filesystem
+share/wasi-sysroot/include/c++/v1/float.h
+share/wasi-sysroot/include/c++/v1/forward_list
+share/wasi-sysroot/include/c++/v1/fstream
+share/wasi-sysroot/include/c++/v1/functional
+share/wasi-sysroot/include/c++/v1/future
+share/wasi-sysroot/include/c++/v1/initializer_list
+share/wasi-sysroot/include/c++/v1/inttypes.h
+share/wasi-sysroot/include/c++/v1/iomanip
+share/wasi-sysroot/include/c++/v1/ios
+share/wasi-sysroot/include/c++/v1/iosfwd
+share/wasi-sysroot/include/c++/v1/iostream
+share/wasi-sysroot/include/c++/v1/istream
+share/wasi-sysroot/include/c++/v1/iterator
+share/wasi-sysroot/include/c++/v1/latch
+share/wasi-sysroot/include/c++/v1/limits
+share/wasi-sysroot/include/c++/v1/limits.h
+share/wasi-sysroot/include/c++/v1/list
+share/wasi-sysroot/include/c++/v1/locale
+share/wasi-sysroot/include/c++/v1/locale.h
+share/wasi-sysroot/include/c++/v1/map
+share/wasi-sysroot/include/c++/v1/math.h
+share/wasi-sysroot/include/c++/v1/memory
+share/wasi-sysroot/include/c++/v1/module.modulemap
+share/wasi-sysroot/include/c++/v1/mutex
+share/wasi-sysroot/include/c++/v1/new
+share/wasi-sysroot/include/c++/v1/numbers
+share/wasi-sysroot/include/c++/v1/numeric
+share/wasi-sysroot/include/c++/v1/optional
+share/wasi-sysroot/include/c++/v1/ostream
+share/wasi-sysroot/include/c++/v1/queue
+share/wasi-sysroot/include/c++/v1/random
+share/wasi-sysroot/include/c++/v1/ratio
+share/wasi-sysroot/include/c++/v1/regex
+share/wasi-sysroot/include/c++/v1/scoped_allocator
+share/wasi-sysroot/include/c++/v1/semaphore
+share/wasi-sysroot/include/c++/v1/set
+share/wasi-sysroot/include/c++/v1/setjmp.h
+share/wasi-sysroot/include/c++/v1/shared_mutex
+share/wasi-sysroot/include/c++/v1/span
+share/wasi-sysroot/include/c++/v1/sstream
+share/wasi-sysroot/include/c++/v1/stack
+share/wasi-sysroot/include/c++/v1/stdbool.h
+share/wasi-sysroot/include/c++/v1/stddef.h
+share/wasi-sysroot/include/c++/v1/stdexcept
+share/wasi-sysroot/include/c++/v1/stdint.h
+share/wasi-sysroot/include/c++/v1/stdio.h
+share/wasi-sysroot/include/c++/v1/stdlib.h
+share/wasi-sysroot/include/c++/v1/streambuf
+share/wasi-sysroot/include/c++/v1/string
+share/wasi-sysroot/include/c++/v1/string.h
+share/wasi-sysroot/include/c++/v1/string_view
+share/wasi-sysroot/include/c++/v1/strstream
+share/wasi-sysroot/include/c++/v1/system_error
+share/wasi-sysroot/include/c++/v1/tgmath.h
+share/wasi-sysroot/include/c++/v1/thread
+share/wasi-sysroot/include/c++/v1/tuple
+share/wasi-sysroot/include/c++/v1/type_traits
+share/wasi-sysroot/include/c++/v1/typeindex
+share/wasi-sysroot/include/c++/v1/typeinfo
+share/wasi-sysroot/include/c++/v1/unordered_map
+share/wasi-sysroot/include/c++/v1/unordered_set
+share/wasi-sysroot/include/c++/v1/utility
+share/wasi-sysroot/include/c++/v1/valarray
+share/wasi-sysroot/include/c++/v1/variant
+share/wasi-sysroot/include/c++/v1/vector
+share/wasi-sysroot/include/c++/v1/version
+share/wasi-sysroot/include/c++/v1/wchar.h
+share/wasi-sysroot/include/c++/v1/wctype.h
+share/wasi-sysroot/lib/wasm32-wasi/libc++.a
*** 3414 LINES SKIPPED ***