Skip to content
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

Build fails on Ubuntu 18.04 #93

Closed
s2x opened this issue Nov 18, 2019 · 6 comments · Fixed by #98
Closed

Build fails on Ubuntu 18.04 #93

s2x opened this issue Nov 18, 2019 · 6 comments · Fixed by #98
Assignees
Labels
🐞 bug Something isn't working 📦 component-extension About the PHP extension written in C/C++ 📦 component-runtime About the Wasm runtime

Comments

@s2x
Copy link

s2x commented Nov 18, 2019

When compiling last commit (6147c98) under Ubuntu 18.04 i got this error:

In file included from /home/piotr/build/php-ext-wasm/src/wasm.cc:19:0:
/home/piotr/build/php-ext-wasm/src/wasm.hh:229:5: error: ‘wasmer_trampoline_buffer_t’ does not name a type; did you mean ‘wasmer_import_func_t’?
     wasmer_trampoline_buffer_t *trampoline_buffer;
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
     wasmer_import_func_t
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zim_WasmArrayBuffer___construct(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:108:113: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
         zend_throw_exception_ex(zend_ce_exception, 0, "Buffer length must be positive; given %lld.", byte_length);
                                                                                                                 ^
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zim_WasmArrayBuffer_grow(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:174:119: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
         zend_throw_exception_ex(zend_ce_exception, 0, "Number of pages must be positive; given %lld.", number_of_pages);
                                                                                                                       ^
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘bool initialize_wasm_imports(HashTable*, std::__cxx11::list<wasm_imported_function*>**, wasmer_import_t**, uint32_t*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:966:33: error: ‘struct wasm_imported_function’ has no member named ‘trampoline_buffer’
             trampoline_context->trampoline_buffer = NULL;
                                 ^~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:969:13: error: ‘wasmer_trampoline_buffer_builder_t’ was not declared in this scope
             wasmer_trampoline_buffer_builder_t *trampoline_builder = wasmer_trampoline_buffer_builder_new();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:969:13: note: suggested alternative: ‘wasmer_import_object_iter_t’
             wasmer_trampoline_buffer_builder_t *trampoline_builder = wasmer_trampoline_buffer_builder_new();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             wasmer_import_object_iter_t
/home/piotr/build/php-ext-wasm/src/wasm.cc:969:49: error: ‘trampoline_builder’ was not declared in this scope
             wasmer_trampoline_buffer_builder_t *trampoline_builder = wasmer_trampoline_buffer_builder_new();
                                                 ^~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:969:49: note: suggested alternative: ‘trampoline_context’
             wasmer_trampoline_buffer_builder_t *trampoline_builder = wasmer_trampoline_buffer_builder_new();
                                                 ^~~~~~~~~~~~~~~~~~
                                                 trampoline_context
/home/piotr/build/php-ext-wasm/src/wasm.cc:969:70: error: ‘wasmer_trampoline_buffer_builder_new’ was not declared in this scope
             wasmer_trampoline_buffer_builder_t *trampoline_builder = wasmer_trampoline_buffer_builder_new();
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:972:18: error: ‘wasmer_trampoline_callable_t’ was not declared in this scope
                 (wasmer_trampoline_callable_t *) imported_function_trampoline,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:972:18: note: suggested alternative: ‘trampoline_context’
                 (wasmer_trampoline_callable_t *) imported_function_trampoline,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  trampoline_context
/home/piotr/build/php-ext-wasm/src/wasm.cc:972:48: error: expected primary-expression before ‘)’ token
                 (wasmer_trampoline_callable_t *) imported_function_trampoline,
                                                ^
/home/piotr/build/php-ext-wasm/src/wasm.cc:970:46: error: ‘wasmer_trampoline_buffer_builder_add_callinfo_trampoline’ was not declared in this scope
             unsigned long trampoline_index = wasmer_trampoline_buffer_builder_add_callinfo_trampoline(
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:978:13: error: ‘wasmer_trampoline_buffer_t’ was not declared in this scope
             wasmer_trampoline_buffer_t *trampoline = wasmer_trampoline_buffer_builder_build(trampoline_builder);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:978:13: note: suggested alternative: ‘wasmer_import_func_t’
             wasmer_trampoline_buffer_t *trampoline = wasmer_trampoline_buffer_builder_build(trampoline_builder);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
             wasmer_import_func_t
/home/piotr/build/php-ext-wasm/src/wasm.cc:978:41: error: ‘trampoline’ was not declared in this scope
             wasmer_trampoline_buffer_t *trampoline = wasmer_trampoline_buffer_builder_build(trampoline_builder);
                                         ^~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:978:41: note: suggested alternative: ‘tmpfile’
             wasmer_trampoline_buffer_t *trampoline = wasmer_trampoline_buffer_builder_build(trampoline_builder);
                                         ^~~~~~~~~~
                                         tmpfile
/home/piotr/build/php-ext-wasm/src/wasm.cc:978:54: error: ‘wasmer_trampoline_buffer_builder_build’ was not declared in this scope
             wasmer_trampoline_buffer_t *trampoline = wasmer_trampoline_buffer_builder_build(trampoline_builder);
                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:979:33: error: ‘struct wasm_imported_function’ has no member named ‘trampoline_buffer’
             trampoline_context->trampoline_buffer = trampoline;
                                 ^~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:982:19: error: ‘wasmer_trampoline_callable_t’ does not name a type; did you mean ‘trampoline_context’?
             const wasmer_trampoline_callable_t *trampoline_callable = wasmer_trampoline_buffer_get_trampoline(trampoline, trampoline_index);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   trampoline_context
/home/piotr/build/php-ext-wasm/src/wasm.cc:986:36: error: ‘trampoline_callable’ was not declared in this scope
                 (void (*)(void *)) trampoline_callable,
                                    ^~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:986:36: note: suggested alternative: ‘trampoline_context’
                 (void (*)(void *)) trampoline_callable,
                                    ^~~~~~~~~~~~~~~~~~~
                                    trampoline_context
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void wasm_instance_destructor(zend_resource*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:1166:65: error: ‘struct wasm_imported_function’ has no member named ‘trampoline_buffer’
             wasmer_trampoline_buffer_destroy(imported_function->trampoline_buffer);
                                                                 ^~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:1166:13: error: ‘wasmer_trampoline_buffer_destroy’ was not declared in this scope
             wasmer_trampoline_buffer_destroy(imported_function->trampoline_buffer);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/piotr/build/php-ext-wasm/src/wasm.cc:1166:13: note: suggested alternative: ‘wasmer_import_func_destroy’
             wasmer_trampoline_buffer_destroy(imported_function->trampoline_buffer);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             wasmer_import_func_destroy
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zif_WasmTypedArray___construct(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:2029:105: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
         zend_throw_exception_ex(zend_ce_exception, 0, "Offset must be non-negative; given %lld.", offset);
                                                                                                         ^
/home/piotr/build/php-ext-wasm/src/wasm.cc:2041:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
         );
         ^
/home/piotr/build/php-ext-wasm/src/wasm.cc:2047:105: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
         zend_throw_exception_ex(zend_ce_exception, 2, "Length must be non-negative; given %lld.", length);
                                                                                                         ^
/home/piotr/build/php-ext-wasm/src/wasm.cc:2099:13: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘zend_long {aka long int}’ [-Wformat=]
             );
             ^
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zif_WasmTypedArray_offset_get(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:2202:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘zend_long {aka long int}’ [-Wformat=]
         );
         ^
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zif_WasmTypedArray_offset_set(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:2285:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘zend_long {aka long int}’ [-Wformat=]
         );
         ^
/home/piotr/build/php-ext-wasm/src/wasm.cc: In function ‘void zif_WasmTypedArray_offset_unset(zend_execute_data*, zval*)’:
/home/piotr/build/php-ext-wasm/src/wasm.cc:2406:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘zend_long {aka long int}’ [-Wformat=]
         );
         ^
Makefile:194: recipe for target 'wasm.lo' failed
make: *** [wasm.lo] Error 1
error: Recipe `build` failed with exit code 2

Previous commit builds ok (0154a56)

@s2x s2x added the 🐞 bug Something isn't working label Nov 18, 2019
@Hywan
Copy link
Contributor

Hywan commented Nov 18, 2019

Hello,

Thanks for the bug report and the bisect on valid commits.
Do you compile with GCC or clang? What's your architecture (x86, …)?

Thanks!

@Hywan Hywan added 📦 component-extension About the PHP extension written in C/C++ 📦 component-runtime About the Wasm runtime labels Nov 18, 2019
@Hywan Hywan self-assigned this Nov 18, 2019
@s2x
Copy link
Author

s2x commented Nov 18, 2019

There is some problem with src/wasmer.hh:

#if !defined(WASMER_H_MACROS)
  #define WASMER_H_MACROS
  #if defined(MSVC)
    #if defined(_M_AMD64)
      #define ARCH_X86_64
    #endif
  #endif

#if defined(GCC) || defined(__clang__)
    #if defined(__x86_64__)
      #define ARCH_X86_64
    #endif
  #endif
#endif

when i add this line #define ARCH_X86_64 it compiles.

g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) 

@s2x
Copy link
Author

s2x commented Nov 18, 2019

Replacing
#if defined(GCC) || defined(__clang__)

with
#if defined(__GNUC__) || defined(__clang__)

works for me.

@Hywan
Copy link
Contributor

Hywan commented Nov 18, 2019

Does it work also with:

#if defined(GCC) || defined(__GNUC__) || defined(__clang__)

It should, but we never know…

@s2x
Copy link
Author

s2x commented Nov 19, 2019

Yes it works

bors bot added a commit to wasmerio/wasmer that referenced this issue Nov 20, 2019
987: Fix runtime c api header preprocessor gcc r=syrusakbary a=Hywan

`ARCH_X86_64` is correctly defined for GCC or clang, but gnuc was
missing. This patch fixes that.

Address wasmerio/wasmer-php#93
Fix #984

Co-authored-by: Ivan Enderlin <[email protected]>
@Hywan Hywan closed this as completed in #98 Dec 4, 2019
@Hywan
Copy link
Contributor

Hywan commented Dec 4, 2019

master contains the fix for your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 component-extension About the PHP extension written in C/C++ 📦 component-runtime About the Wasm runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants