Skip to content

Commit

Permalink
Merge pull request #5184 from wasmerio/fix-wamr-ios-build
Browse files Browse the repository at this point in the history
fix(api/wamr): Build `wamr` on `iOS`
  • Loading branch information
xdoardo authored Oct 29, 2024
2 parents dd5d456 + 19d3fde commit ec60064
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,35 @@ fn main() {
.define("WAMR_DISABLE_HW_BOUND_CHECK", "1")
.define("WAMR_BUILD_TARGET", target_arch);

if cfg!(target_os = "windows") {
if target_os == "windows" {
dst.define("CMAKE_CXX_COMPILER", "cl.exe");
dst.define("CMAKE_C_COMPILER", "cl.exe");
dst.define("CMAKE_LINKER_TYPE", "MSVC");
dst.define("WAMR_BUILD_PLATFORM", "windows");
dst.define("WAMR_BUILD_LIBC_UVWASI", "0");
}

if target_os == "ios" {
// XXX: Hacky
//
// Compiling wamr targeting `aarch64-apple-ios` results in
//
// ```
// clang: error: unsupported option '-mfloat-abi=' for target 'aarch64-apple-ios'
// ```
// So, here, we simply remove that setting.
//
// See: https://github.com/bytecodealliance/wasm-micro-runtime/pull/3889
let mut lines = vec![];
let cmake_file_path = wamr_platform_dir.join("CMakeLists.txt");
for line in std::fs::read_to_string(&cmake_file_path).unwrap().lines() {
if !line.contains("-mfloat-abi=hard") {
lines.push(line.to_string())
}
}
std::fs::write(cmake_file_path, lines.join("\n")).unwrap();
}

let dst = dst.build();

// Check output of `cargo build --verbose`, should see something like:
Expand Down

0 comments on commit ec60064

Please sign in to comment.