From bf9fb2e680892f2c298104c37d608cf182c8d345 Mon Sep 17 00:00:00 2001 From: Gavin Hayes Date: Wed, 24 Jan 2024 03:04:48 -0500 Subject: [PATCH] cosmopolitan: Update compiler and update platform_internal.h (#3079) This fixes the cosmopolitan platform. - Switch `build_cosmocc.sh` and platform documentation to explicitly use the x86_64 cosmocc compiler as multi-arch cosmocc won't work here. Older version `cosmocc` just did a x86_64 build. - Add missing items from `platform_internal.h` to fix build. --- core/shared/platform/cosmopolitan/platform_internal.h | 7 +++++++ product-mini/README.md | 6 +++--- product-mini/platforms/cosmopolitan/build_cosmocc.sh | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/shared/platform/cosmopolitan/platform_internal.h b/core/shared/platform/cosmopolitan/platform_internal.h index 66515e30..72602116 100644 --- a/core/shared/platform/cosmopolitan/platform_internal.h +++ b/core/shared/platform/cosmopolitan/platform_internal.h @@ -55,6 +55,7 @@ typedef pthread_t korp_tid; typedef pthread_mutex_t korp_mutex; typedef pthread_cond_t korp_cond; typedef pthread_t korp_thread; +typedef pthread_rwlock_t korp_rwlock; typedef sem_t korp_sem; #define OS_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER @@ -67,6 +68,12 @@ typedef int os_file_handle; typedef DIR *os_dir_stream; typedef int os_raw_file_handle; +static inline os_file_handle +os_get_invalid_handle() +{ + return -1; +} + #if WASM_DISABLE_WRITE_GS_BASE == 0 #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) #define os_writegsbase(base_addr) \ diff --git a/product-mini/README.md b/product-mini/README.md index 22acfeaf..4a827561 100644 --- a/product-mini/README.md +++ b/product-mini/README.md @@ -447,12 +447,12 @@ make ## Cosmopolitan Libc Currently, only x86_64 architecture with interpreter modes is supported. -Clone the Cosmopolitan Libc. Setup `cosmocc` as described in [Getting Started](https://github.com/jart/cosmopolitan/#getting-started) being sure to get it into `PATH`. +Setup `cosmocc` as described in [Getting Started](https://github.com/jart/cosmopolitan/#getting-started) being sure to get its `bin` directory into `PATH`. Build iwasm ``` Bash -export CC=cosmocc -export CXX=cosmoc++ +export CC=x86_64-unknown-cosmo-cc +export CXX=x86_64-unknown-cosmo-c++ rm -rf build mkdir build cmake -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -B build diff --git a/product-mini/platforms/cosmopolitan/build_cosmocc.sh b/product-mini/platforms/cosmopolitan/build_cosmocc.sh index b2ce15d3..8d96027e 100755 --- a/product-mini/platforms/cosmopolitan/build_cosmocc.sh +++ b/product-mini/platforms/cosmopolitan/build_cosmocc.sh @@ -2,8 +2,8 @@ # Copyright (C) 2023 Dylibso. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -export CC=cosmocc -export CXX=cosmoc++ +export CC=x86_64-unknown-cosmo-cc +export CXX=x86_64-unknown-cosmo-c++ rm -rf build mkdir build cmake -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -B build