Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDK Docker build scripts, update Emscripten #172

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# NOTE: incompatible_enable_cc_toolchain_resolution is set by default on Bazel
# versions 7.0+, see https://github.com/bazelbuild/bazel/issues/7260.
#
# emsdk documentation asks to set this flag (see
# https://github.com/emscripten-core/emsdk/blob/main/bazel/README.md). And even
# though things seem to work even without this flag, given that this flag
# enables improved Bazel C++ toolchain resolution method that became the
# default in newer Bazel version and does not cause problems, we keep it.
build --incompatible_enable_cc_toolchain_resolution
4 changes: 2 additions & 2 deletions Dockerfile-sdk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:bionic
FROM ubuntu:noble

COPY ./sdk_container.sh /
COPY ./build_wasm.sh /
COPY *.cc *.h *.js *.proto Makefile* *.a /sdk/
COPY *.cc *.h *.js *.proto Makefile* /sdk/

RUN ./sdk_container.sh
2 changes: 2 additions & 0 deletions bazel/dependencies_extra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.

load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")

# Requires proxy_wasm_cpp_sdk_dependencies() to be loaded first.
def proxy_wasm_cpp_sdk_dependencies_extra():
emscripten_deps()
register_emscripten_toolchains()
48 changes: 0 additions & 48 deletions bazel/emsdk.patch

This file was deleted.

9 changes: 3 additions & 6 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ def proxy_wasm_cpp_sdk_repositories():
maybe(
http_archive,
name = "emsdk",
sha256 = "1ca0ff918d476c55707bb99bc0452be28ac5fb8f22a9260a8aae8a38d1bc0e27",
# v3.1.7 with Bazel fixes
strip_prefix = "emsdk-0ea8f8a8707070e9a7c83fbb4a3065683bcf1799/bazel",
url = "https://github.com/emscripten-core/emsdk/archive/0ea8f8a8707070e9a7c83fbb4a3065683bcf1799.tar.gz",
patches = ["@proxy_wasm_cpp_sdk//bazel:emsdk.patch"],
patch_args = ["-p2"],
sha256 = "0cb0eabd6e3ceb1a970a2363e67f2b1689c2d83fbeae1e75901213c1f84de2e2",
strip_prefix = "emsdk-3.1.67/bazel",
url = "https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.67.tar.gz",
)

maybe(
Expand Down
Binary file removed libprotobuf-lite.a
Binary file not shown.
Binary file removed libprotobuf.a
Binary file not shown.
57 changes: 34 additions & 23 deletions sdk_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -y
apt-get install -y --no-install-recommends apt-utils ca-certificates
apt-get autoremove -y
apt-get clean
apt-get install -y --no-install-recommends software-properties-common apt-transport-https git wget curl pkg-config autoconf autotools-dev automake libtool cmake python zlib1g-dev
apt-get install -y --no-install-recommends ca-certificates git autoconf autotools-dev automake libtool cmake python-is-python3 zlib1g-dev make xz-utils libzstd-dev

# gcc-7
apt-get install -y --no-install-recommends gcc-7 g++-7 cpp-7
export CC=gcc-7
export CXX=g++-7
export CPP=cpp-7
# The specific version of GCC does not actually matter as long as it's confirmed to work.
# That's why we explicitly pin gcc version (in this case to gcc 13) - it's the version
# which was tested to work.
apt-get install -y --no-install-recommends gcc-13 g++-13 cpp-13
export CC=gcc-13
export CXX=g++-13
export CPP=cpp-13

NUM_CPUS=$(nproc)
JOBS=$((NUM_CPUS>1 ? NUM_CPUS-1 : NUM_CPUS))

# get $HOME
cd
Expand All @@ -41,36 +45,43 @@ git checkout v3.9.1
git submodule update --init --recursive
./autogen.sh
./configure
make
make -j $JOBS
make check
make install
cd
rm -rf protobuf

# This makes sure that installed dynamic libraries are visible to the dynamic
# linker, because it seems like make install does not take care of that
ldconfig

# emscripten
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk update-tags
./emsdk install 3.1.7
./emsdk activate 3.1.7
git checkout 3.1.67
./emsdk install --shallow 3.1.67
./emsdk activate 3.1.67
source ./emsdk_env.sh
cd

git clone https://github.com/protocolbuffers/protobuf protobuf-wasm
cd protobuf-wasm
git checkout v3.9.1
git submodule update --init --recursive
./autogen.sh
emconfigure ./configure --disable-shared CXXFLAGS="-O3 -flto"
emmake make -j $JOBS
cd

cp protobuf-wasm/src/.libs/libprotobuf-lite.a /sdk/libprotobuf-lite.a
cp protobuf-wasm/src/.libs/libprotobuf.a /sdk/libprotobuf.a
martijneken marked this conversation as resolved.
Show resolved Hide resolved
rm -rf protobuf-wasm

# abseil (optional)
git clone https://github.com/abseil/abseil-cpp
cd abseil-cpp
git checkout 14550beb3b7b97195e483fb74b5efb906395c31e -b Jul302019 # Jul 30 2019
git checkout 4447c7562e3bc702ade25105912dce503f0c4010 -b lts20240722 # Abseil LTS release 20240722.0
emcmake cmake -DCMAKE_CXX_STANDARD=17 "."
emmake make
emmake make -j $JOBS
cd

# WAVM (optional)
apt-get install -y --no-install-recommends llvm-6.0-dev
git clone https://github.com/WAVM/WAVM
cd WAVM
git checkout 1ec06cd202a922015c9041c5ed84f875453c4dc7 -b Oct152019 # Oct 15 2019
cmake "."
make
make install
cd
rm -rf WAVM
Loading