Skip to content

Add WebAssembly support #42

@sssxks

Description

@sssxks

I am using good_lp in a web project and I noticed this document says highs doesn't support wasm targets, but upstreamERGO-Code/HiGHS seems to have wasm support build_webdemo.sh

Reproduction

current behavior when attempting to compile

xks@xks:~/repos/end2$ cargo build --target wasm32-unknown-unknown
   Compiling highs-sys v1.12.1
error: failed to run custom build command for `highs-sys v1.12.1`

Caused by:
  process didn't exit successfully: `/home/xks/repos/end2/target/debug/build/highs-sys-abc5c91127052a9d/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_wasm32-unknown-unknown = None
  CMAKE_TOOLCHAIN_FILE_wasm32_unknown_unknown = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_wasm32-unknown-unknown = None
  CMAKE_GENERATOR_wasm32_unknown_unknown = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_wasm32-unknown-unknown = None
  CMAKE_PREFIX_PATH_wasm32_unknown_unknown = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_wasm32-unknown-unknown = None
  CMAKE_wasm32_unknown_unknown = None
  TARGET_CMAKE = None
  CMAKE = None
  -- The CXX compiler identification is Clang 18.1.3
  -- The C compiler identification is Clang 18.1.3
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - failed
  -- Check for working CXX compiler: /usr/bin/clang++
  -- Check for working CXX compiler: /usr/bin/clang++ - broken
  -- Configuring incomplete, errors occurred!

  --- stderr
  running: cd "/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build" && CMAKE_PREFIX_PATH="" LC_ALL="C" "cmake" "/home/xks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/highs-sys-1.12.1/HiGHS" "-B" "/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build" "-DFAST_BUILD=ON" "-DBUILD_SHARED_LIBS=OFF" "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL" "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=FALSE" "-DZLIB=OFF" "-DCMAKE_SYSTEM_NAME=unknown" "-DCMAKE_SYSTEM_PROCESSOR=wasm32" "-DCMAKE_INSTALL_PREFIX=/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fno-exceptions --target=wasm32-unknown-unknown -w" "-DCMAKE_C_COMPILER=/usr/bin/clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fno-exceptions --target=wasm32-unknown-unknown -w" "-DCMAKE_CXX_COMPILER=/usr/bin/clang++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fno-exceptions --target=wasm32-unknown-unknown -w" "-DCMAKE_ASM_COMPILER=/usr/bin/clang" "-DCMAKE_BUILD_TYPE=Release"
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  CMake Error at /usr/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message):
    The C++ compiler

      "/usr/bin/clang++"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: '/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build/CMakeFiles/CMakeScratch/TryCompile-OGje0t'
      
      Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_47ac3/fast
      /usr/bin/gmake  -f CMakeFiles/cmTC_47ac3.dir/build.make CMakeFiles/cmTC_47ac3.dir/build
      gmake[1]: Entering directory '/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build/CMakeFiles/CMakeScratch/TryCompile-OGje0t'
      Building CXX object CMakeFiles/cmTC_47ac3.dir/testCXXCompiler.cxx.obj
      /usr/bin/clang++   -ffunction-sections -fdata-sections -fno-exceptions --target=wasm32-unknown-unknown -w  -MD -MT CMakeFiles/cmTC_47ac3.dir/testCXXCompiler.cxx.obj -MF CMakeFiles/cmTC_47ac3.dir/testCXXCompiler.cxx.obj.d -o CMakeFiles/cmTC_47ac3.dir/testCXXCompiler.cxx.obj -c /home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build/CMakeFiles/CMakeScratch/TryCompile-OGje0t/testCXXCompiler.cxx
      Linking CXX executable cmTC_47ac3
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_47ac3.dir/link.txt --verbose=1
      /usr/bin/clang++  -ffunction-sections -fdata-sections -fno-exceptions --target=wasm32-unknown-unknown -w  CMakeFiles/cmTC_47ac3.dir/testCXXCompiler.cxx.obj -o cmTC_47ac3 
      clang++: error: unable to execute command: Executable "wasm-ld-18" doesn't exist!
      clang++: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[1]: *** [CMakeFiles/cmTC_47ac3.dir/build.make:100: cmTC_47ac3] Error 1
      gmake[1]: Leaving directory '/home/xks/repos/end2/target/wasm32-unknown-unknown/debug/build/highs-sys-5a38edd1944b2783/out/build/CMakeFiles/CMakeScratch/TryCompile-OGje0t'
      gmake: *** [Makefile:127: cmTC_47ac3/fast] Error 2
      
      

    

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:23 (project)



  thread 'main' (1688573) panicked at /home/xks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cmake-0.1.57/src/lib.rs:1132:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions