wasmerio / wasmer-php

πŸ˜πŸ•ΈοΈ WebAssembly runtime for PHP
https://wasmerio.github.io/wasmer-php/wasm/
MIT License
1.01k stars 42 forks source link

CentOS 7 compilation error. #23

Closed spasius closed 5 years ago

spasius commented 5 years ago

It`s unable to compile in centos.

config.status: executing libtool commands
/bin/sh /var/web/rust/php-ext-wasm/extension/libtool --mode=compile   -I. -I/var/web/rust/php-ext-wasm/extension -DPHP_ATOM_INC -I/var/web/rust/php-ext-wasm/extension/include -I/var/web/rust/php-ext-wasm/extension/main -I/var/web/rust/php-ext-wasm/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H     -c /var/web/rust/php-ext-wasm/extension/wasm.cc -o wasm.lo
libtool: compile: unrecognized option `-I.'
libtool: compile: Try `libtool --help' for more information.
make: *** [wasm.lo] Error 1
Hywan commented 5 years ago

Hello,

Thanks for the bug report. It's not even possible to compile the Rust part today, since I'm waiting on several patches to be released.

Let's pause this issue for a week, and resume it after the next release of wasmer-runtime-c-api. Is it OK?

spasius commented 5 years ago

Sure. Thanks. Will wait.

Hywan commented 5 years ago

It should be better today. Can you retry please? Run just rust && just php.

spasius commented 5 years ago

Error on running cargo build. Looks like a file wasmer.hh not found. error: failed to run custom build command for php-ext-wasm v0.2.0 (/var/web/rust/php-ext-wasm) process didn't exit successfully: /var/web/rust/php-ext-wasm/target/debug/build/php-ext-wasm-32597ea6b96fd08d/build-script-build (exit code: 101) --- stderr thread 'main' panicked at 'The wasmer.hh file is not found.', build.rs:52:9 note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...

irxground commented 5 years ago

Ignoring build.rs for the first time will work fine.

mv build.rs build.rs.bck
just rust
mv build.rs.bck build.rs
just rust
Hywan commented 5 years ago

Yeah, it's sometimes broken. I need to fix that. If this crate is build before wasmer-runtime-c-api, then build.rs is broken.

spasius commented 5 years ago

After using temporary moving build.rs rust compile fine. Ok. Running just php back the first error config.status: executing libtool commands /bin/sh /var/web/rust/php-ext-wasm/extension/libtool --mode=compile -I. -I/var/web/rust/php-ext-wasm/extension -DPHP_ATOM_INC -I/var/web/rust/php-ext-wasm/extension/include -I/var/web/rust/php-ext-wasm/extension/main -I/var/web/rust/php-ext-wasm/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -c /var/web/rust/php-ext-wasm/extension/wasm.cc -o wasm.lo libtool: compile: unrecognized option-I.' libtool: compile: Try libtool --help' for more information. make: *** [wasm.lo] Error 1 In makefile the option CXX is empty.

Hywan commented 5 years ago

It means you don't have the option -I on libtool. I'm just using the build system from PHP. What libtool --help gives you?

spasius commented 5 years ago

libtool --help return usage information.

Usage: libtool [OPTION]... [MODE-ARG]...

Provide generalized library-building support services.

      --config             show all configuration variables
      --debug              enable verbose shell tracing
  -n, --dry-run            display commands without modifying any files
      --features           display basic configuration information and exit
      --mode=MODE          use operation mode MODE
      --preserve-dup-deps  don't remove duplicate dependency libraries
      --quiet, --silent    don't print informational messages
      --no-quiet, --no-silent
                           print informational messages (default)
      --no-warn            don't display warning messages
      --tag=TAG            use configuration variables from tag TAG
  -v, --verbose            print more informational messages than default
      --no-verbose         don't print the extra informational messages
      --version            print version information
  -h, --help, --help-all   print short, long, or detailed help message

MODE must be one of the following:

        clean              remove files from the build directory
        compile            compile a source file into a libtool object
        execute            automatically set library path, then run a program
        finish             complete the installation of libtool libraries
        install            install libraries or executables
        link               create a library or an executable
        uninstall          remove libraries from an installed directory

MODE-ARGS vary depending on the MODE.  When passed as first option,
`--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
Try `libtool --help --mode=MODE' for a more detailed description of MODE.

When reporting a bug, please describe a test case to reproduce it and
include the following information:

        host-triplet:   x86_64-redhat-linux-gnu
        shell:          /bin/sh
        compiler:               gcc
        compiler flags:         -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -fPIC
        linker:         /usr/bin/ld -m elf_x86_64 (gnu? yes)
        libtool:        (GNU libtool) 2.4.2
        automake:       automake (GNU automake) 1.13.4
        autoconf:       autoconf (GNU Autoconf) 2.69

Report bugs to <bug-libtool@gnu.org>.
GNU libtool home page: <http://www.gnu.org/software/libtool/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
spasius commented 5 years ago

Can anyone show system for compile extension? compiler version, flags, etc.

irxground commented 5 years ago

I use a Mac, and I hit the same error.

The error message displayed on the terminal is below.

/bin/sh /Users/user/work/reading/php-ext-wasm/extension/libtool --mode=compile   -I. -I/Users/user/work/reading/php-ext-wasm/extension -DPHP_ATOM_INC -I/Users/user/work/reading/php-ext-wasm/extension/include -I/Users/user/work/reading/php-ext-wasm/extension/main -I/Users/user/work/reading/php-ext-wasm/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H     -c /Users/user/work/reading/php-ext-wasm/extension/wasm.cc -o wasm.lo

My guess is that configure cannot find a C ++ compiler. Here is a part of the generated extension/Makefile for reference.

...
CC = cc
CFLAGS = -g -O2
CFLAGS_CLEAN = $(CFLAGS)
CPP = cc -E
CPPFLAGS = -DHAVE_CONFIG_H
CXX =
CXXFLAGS =
...
.PHONY: all clean install distclean test prof-gen prof-clean prof-use
.NOEXPORT:
wasm.lo: /Users/user/work/reading/php-ext-wasm/extension/wasm.cc
    $(LIBTOOL) --mode=compile $(CXX)  -I. -I/Users/user/work/reading/php-ext-wasm/extension $(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)  -c /Users/user/work/reading/php-ext-wasm/extension/wasm.cc -o wasm.lo
...
sperelson commented 5 years ago

I got the same error when running just php on macOS. I managed to get past that and into a world of pain by running CXX='gcc -std=c++11 -stdlib=libc++' just php. A few of the errors included: 'finite' is deprecated and too few arguments provided to function-like macro invocation. I did try a few different compilers for good measure.

I don't want to guess as to what is wrong, because I really wouldn't know where to start, but, for the fun of it:

  1. I need a specific version of PHP (currently 7.1.23)
  2. I have bad PHP headers
  3. I need to get an older gcc version
  4. I should just compile it on Linux and forget running this on a Mac 😒
Hywan commented 5 years ago

The warning about 'finite' is deprecated comes from PHP itself, not this code. I may open a PR to fix that though.

I developed the extension on macOS. I installed PHP with brew. How did you install PHP?

Hywan commented 5 years ago

The error with libtool is fixed in #47. I'm facing other compilation errors on Linux. Working on it.

Hywan commented 5 years ago

@spasius Does it work with:

$ export CXX='gcc'
$ just php

or even:

$ export CXX='clang++'
$ just php
spasius commented 5 years ago

@Hywan Thanks for work. With gcc:

 error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
In file included from /var/web/rust/php-ext-wasm/extension/wasm.hh:28:0,
                 from /var/web/rust/php-ext-wasm/extension/wasm.cc:19:
/var/web/rust/php-ext-wasm/extension/wasmer.hh:8:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
 enum class wasmer_import_export_kind : uint32_t {
 ^
/var/web/rust/php-ext-wasm/extension/wasmer.hh:8:40: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
 enum class wasmer_import_export_kind : uint32_t {
                                        ^
/var/web/rust/php-ext-wasm/extension/wasmer.hh:15:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
 enum class wasmer_result_t {
 ^
/var/web/rust/php-ext-wasm/extension/wasmer.hh:20:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
 enum class wasmer_value_tag : uint32_t {
 ^
/var/web/rust/php-ext-wasm/extension/wasmer.hh:20:31: warning: scoped enums only available with -std=c++11 or -std=gnu++11 [enabled by default]
 enum class wasmer_value_tag : uint32_t {
                               ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'wasmer_value_tag from_zend_long_to_wasmer_value_tag(zend_long)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:154:16: error: 'wasmer_value_tag' is not a class or namespace
         return wasmer_value_tag::WASM_I32;
                ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_compile(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:425:40: error: 'wasmer_result_t' is not a class or namespace
         if (wasm_compilation_result != wasmer_result_t::WASMER_OK) {
                                        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_module_serialize(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:547:74: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_module_serialize(&wasm_serialized_module, wasm_module) != wasmer_result_t::WASMER_OK) {
                                                                          ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_module_deserialize(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:592:158: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_serialized_module_from_bytes(&wasm_serialized_module, (const uint8_t *) wasm_serialized_module_bytes, wasm_serialized_module_bytes_length) != wasmer_result_t::WASMER_OK) {
                                                                                                                                                              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:598:76: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_module_deserialize(&wasm_module, wasm_serialized_module) != wasmer_result_t::WASMER_OK) {
                                                                            ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_module_new_instance(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:682:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
         &wasm_instance,
                       ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:690:38: error: 'wasmer_result_t' is not a class or namespace
     if (wasm_instantiation_result != wasmer_result_t::WASMER_OK) {
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_new_instance(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:746:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
         wasm_byte_array->bytes_len,
                                   ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:754:38: error: 'wasmer_result_t' is not a class or namespace
     if (wasm_instantiation_result != wasmer_result_t::WASMER_OK) {
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_get_function_signature(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:827:33: error: 'wasmer_import_export_kin ' is not a class or namespace
         if (wasm_export_kind != wasmer_import_export_kind::WASM_FUNCTION) {
                                 ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:856:88: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_export_func_params_arity(wasm_function, &wasm_function_inputs_arity) != wasmer_result_t::WASMER_OK) {
                                                                                        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:866:113: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_export_func_params(wasm_function, wasm_function_input_signatures, wasm_function_inputs_arity) != wasmer_result_t::WASMER_OK) {
                                                                                                                 ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:882:90: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_export_func_returns_arity(wasm_function, &wasm_function_outputs_arity) != wasmer_result_t::WASMER_OK) {
                                                                                          ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:894:116: error: 'wasmer_result_t' is not a class or namespace
     if (wasmer_export_func_returns(wasm_function, wasm_function_output_signatures, wasm_function_outputs_arity) != wasmer_result_t::WASMER_OK) {
                                                                                                                    ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_value(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:973:17: error: 'wasmer_value_tag' is not a class or namespace
     if (type == wasmer_value_tag::WASM_I32) {
                 ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:976:24: error: 'wasmer_value_tag' is not a class or namespace
     } else if (type == wasmer_value_tag::WASM_I64) {
                        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:979:24: error: 'wasmer_value_tag' is not a class or namespace
     } else if (type == wasmer_value_tag::WASM_F32) {
                        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:982:24: error: 'wasmer_value_tag' is not a class or namespace
     } else if (type == wasmer_value_tag::WASM_F64) {
                        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_invoke_function(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1086:33: error: 'wasmer_result_t' is not a class or namespace
     if (function_call_result != wasmer_result_t::WASMER_OK) {
                                 ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1095:32: error: 'wasmer_value_tag' is not a class or namespace
     if (function_output.tag == wasmer_value_tag::WASM_I32) {
                                ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1097:39: error: 'wasmer_value_tag' is not a class or namespace
     } else if (function_output.tag == wasmer_value_tag::WASM_I64) {
                                       ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1099:39: error: 'wasmer_value_tag' is not a class or namespace
     } else if (function_output.tag == wasmer_value_tag::WASM_F32) {
                                       ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1101:39: error: 'wasmer_value_tag' is not a class or namespace
     } else if (function_output.tag == wasmer_value_tag::WASM_F64) {
                                       ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_wasm_get_memory_buffer(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1165:33: error: 'wasmer_import_export_kind' is not a class or namespace
         if (wasm_export_kind != wasmer_import_export_kind::WASM_MEMORY) {
                                 ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1170:67: error: 'wasmer_result_t' is not a class or namespace
         if (wasmer_export_to_memory(wasm_export, &wasm_memory) == wasmer_result_t::WASMER_OK) {
                                                                   ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'zend_object* create_wasm_typed_array_object(zend_class_entry*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1283:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::INT8;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1285:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::UINT8;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1287:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::INT16;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1289:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::UINT16;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1291:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::INT32;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1293:38: error: 'wasm_typed_array_kind' is not a class or namespace
             wasm_typed_array->kind = wasm_typed_array_kind::UINT32;
                                      ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_WasmTypedArray___construct(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1401:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::INT8:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1402:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::UINT8:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1407:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::INT16:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1408:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::UINT16:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1413:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::INT32:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1414:18: error: 'wasm_typed_array_kind' is not a class or namespace
             case wasm_typed_array_kind::UINT32:
                  ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_WasmTypedArray_offset_get(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1545:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1550:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1555:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1560:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1565:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT32:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1570:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT32:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_WasmTypedArray_offset_set(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1630:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1635:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1640:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1645:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1650:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT32:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1655:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT32:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'void zif_WasmTypedArray_offset_unset(zend_execute_data*, zval*)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1749:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1754:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT8:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1759:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1764:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT16:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1769:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::INT32:
              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1774:14: error: 'wasm_typed_array_kind' is not a class or namespace
         case wasm_typed_array_kind::UINT32:
              ^
In file included from /usr/include/php/main/php.h:468:0,
                 from /var/web/rust/php-ext-wasm/extension/wasm.hh:23,
                 from /var/web/rust/php-ext-wasm/extension/wasm.cc:19:
/var/web/rust/php-ext-wasm/extension/wasm.cc: In function 'int zm_startup_wasm(int, int)':
/var/web/rust/php-ext-wasm/extension/wasm.cc:1802:57: error: 'wasmer_value_tag' is not a class or namespace
     REGISTER_LONG_CONSTANT("WASM_TYPE_I32", (zend_long) wasmer_value_tag::WASM_I32, CONST_CS | CONST_PERSISTENT);
                                                         ^
/usr/include/php/Zend/zend_constants.h:53:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
                                                                                                         ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1803:57: error: 'wasmer_value_tag' is not a class or namespace
     REGISTER_LONG_CONSTANT("WASM_TYPE_I64", (zend_long) wasmer_value_tag::WASM_I64, CONST_CS | CONST_PERSISTENT);
                                                         ^
/usr/include/php/Zend/zend_constants.h:53:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
                                                                                                         ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1804:57: error: 'wasmer_value_tag' is not a class or namespace
     REGISTER_LONG_CONSTANT("WASM_TYPE_F32", (zend_long) wasmer_value_tag::WASM_F32, CONST_CS | CONST_PERSISTENT);
                                                         ^
/usr/include/php/Zend/zend_constants.h:53:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
                                                                                                         ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:1805:57: error: 'wasmer_value_tag' is not a class or namespace
     REGISTER_LONG_CONSTANT("WASM_TYPE_F64", (zend_long) wasmer_value_tag::WASM_F64, CONST_CS | CONST_PERSISTENT);
                                                         ^
/usr/include/php/Zend/zend_constants.h:53:105: note: in definition of macro 'REGISTER_LONG_CONSTANT'
 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
spasius commented 5 years ago

The second with clang++:

compile:  clang++ -I. -I/var/web/rust/php-ext-wasm/extension -DPHP_ATOM_INC -I/var/web/rust/php-ext-wasm/extension/include -I/var/web/rust/php-ext-wasm/extension/main -I/var/web/rust/php-ext-wasm/extension -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -c /var/web/rust/php-ext-wasm/extension/wasm.cc  -fPIC -DPIC -o .libs/wasm.o
In file included from /var/web/rust/php-ext-wasm/extension/wasm.cc:19:
In file included from ./wasm.hh:23:
In file included from /usr/include/php/main/php.h:33:
In file included from /usr/include/php/Zend/zend.h:335:
/usr/include/php/Zend/zend_operators.h:486:10: error: expected '(' after 'asm'
        __asm__ goto(
                ^
/usr/include/php/Zend/zend_operators.h:536:10: error: expected '(' after 'asm'
        __asm__ goto(
                ^
/usr/include/php/Zend/zend_operators.h:593:10: error: expected '(' after 'asm'
        __asm__ goto(
                ^
/usr/include/php/Zend/zend_operators.h:683:10: error: expected '(' after 'asm'
        __asm__ goto(
                ^
In file included from /var/web/rust/php-ext-wasm/extension/wasm.cc:19:
In file included from ./wasm.hh:28:
In file included from ./wasmer.hh:5:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdint:35:
/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/c++0x_warning.h:32:2: error:
      This file requires compiler and library support for the ISO C++ 2011 standard.
      This support is currently experimental, and must be enabled with the -std=c++11
      or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
 ^
In file included from /var/web/rust/php-ext-wasm/extension/wasm.cc:19:
In file included from ./wasm.hh:28:
./wasmer.hh:8:6: warning: scoped enumerations are a C++11 extension
      [-Wc++11-extensions]
enum class wasmer_import_export_kind : uint32_t {
     ^
./wasmer.hh:8:12: error: ISO C++ forbids forward references to 'enum' types
enum class wasmer_import_export_kind : uint32_t {
           ^
./wasmer.hh:8:38: error: expected unqualified-id
enum class wasmer_import_export_kind : uint32_t {
                                     ^
./wasmer.hh:15:6: warning: scoped enumerations are a C++11 extension
      [-Wc++11-extensions]
enum class wasmer_result_t {
     ^
./wasmer.hh:20:6: warning: scoped enumerations are a C++11 extension
      [-Wc++11-extensions]
enum class wasmer_value_tag : uint32_t {
     ^
./wasmer.hh:20:12: error: ISO C++ forbids forward references to 'enum' types
enum class wasmer_value_tag : uint32_t {
           ^
./wasmer.hh:20:29: error: expected unqualified-id
enum class wasmer_value_tag : uint32_t {
                            ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:100:102: warning: format specifies type
      'long long' but the argument has type 'zend_long' (aka 'long') [-Wformat]
  ...0, "Buffer length must be positive; given %lld.", byte_length);
                                               ~~~~    ^~~~~~~~~~~
                                               %ld
/var/web/rust/php-ext-wasm/extension/wasm.cc:154:16: error: expected a class or
      namespace
        return wasmer_value_tag::WASM_I32;
               ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:425:40: error: expected a class or
      namespace
        if (wasm_compilation_result != wasmer_result_t::WASMER_OK) {
                                       ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:547:74: error: expected a class or
      namespace
    if (wasmer_module_serialize(&wasm_serialized_module, wasm_module) != wasme...
                                                                         ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:592:158: error: expected a class or
      namespace
  ...*) wasm_serialized_module_bytes, wasm_serialized_module_bytes_length) != wasme...
                                                                              ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:598:76: error: expected a class or
      namespace
    if (wasmer_module_deserialize(&wasm_module, wasm_serialized_module) != wasmer_...
                                                                           ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:684:9: error: expected expression
        {},
        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:690:38: error: expected a class or
      namespace
    if (wasm_instantiation_result != wasmer_result_t::WASMER_OK) {
                                     ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:748:9: error: expected expression
        {},
        ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:754:38: error: expected a class or
      namespace
    if (wasm_instantiation_result != wasmer_result_t::WASMER_OK) {
                                     ^
/var/web/rust/php-ext-wasm/extension/wasm.cc:827:33: error: expected a class or
      namespace
        if (wasm_export_kind != wasmer_import_export_kind::WASM_FUNCTION) {
                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
make: *** [wasm.lo] Error 1
error: Recipe `php` failed with exit code 2
spasius commented 5 years ago

My solution:

$ export CXX='g++'
$ export CXXFLAGS='-std=c++11'
$ just php

It`s work. Thanks.

Hywan commented 5 years ago

Interesting. With clang++, you have the same bug than I've on Linux, but not on macOS. That's surprising. Let me run a PR.

sperelson commented 5 years ago

I developed the extension on macOS. I installed PHP with brew. How did you install PHP?

Brew'd PHP as well. But that shouldn't mean much. I suspect my setup is different or broken. I am thinking of uninstalling and reinstalling when doing so won't stop my day job.

Thank you @Hywan. I'm looking forward to trying this extension out

Hywan commented 5 years ago

@sperelson Feel free to come back, we will find a way :-).

mattsches commented 5 years ago

Just chiming in to let you know - I'm on Ubuntu 18.10, and just php also fails here (with both gcc and clang++).

libtool: error: unrecognised option: '-I.'

With CXX='clang++' and similar error with CXX='gcc' CXXFLAGS='-std=c++11':


/path/to/php-ext-wasm/extension/wasm.cc:132:5: error: use of undeclared identifier 'ZEND_PARSE_PARAMETERS_NONE'
    ZEND_PARSE_PARAMETERS_NONE();
    ^
``
Hywan commented 5 years ago

Hope the new master is correct for all Linux distros.

mattsches commented 5 years ago

Updated to 5c4d7ca280224c2d6bb4092608d3ef8afb039b9b but still getting the same errors. libtool does not support the option -I and/or

'ZEND_PARSE_PARAMETERS_NONE' was not declared in this scope
     ZEND_PARSE_PARAMETERS_NONE();
[…]

Maybe I'm getting it all wrong somehow …?

Hywan commented 5 years ago

What if you run those lines by hand: https://github.com/wasmerio/php-ext-wasm/blob/0418cac5e0b25c4de94a5d8991c14e0680e1a61d/.circleci/config.yml#L48-L64. Do you know where it fails, and why?