Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/icu4c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,50 @@ jobs:
set PATH=C:\tools\msys64\mingw64\bin;%PATH%
.\icuinfo.exe

# WebAssembly build using the WASI SDK.
wasm-wasi-sdk:
runs-on: ubuntu-22.04 # Updated in BRS
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install WASI SDK
env:
WASI_SDK_DOWNLOAD_URL: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.deb
WASI_SDK_DOWNLOAD_SHA256: 3ed68fc89e3299c0e2333360efac89ec60fbc01870732a486ab386267355cc80
run: |
wget -O /tmp/wasi-sdk.deb "${WASI_SDK_DOWNLOAD_URL}"
echo "${WASI_SDK_DOWNLOAD_SHA256} /tmp/wasi-sdk.deb" | sha256sum -c -
sudo apt-get install /tmp/wasi-sdk.deb
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV

- name: Build tools for host system
run: |
TOOLS_BUILD_DIR="$PWD/build/tools";
mkdir -p "$TOOLS_BUILD_DIR";
pushd "$TOOLS_BUILD_DIR";
../../icu4c/source/configure
make -j$(nproc)
echo "TOOLS_BUILD_DIR=$TOOLS_BUILD_DIR" >> $GITHUB_ENV

- name: Cross-build for WebAssembly with WASI SDK
run: |
CROSS_BUILD_DIR="$PWD/build/cross";
mkdir -p "$CROSS_BUILD_DIR";
pushd "$CROSS_BUILD_DIR";
../../icu4c/source/configure --host=wasm32-unknown-wasip1 \
--with-cross-build="$TOOLS_BUILD_DIR" \
--enable-static --disable-shared \
--disable-tools --disable-tests \
--disable-samples --disable-extras \
--with-data-packaging=static \
--prefix / \
CC="$WASI_SDK_PATH/bin/clang" CXX="$WASI_SDK_PATH/bin/clang++" \
AR="$WASI_SDK_PATH/bin/llvm-ar" RANLIB="$WASI_SDK_PATH/bin/llvm-ranlib" \
CFLAGS="-D_WASI_EMULATED_SIGNAL" \
CXXFLAGS="-fno-exceptions -D_WASI_EMULATED_SIGNAL"
make -j$(nproc) PKGDATA_OPTS="--without-assembly -O $CROSS_BUILD_DIR/data/icupkg.inc"
make install DESTDIR="$CROSS_BUILD_DIR/install"

# Run ICU4C tests with stubdata.
run-with-stubdata:
runs-on: ubuntu-22.04 # Updated in BRS
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ powerpc*-apple-darwin*) icu_cv_host_frag=mh-darwin-ppc ;;
*-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
*-*-nto*) icu_cv_host_frag=mh-qnx ;;
*-ncr-*) icu_cv_host_frag=mh-mpras ;;
*-wasi*) icu_cv_host_frag=mh-wasi ;;
*) icu_cv_host_frag=mh-unknown ;;
esac
]
Expand Down
6 changes: 6 additions & 0 deletions icu4c/source/common/putilimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ typedef size_t uintptr_t;
/* not defined */
#elif U_PLATFORM == U_PF_HAIKU
/* not defined */
#elif defined(__wasi__)
/* not defined */
#else
# define U_TZSET tzset
#endif
Expand All @@ -132,6 +134,8 @@ typedef size_t uintptr_t;
/* not defined */
#elif U_PLATFORM == U_PF_IPHONE
/* not defined */
#elif defined(__wasi__)
/* not defined */
#else
# define U_TIMEZONE timezone
#endif
Expand All @@ -147,6 +151,8 @@ typedef size_t uintptr_t;
/* not defined */
#elif U_PLATFORM == U_PF_HAIKU
/* not defined, (well it is but a loop back to icu) */
#elif defined(__wasi__)
/* not defined */
#else
# define U_TZNAME tzname
#endif
Expand Down
76 changes: 76 additions & 0 deletions icu4c/source/config/mh-wasi
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## -*-makefile-*-
## Copyright (C) 2024 and later: Unicode, Inc. and others.
## License & terms of use: http://www.unicode.org/copyright.html
## WASI-specific setup

## Commands to generate dependency files
GEN_DEPS.c= $(CC) -E -MM $(DEFS) $(CPPFLAGS)
GEN_DEPS.cc= $(CXX) -E -MM $(DEFS) $(CPPFLAGS) $(CXXFLAGS)

## Flags for position independent code
SHAREDLIBCFLAGS = -fPIC
SHAREDLIBCXXFLAGS = -fPIC
SHAREDLIBCPPFLAGS = -DPIC

## Additional flags when building libraries and with threads
# WASI Preview 1 without wasi-threads does not support threads
THREADSCPPFLAGS =
LIBCPPFLAGS =

## Compiler switch to embed a runtime search path
LD_RPATH=
LD_RPATH_PRE =

## These are the library specific LDFLAGS
LDFLAGSICUDT=-nodefaultlibs -nostdlib

## Shared object suffix
SO = so
## Non-shared intermediate object suffix
STATIC_O = ao

## Compilation rules
%.$(STATIC_O): $(srcdir)/%.c
$(call SILENT_COMPILE,$(strip $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS)) -o $@ $<)
%.o: $(srcdir)/%.c
$(call SILENT_COMPILE,$(strip $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS)) -o $@ $<)

%.$(STATIC_O): $(srcdir)/%.cpp
$(call SILENT_COMPILE,$(strip $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS)) -o $@ $<)
%.o: $(srcdir)/%.cpp
$(call SILENT_COMPILE,$(strip $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS)) -o $@ $<)


## Dependency rules
%.d: $(srcdir)/%.c
$(call ICU_MSG,(deps)) $<
@$(SHELL) -ec '$(GEN_DEPS.c) $< \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'

%.d: $(srcdir)/%.cpp
$(call ICU_MSG,(deps)) $<
@$(SHELL) -ec '$(GEN_DEPS.cc) $< \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'

## Versioned libraries rules

%.$(SO).$(SO_TARGET_VERSION_MAJOR): %.$(SO).$(SO_TARGET_VERSION)
$(RM) $@ && ln -s ${<F} $@
%.$(SO): %.$(SO).$(SO_TARGET_VERSION_MAJOR)
$(RM) $@ && ln -s ${*F}.$(SO).$(SO_TARGET_VERSION) $@

## Bind internal references

# LDflags that pkgdata will use
BIR_LDFLAGS= -Wl,-Bsymbolic

# Dependencies [i.e. map files] for the final library
BIR_DEPS=

## Remove shared library 's'
STATIC_PREFIX_WHEN_USED =
STATIC_PREFIX =

## End WASI-specific setup
1 change: 1 addition & 0 deletions icu4c/source/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5833,6 +5833,7 @@ powerpc*-apple-darwin*) icu_cv_host_frag=mh-darwin-ppc ;;
*-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
*-*-nto*) icu_cv_host_frag=mh-qnx ;;
*-ncr-*) icu_cv_host_frag=mh-mpras ;;
*-wasi*) icu_cv_host_frag=mh-wasi ;;
*) icu_cv_host_frag=mh-unknown ;;
esac

Expand Down