Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Make more efforts to detect system SUNDIALS libraries #1

Merged
merged 12 commits into from
Jan 9, 2023

Conversation

Chris00
Copy link

@Chris00 Chris00 commented Nov 22, 2022

  • Enhance build.rs to try to detect system Sundials libraries;
  • Enable CI.

build.rs Outdated
Comment on lines 136 to 138
#[cfg(target_family = "wasm")] {
(lib_loc, inc_dir, library_type) = build_vendored_sundials();
}
Copy link
Owner

Choose a reason for hiding this comment

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

I tried to cross compile to wasm to no avail. That being said, I'm no wasm expert and it doesn't work in current master. Could you test wasm builds?

Copy link
Author

Choose a reason for hiding this comment

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

I'll start by adding WASM to the CI. Hopefully cmake supports it otherwise that would be the first step...

Copy link
Author

Choose a reason for hiding this comment

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

What is your experience with WASM? On my machine, clang does not succeed to compile the C code — but clearly, the path to stdio.h (present in many sundials files) is probably not the one WASM wants... (like you, I'm far from being an expert in WASM).

   ...
   Compiling sundials-sys v0.2.3 (/home/trch/software/Rust/Scientific/sundials-sys)
error: failed to run custom build command for `sundials-sys v0.2.3 (/home/trch/software/Rust/Scientific/sundials-sys)`

Caused by:
  process didn't exit successfully: `/home/trch/software/Rust/Scientific/sundials-sys/target/debug/build/sundials-sys-95571e3a631130d5/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
  running: "cmake" "/home/trch/software/Rust/Scientific/sundials-sys/vendor" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_STATIC_LIBS=OFF" "-DBUILD_SHARED_LIBS=ON" "-DBUILD_TESTING=OFF" "-DEXAMPLES_INSTALL=OFF" "-DEXAMPLES_ENABLE_C=OFF" "-DBUILD_ARKODE=ON" "-DBUILD_CVODE=ON" "-DBUILD_CVODES=OFF" "-DBUILD_IDA=ON" "-DBUILD_IDAS=OFF" "-DBUILD_KINSOL=ON" "-DOPENMP_ENABLE=OFF" "-DPTHREAD_ENABLE=OFF" "-DCMAKE_INSTALL_PREFIX=/home/trch/software/Rust/Scientific/sundials-sys/target/wasm32-unknown-unknown/debug/build/sundials-sys-0f90bc14c5fa37e0/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_C_COMPILER=/usr/bin/clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_CXX_COMPILER=/usr/bin/clang" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown" "-DCMAKE_ASM_COMPILER=/usr/bin/clang" "-DCMAKE_BUILD_TYPE=Debug"
  -- The C compiler identification is Clang 14.0.6
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/clang
  -- Check for working C compiler: /usr/bin/clang - broken
  -- Configuring incomplete, errors occurred!
   ...
--- stderr
  /usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found
  /usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found, err: true
  CMake Error at /usr/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
    The C compiler

      "/usr/bin/clang"

    is not able to compile a simple test program.
   ...

Copy link
Author

Choose a reason for hiding this comment

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

As I understand it, because the sundials code expects some system resources, Emscripten should be used to compile it. A patch was merged on May 11 in the cmake crate for that. So, if I do

rustup target add wasm32-unknown-emscripten
cargo build --target wasm32-unknown-emscripten

I get

  CMake Error at cmake/macros/SundialsCMakeMacros.cmake:89 (message):
    ************************************************************************

    ERROR: No integer type of size 8 was found.

                     Tried int64_t__int64longlonglong.
                     Try setting the advanced option SUNDIALS_INDEX_TYPE.

    ************************************************************************
  Call Stack (most recent call first):
    cmake/SundialsIndexSize.cmake:45 (print_error)
    cmake/SundialsSetupCompilers.cmake:21 (include)
    CMakeLists.txt:161 (include)


  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

Copy link
Author

Choose a reason for hiding this comment

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

There may not be a way around that: emscripten-core/emscripten#11140 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

@Chris00 Chris00 requested a review from krtab December 24, 2022 16:10
Unfortunately int64_t is currently not supported by emscripten
(emscripten-core/emscripten#11140 (comment)),
so

cargo build --target wasm32-unknown-emscripten

fails
@krtab
Copy link
Owner

krtab commented Jan 9, 2023

This looks good to me as-is, even though I couldn't get the WASM to build. I'll merge and proceed to transfer the crate to you.

@krtab krtab merged commit 939dd8b into krtab:master Jan 9, 2023
@Chris00
Copy link
Author

Chris00 commented Jan 10, 2023

I couldn't get the WASM to build.

There is a SUNDIALS_INDEX_TYPE that probably needs to be set to something other than int64_t. More investigation is needed to compile the C code to WASM. I'll open an issue on the new repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants