Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion ortools/base/raw_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
#include "ortools/base/logging.h"
#include "ortools/base/logging_utilities.h"

#if !defined(_MSC_VER)
#if !defined(_MSC_VER) && !defined(__EMSCRIPTEN__)
#include <sys/syscall.h> // for syscall()
#define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
#else
#if !defined(__EMSCRIPTEN__)
Comment thread
Mizux marked this conversation as resolved.
Outdated
#include <io.h> // _write()
// Not so safe, but what can you do?
#define safe_write(fd, s, len) _write(fd, s, len)
#else
#define safe_write(fd, s, len) write(fd, s, len)
#endif
#endif

#if defined(_MSC_VER) && !defined(__MINGW32__)
Expand Down
2 changes: 2 additions & 0 deletions ortools/glop/lp_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ ProblemStatus LPSolver::SolveWithTimeLimit(const LinearProgram& lp,
// Note that we only activate the floating-point exceptions after we are sure
// that the program is valid. This way, if we have input NaNs, we will not
// crash.
#ifndef __EMSCRIPTEN__
ScopedFloatingPointEnv scoped_fenv;
if (absl::GetFlag(FLAGS_lp_solver_enable_fp_exceptions)) {
#ifdef _MSC_VER
Expand All @@ -168,6 +169,7 @@ ProblemStatus LPSolver::SolveWithTimeLimit(const LinearProgram& lp,
scoped_fenv.EnableExceptions(FE_DIVBYZERO | FE_INVALID);
#endif
}
#endif

// Make an internal copy of the problem for the preprocessing.
const bool log_info = parameters_.log_search_progress() || VLOG_IS_ON(1);
Expand Down
22 changes: 22 additions & 0 deletions tools/cross_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ function clean_build() {
mkdir -p "${BUILD_DIR}"
}

function expand_wasm_config() {
local -r EMSDK_VERSION=2.0.14
local -r EMSDK_URL=https://github.com/emscripten-core/emsdk/archive/${EMSDK_VERSION}.tar.gz
local -r EMSDK_RELATIVE_DIR="emsdk-${EMSDK_VERSION}"
local -r EMSDK="${ARCHIVE_DIR}/${EMSDK_RELATIVE_DIR}"
if [ ! -d "${EMSDK}" ]; then
echo "Fetching emscripten"
unpack "${EMSDK_URL}" "${EMSDK_RELATIVE_DIR}"
echo "Installing Emscripten ..."
${EMSDK}/emsdk install ${EMSDK_VERSION}
Comment thread
Mizux marked this conversation as resolved.
Outdated

echo "Activating Emscripten ..."
${EMSDK}/emsdk activate ${EMSDK_VERSION}
fi

declare -r TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
CMAKE_ADDITIONAL_ARGS+=( -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF)
}

function expand_linaro_config() {
#ref: https://releases.linaro.org/components/toolchain/binaries/
local -r LINARO_VERSION=7.5-2019.12
Expand Down Expand Up @@ -322,6 +341,9 @@ function main() {
mips64el)
expand_codescape_config
declare -r QEMU_ARCH=mips64el ;;
wasm32)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for myself, emscripten generate wasm32 by default
ref: https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

expand_wasm_config
declare -r QEMU_ARCH=DISABLED ;;
*)
>&2 echo "Unknown TARGET '${TARGET}'..."
exit 1 ;;
Expand Down