diff --git a/crates/c-api/CMakeLists.txt b/crates/c-api/CMakeLists.txt index 2112f9b5a950..953be8c9330f 100644 --- a/crates/c-api/CMakeLists.txt +++ b/crates/c-api/CMakeLists.txt @@ -53,6 +53,8 @@ feature(demangle ON) feature(threads ON) feature(gc ON) feature(async ON) +feature(cranelift ON) +feature(winch ON) # ... if you add a line above this be sure to also change: # # crates/c-api/include/wasmtime/conf.h.in @@ -164,6 +166,7 @@ endif() set(DOXYGEN_CONF_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in) set(DOXYGEN_CONF_OUT ${CMAKE_BINARY_DIR}/doxygen.conf) configure_file(${DOXYGEN_CONF_IN} ${DOXYGEN_CONF_OUT}) -add_custom_target(doc doxygen ${DOXYGEN_CONF_OUT} +add_custom_target(doc + COMMAND doxygen ${DOXYGEN_CONF_OUT} DEPENDS ${WASMTIME_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.toml index 46336ed16deb..5b8a964f25ec 100644 --- a/crates/c-api/Cargo.toml +++ b/crates/c-api/Cargo.toml @@ -22,7 +22,7 @@ doctest = false env_logger = { workspace = true, optional = true } anyhow = { workspace = true } once_cell = { workspace = true } -wasmtime = { workspace = true, features = ['cranelift', 'runtime', 'gc', 'std'] } +wasmtime = { workspace = true, features = ['runtime', 'gc', 'std'] } wasmtime-c-api-macros = { workspace = true } log = { workspace = true } tracing = { workspace = true } @@ -51,6 +51,8 @@ addr2line = ["wasmtime/addr2line"] demangle = ["wasmtime/demangle"] threads = ["wasmtime/threads"] gc = ["wasmtime/gc"] +cranelift = ['wasmtime/cranelift'] +winch = ['wasmtime/winch'] # ... if you add a line above this be sure to also change: # # crates/c-api/artifact/Cargo.toml diff --git a/crates/c-api/artifact/Cargo.toml b/crates/c-api/artifact/Cargo.toml index d14123550f65..a64007cc225e 100644 --- a/crates/c-api/artifact/Cargo.toml +++ b/crates/c-api/artifact/Cargo.toml @@ -32,6 +32,8 @@ default = [ 'demangle', 'threads', 'gc', + 'cranelift', + 'winch', # ... if you add a line above this be sure to also change: # # crates/c-api/CMakeLists.txt @@ -50,5 +52,7 @@ demangle = ["wasmtime-c-api/demangle"] wat = ["wasmtime-c-api/wat"] threads = ["wasmtime-c-api/threads"] gc = ["wasmtime-c-api/gc"] +cranelift = ["wasmtime-c-api/cranelift"] +winch = ["wasmtime-c-api/winch"] # ... if you add a line above this be sure to read the comment at the end of # `default` diff --git a/crates/c-api/doxygen.conf.in b/crates/c-api/doxygen.conf.in index b2a7c2998b75..1f6645dfda93 100644 --- a/crates/c-api/doxygen.conf.in +++ b/crates/c-api/doxygen.conf.in @@ -864,7 +864,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = include +INPUT = include @CMAKE_BINARY_DIR@/include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/crates/c-api/include/wasmtime/conf.h.in b/crates/c-api/include/wasmtime/conf.h.in index 44cbd4d87f17..009c00b9d289 100644 --- a/crates/c-api/include/wasmtime/conf.h.in +++ b/crates/c-api/include/wasmtime/conf.h.in @@ -20,5 +20,11 @@ #cmakedefine WASMTIME_FEATURE_THREADS #cmakedefine WASMTIME_FEATURE_GC #cmakedefine WASMTIME_FEATURE_ASYNC +#cmakedefine WASMTIME_FEATURE_CRANELIFT +#cmakedefine WASMTIME_FEATURE_WINCH + +#if defined(WASMTIME_FEATURE_CRANELIFT) || defined(WASMTIME_FEATURE_WINCH) +#define WASMTIME_FEATURE_COMPILER +#endif #endif // WASMTIME_CONF_H diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h index 7c6f60b2fe12..0cd970ccc9b3 100644 --- a/crates/c-api/include/wasmtime/config.h +++ b/crates/c-api/include/wasmtime/config.h @@ -240,6 +240,8 @@ WASMTIME_CONFIG_PROP(void, wasm_multi_memory, bool) */ WASMTIME_CONFIG_PROP(void, wasm_memory64, bool) +#ifdef WASMTIME_FEATURE_COMPILER + /** * \brief Configures how JIT code will be compiled. * @@ -247,6 +249,8 @@ WASMTIME_CONFIG_PROP(void, wasm_memory64, bool) */ WASMTIME_CONFIG_PROP(void, strategy, wasmtime_strategy_t) +#endif // WASMTIME_FEATURE_COMPILER + #ifdef WASMTIME_FEATURE_PARALLEL_COMPILATION /** @@ -260,6 +264,8 @@ WASMTIME_CONFIG_PROP(void, parallel_compilation, bool) #endif // WASMTIME_FEATURE_PARALLEL_COMPILATION +#ifdef WASMTIME_FEATURE_COMPILER + /** * \brief Configures whether Cranelift's debug verifier is enabled. * @@ -292,6 +298,8 @@ WASMTIME_CONFIG_PROP(void, cranelift_nan_canonicalization, bool) */ WASMTIME_CONFIG_PROP(void, cranelift_opt_level, wasmtime_opt_level_t) +#endif // WASMTIME_FEATURE_COMPILER + /** * \brief Configures the profiling strategy used for JIT code. * @@ -372,6 +380,8 @@ wasmtime_config_cache_config_load(wasm_config_t *, const char *); #endif // WASMTIME_FEATURE_CACHE +#ifdef WASMTIME_FEATURE_COMPILER + /** * \brief Configures the target triple that this configuration will produce * machine code for. @@ -411,6 +421,8 @@ WASM_API_EXTERN void wasmtime_config_cranelift_flag_set(wasm_config_t *, const char *key, const char *value); +#endif // WASMTIME_FEATURE_COMPILER + /** * \brief Configures whether, when on macOS, Mach ports are used for exception * handling instead of traditional Unix-based signal handling. diff --git a/crates/c-api/include/wasmtime/module.h b/crates/c-api/include/wasmtime/module.h index 0460798ede30..286f784bd561 100644 --- a/crates/c-api/include/wasmtime/module.h +++ b/crates/c-api/include/wasmtime/module.h @@ -27,6 +27,8 @@ extern "C" { */ typedef struct wasmtime_module wasmtime_module_t; +#ifdef WASMTIME_FEATURE_COMPILER + /** * \brief Compiles a WebAssembly binary into a #wasmtime_module_t * @@ -46,6 +48,8 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_new(wasm_engine_t *engine, size_t wasm_len, wasmtime_module_t **ret); +#endif // WASMTIME_FEATURE_COMPILER + /** * \brief Deletes a module. */ @@ -69,6 +73,8 @@ WASM_API_EXTERN void wasmtime_module_imports(const wasmtime_module_t *module, WASM_API_EXTERN void wasmtime_module_exports(const wasmtime_module_t *module, wasm_exporttype_vec_t *out); +#ifdef WASMTIME_FEATURE_COMPILER + /** * \brief Validate a WebAssembly binary. * @@ -101,6 +107,8 @@ wasmtime_module_validate(wasm_engine_t *engine, const uint8_t *wasm, WASM_API_EXTERN wasmtime_error_t * wasmtime_module_serialize(wasmtime_module_t *module, wasm_byte_vec_t *ret); +#endif // WASMTIME_FEATURE_COMPILER + /** * \brief Build a module from serialized data. * @@ -109,7 +117,7 @@ wasmtime_module_serialize(wasmtime_module_t *module, wasm_byte_vec_t *ret); * * This function is not safe to receive arbitrary user input. See the Rust * documentation for more information on what inputs are safe to pass in here - * (e.g. only that of #wasmtime_module_serialize) + * (e.g. only that of `wasmtime_module_serialize`) */ WASM_API_EXTERN wasmtime_error_t * wasmtime_module_deserialize(wasm_engine_t *engine, const uint8_t *bytes, @@ -127,7 +135,7 @@ wasmtime_module_deserialize(wasm_engine_t *engine, const uint8_t *bytes, * * This function is not safe to receive arbitrary user input. See the Rust * documentation for more information on what inputs are safe to pass in here - * (e.g. only that of #wasmtime_module_serialize) + * (e.g. only that of `wasmtime_module_serialize`) */ WASM_API_EXTERN wasmtime_error_t * wasmtime_module_deserialize_file(wasm_engine_t *engine, const char *path, diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs index fb93ab0d1f34..75d8cd5d9d1c 100644 --- a/crates/c-api/src/config.rs +++ b/crates/c-api/src/config.rs @@ -138,6 +138,7 @@ pub extern "C" fn wasmtime_config_wasm_memory64_set(c: &mut wasm_config_t, enabl } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasmtime_config_strategy_set( c: &mut wasm_config_t, strategy: wasmtime_strategy_t, @@ -156,6 +157,7 @@ pub extern "C" fn wasmtime_config_parallel_compilation_set(c: &mut wasm_config_t } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set( c: &mut wasm_config_t, enable: bool, @@ -164,6 +166,7 @@ pub extern "C" fn wasmtime_config_cranelift_debug_verifier_set( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasmtime_config_cranelift_nan_canonicalization_set( c: &mut wasm_config_t, enable: bool, @@ -172,6 +175,7 @@ pub extern "C" fn wasmtime_config_cranelift_nan_canonicalization_set( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasmtime_config_cranelift_opt_level_set( c: &mut wasm_config_t, opt_level: wasmtime_opt_level_t, @@ -251,6 +255,7 @@ pub extern "C" fn wasmtime_config_native_unwind_info_set(c: &mut wasm_config_t, } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasmtime_config_target_set( c: &mut wasm_config_t, target: *const c_char, @@ -265,6 +270,7 @@ pub extern "C" fn wasmtime_config_macos_use_mach_ports_set(c: &mut wasm_config_t } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasmtime_config_cranelift_flag_enable( c: &mut wasm_config_t, flag: *const c_char, @@ -274,6 +280,7 @@ pub unsafe extern "C" fn wasmtime_config_cranelift_flag_enable( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasmtime_config_cranelift_flag_set( c: &mut wasm_config_t, flag: *const c_char, diff --git a/crates/c-api/src/module.rs b/crates/c-api/src/module.rs index 970e7ba27ca6..47250fb710d4 100644 --- a/crates/c-api/src/module.rs +++ b/crates/c-api/src/module.rs @@ -29,6 +29,7 @@ pub struct wasm_shared_module_t { wasmtime_c_api_macros::declare_own!(wasm_shared_module_t); #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasm_module_new( store: &mut wasm_store_t, binary: &wasm_byte_vec_t, @@ -40,6 +41,7 @@ pub unsafe extern "C" fn wasm_module_new( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasm_module_validate( store: &mut wasm_store_t, binary: &wasm_byte_vec_t, @@ -105,6 +107,7 @@ pub unsafe extern "C" fn wasm_module_obtain( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasm_module_serialize(module: &wasm_module_t, ret: &mut wasm_byte_vec_t) { if let Ok(buf) = module.module.serialize() { ret.set_buffer(buf); @@ -130,6 +133,7 @@ pub struct wasmtime_module_t { wasmtime_c_api_macros::declare_own!(wasmtime_module_t); #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasmtime_module_new( engine: &wasm_engine_t, wasm: *const u8, @@ -166,6 +170,7 @@ pub extern "C" fn wasmtime_module_imports( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub unsafe extern "C" fn wasmtime_module_validate( engine: &wasm_engine_t, wasm: *const u8, @@ -176,6 +181,7 @@ pub unsafe extern "C" fn wasmtime_module_validate( } #[no_mangle] +#[cfg(any(feature = "cranelift", feature = "winch"))] pub extern "C" fn wasmtime_module_serialize( module: &wasmtime_module_t, ret: &mut wasm_byte_vec_t,