-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasmtime: need to download binaries in build
#7190
Changes from all commits
35c9433
bdac4a0
5562857
f91a8c4
5700deb
ad5197b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest C) | ||
|
||
set(CMAKE_C_STANDARD 11) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an idiom we adopted at cci. It probably does not matter for such a small example, but most of us believe it's better to use best practices as much as possible. |
||
project(test_package C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(wasmtime REQUIRED) | ||
find_package(wasmtime REQUIRED CONFIG) | ||
|
||
add_executable(example example.c) | ||
target_link_libraries(example PRIVATE wasmtime::wasmtime) | ||
target_compile_options(example PRIVATE ${CONAN_COMPILE_DEFINITIONS_WASMTIME}) | ||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE wasmtime::wasmtime) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <wasmtime.h> | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int main() { | ||
char *wat = "(module\n" | ||
"\t(func (param $lhs i32) (param $rhs i32) (result i32)\n" | ||
"\t\tlocal.get $lhs\n" | ||
"\t\tlocal.get $rhs\n" | ||
"\t\ti32.add))"; | ||
wasm_byte_vec_t ret; | ||
wasmtime_error_t *error = wasmtime_wat2wasm(wat, strlen(wat), &ret); | ||
if (error != NULL) { | ||
fprintf(stderr, "wasmtime_wat2wasm failed:\n"); | ||
wasm_name_t message; | ||
wasmtime_error_message(error, &message); | ||
wasmtime_error_delete(error); | ||
fprintf(stderr, "%s\n", message.data); | ||
wasm_byte_vec_delete(&message); | ||
return EXIT_FAILURE; | ||
} | ||
printf("wasm text:\n%s\n", wat); | ||
puts("assembly:"); | ||
for(size_t i = 0; i < ret.size; ++i) { | ||
printf(" 0x%02x", ret.data[i]); | ||
if (i%8 == 7) { | ||
puts(""); | ||
} | ||
} | ||
puts(""); | ||
wasm_byte_vec_delete(&ret); | ||
return EXIT_SUCCESS; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it is dirty hack ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a way to alias the packages of gcc and clang.
I couldn't remove
self.info.settings.compiler
.I argue it's a clean hack 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say to use compatible compilers instead: https://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html#compatible-compilers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it this way to avoid creating duplicate packages.
Packages with compiler=gcc and compiler=clang will be identical, because nothing is built.
If I understand compatible compiler correctly, then a package for gcc and clang will be created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually used a custom package id: see https://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html#defining-a-custom-package-id
So not a hack after all. It's documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compatible packages would require me to list all gcc/clang versions that are compatible which does not exist, or will be always incomplete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compatible compilers works, but it will cause c3i to generate a package for gcc and clang, which are the same.
So I'd prefer to keep the
package_id
method as it is now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it will generate for both clang and gcc. Indeed using same pkg id will save cci resources.