From 59ee743f6ab5c71fc26aad0c003245bac88d32c8 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 3 Jun 2020 19:22:17 +0200 Subject: [PATCH] Switch to upstream docker image for emscripten build. --- .circleci/config.yml | 2 +- .circleci/docker/Dockerfile.emscripten | 9 ++++----- Changelog.md | 1 + cmake/EthCompilerSettings.cmake | 16 ++++++++-------- scripts/travis-emscripten/build_emscripten.sh | 4 ++++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 624af2f0e..4bebea97f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -598,7 +598,7 @@ jobs: b_ems: docker: - - image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-1 + - image: ethereum/solidity-buildpack-deps:emsdk-1.39.15-2 environment: TERM: xterm steps: diff --git a/.circleci/docker/Dockerfile.emscripten b/.circleci/docker/Dockerfile.emscripten index 67432f6c5..d2456bb2a 100644 --- a/.circleci/docker/Dockerfile.emscripten +++ b/.circleci/docker/Dockerfile.emscripten @@ -26,11 +26,9 @@ # contains a Makefile in the docker/ subdirectory that can be used to create the # required base image using: # -# make version=1.39.15-fastcomp build +# make version=1.39.15 build # -# TODO: switch to the upstream backend by removing "-fastcomp". -# -FROM emscripten/emsdk:1.39.15-fastcomp AS base +FROM emscripten/emsdk:1.39.15 AS base ADD emscripten.jam /usr/src RUN set -ex; \ @@ -47,6 +45,7 @@ RUN set -ex; \ -DZ3_BUILD_TEST_EXECUTABLES=OFF \ -DZ3_BUILD_EXECUTABLE=OFF \ -DZ3_SINGLE_THREADED=ON \ + -DCMAKE_CXX_FLAGS="-s DISABLE_EXCEPTION_CATCHING=0" \ ..; \ make; make install; \ rm -r /usr/src/z3; \ @@ -61,6 +60,6 @@ RUN set -ex; \ echo "using emscripten : : em++ ;" >> project-config.jam ; \ ./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \ --with-system --with-filesystem --with-test --with-program_options \ - cxxflags="-Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ + cxxflags="-s DISABLE_EXCEPTION_CATCHING=0 -Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ --prefix=/emsdk/emscripten/sdk/system install; \ rm -r /usr/src/boost_1_73_0 diff --git a/Changelog.md b/Changelog.md index 43d31035b..62ddd07ea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Language Features: Compiler Features: * Build system: Update the soljson.js build to emscripten 1.39.15 and boost 1.73.0 and include Z3 for integrated SMTChecker support without the callback mechanism. + * Build system: Switch the emscripten build from the fastcomp backend to the upstream backend. * Code Generator: Do not introduce new internal source references for small compiler routines. * Commandline Interface: Adds new option ``--base-path PATH`` to use the given path as the root of the source tree (defaults to the root of the filesystem). * SMTChecker: Support array ``length``. diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index b36af7e3f..1f7600d9b 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -16,9 +16,11 @@ include(EthCheckCXXCompilerFlag) -eth_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support) -if(NOT have_stack_protector_strong_support) - eth_add_cxx_compiler_flag_if_supported(-fstack-protector) +if(NOT EMSCRIPTEN) + eth_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support) + if(NOT have_stack_protector_strong_support) + eth_add_cxx_compiler_flag_if_supported(-fstack-protector) + endif() endif() eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) @@ -109,15 +111,13 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA # Re-enable exception catching (optimisations above -O1 disable it) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0") # Remove any code related to exit (such as atexit) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_EXIT_RUNTIME=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXIT_RUNTIME=0") # Remove any code related to filesystem access - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_FILESYSTEM=1") - # Remove variables even if it needs to be duplicated (can improve speed at the cost of size) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s AGGRESSIVE_VARIABLE_ELIMINATION=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FILESYSTEM=0") # Allow memory growth, but disable some optimisations set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1") # Disable eval() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_DYNAMIC_EXECUTION=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s DYNAMIC_EXECUTION=0") # Disable greedy exception catcher set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NODEJS_CATCH_EXIT=0") # Abort if linking results in any undefined symbols diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index c338a1977..5c7e3f052 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -54,6 +54,10 @@ cmake \ -DTESTS=0 \ .. make -j 4 soljson +# Patch soljson.js for backwards compatibility. +# TODO: remove this with 0.7. +# "viiiii" encodes the signature of the callback function. +sed -i -e 's/addFunction(func,sig){/addFunction(func,sig){sig=sig||"viiiii";/' libsolc/soljson.js cd .. mkdir -p upload