Skip to content

Commit

Permalink
wasi: update libc to sdk-20 and modularise LLVM bits
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vishwin committed Nov 20, 2023
1 parent b90161c commit e38b385
Show file tree
Hide file tree
Showing 37 changed files with 3,655 additions and 310 deletions.
2 changes: 1 addition & 1 deletion MOVED
Expand Up @@ -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
Expand Down Expand Up @@ -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
24 changes: 8 additions & 16 deletions Mk/bsd.gecko.mk
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
13 changes: 12 additions & 1 deletion devel/Makefile
Expand Up @@ -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
Expand Down
70 changes: 70 additions & 0 deletions 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>
File renamed without changes.
63 changes: 0 additions & 63 deletions devel/wasi-compiler-rt11/Makefile

This file was deleted.

3 changes: 0 additions & 3 deletions devel/wasi-compiler-rt11/distinfo

This file was deleted.

6 changes: 6 additions & 0 deletions 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"
60 changes: 3 additions & 57 deletions 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"
3 changes: 0 additions & 3 deletions devel/wasi-compiler-rt13/distinfo

This file was deleted.

5 changes: 0 additions & 5 deletions devel/wasi-compiler-rt13/pkg-descr

This file was deleted.

6 changes: 6 additions & 0 deletions 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"
6 changes: 6 additions & 0 deletions 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"
6 changes: 6 additions & 0 deletions 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"
6 changes: 6 additions & 0 deletions 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"
27 changes: 12 additions & 15 deletions 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
Expand All @@ -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:
Expand Down

0 comments on commit e38b385

Please sign in to comment.