diff --git a/Code/MinimalLib/docker/Dockerfile b/Code/MinimalLib/docker/Dockerfile index 777e5286f..c523cd105 100644 --- a/Code/MinimalLib/docker/Dockerfile +++ b/Code/MinimalLib/docker/Dockerfile @@ -5,10 +5,13 @@ # cd Code/MinimalLib/docker # # 2. build the JS and WASM libraries -# (the build-arg arguments are all optional) +# (the build-arg arguments are all optional; in the following +# example we select the more performant, though still experimental, +# native WASM exception handling): # docker build -t rdkit-minimallib --network=host \ # --build-arg "RDKIT_GIT_URL=https://github.com/myfork/rdkit.git" \ -# --build-arg "RDKIT_BRANCH=mybranch" . +# --build-arg "RDKIT_BRANCH=mybranch" \ +# --build-arg "EXCEPTION_HANDLING=-fwasm-exceptions". # # 3. create a temporary container and copy built libraries # from the container to your local filesystem, then destroy @@ -22,6 +25,7 @@ ARG RDKIT_GIT_URL="https://github.com/rdkit/rdkit.git" ARG RDKIT_BRANCH="master" ARG EMSDK_VERSION="latest" +ARG EXCEPTION_HANDLING="-fexceptions -sNO_DISABLE_EXCEPTION_CATCHING" ARG BOOST_MAJOR_VERSION="1" ARG BOOST_MINOR_VERSION="84" ARG BOOST_PATCH_VERSION="0" @@ -30,6 +34,7 @@ FROM debian:bookworm as build-stage ARG RDKIT_GIT_URL ARG RDKIT_BRANCH ARG EMSDK_VERSION +ARG EXCEPTION_HANDLING ARG BOOST_MAJOR_VERSION ARG BOOST_MINOR_VERSION ARG BOOST_PATCH_VERSION @@ -68,7 +73,20 @@ RUN ./emsdk install ${EMSDK_VERSION} && \ #RUN source ./emsdk_env.sh -RUN mkdir /src +RUN echo "source /opt/emsdk/emsdk_env.sh > /dev/null 2>&1" >> ~/.bashrc +SHELL ["/bin/bash", "-c", "-l"] + +WORKDIR /src +RUN wget -q https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \ + tar xzf freetype-${FREETYPE_VERSION}.tar.gz +WORKDIR /src/freetype-${FREETYPE_VERSION} +RUN mkdir build +WORKDIR /src/freetype-${FREETYPE_VERSION}/build +RUN emcmake cmake -DCMAKE_BUILD_TYPE=Release -DWITH_ZLIB=OFF -DWITH_BZip2=OFF -DWITH_PNG=OFF \ + -DCMAKE_C_FLAGS="${EXCEPTION_HANDLING}" -DCMAKE_EXE_LINKER_FLAGS="${EXCEPTION_HANDLING}" \ + -DCMAKE_INSTALL_PREFIX=/opt/freetype .. +RUN make -j2 && make -j2 install + WORKDIR /src ENV RDBASE=/src/rdkit RUN git clone ${RDKIT_GIT_URL} @@ -87,11 +105,11 @@ RUN emcmake cmake -DBoost_INCLUDE_DIR=/opt/boost/include -DRDK_BUILD_FREETYPE_SU -DRDK_BUILD_DESCRIPTORS3D=OFF -DRDK_TEST_MULTITHREADED=OFF \ -DRDK_BUILD_MAEPARSER_SUPPORT=OFF -DRDK_BUILD_COORDGEN_SUPPORT=ON \ -DRDK_BUILD_SLN_SUPPORT=OFF -DRDK_USE_BOOST_IOSTREAMS=OFF \ - -DFREETYPE_INCLUDE_DIRS=/opt/emsdk/upstream/emscripten/cache/sysroot/include/freetype2 \ - -DFREETYPE_LIBRARY=/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libfreetype.a \ - -DCMAKE_CXX_FLAGS="-Wno-enum-constexpr-conversion -s DISABLE_EXCEPTION_CATCHING=0" \ - -DCMAKE_C_FLAGS="-Wno-enum-constexpr-conversion -DCOMPILE_ANSI_ONLY" \ - -DCMAKE_EXE_LINKER_FLAGS="-s MODULARIZE=1 -s EXPORT_NAME=\"'initRDKitModule'\"" .. + -DFREETYPE_INCLUDE_DIRS=/opt/freetype/include/freetype2 \ + -DFREETYPE_LIBRARY=/opt/freetype/lib/libfreetype.a \ + -DCMAKE_CXX_FLAGS="${EXCEPTION_HANDLING} -O3 -DNDEBUG" \ + -DCMAKE_C_FLAGS="${EXCEPTION_HANDLING} -O3 -DNDEBUG -DCOMPILE_ANSI_ONLY" \ + -DCMAKE_EXE_LINKER_FLAGS="${EXCEPTION_HANDLING} -s STACK_OVERFLOW_CHECK=1 -s USE_PTHREADS=0 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s MODULARIZE=1 -s EXPORT_NAME=\"'initRDKitModule'\"" .. # "patch" to make the InChI code work with emscripten: RUN cp /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c.bak && \