Giter Site home page Giter Site logo

phper's Introduction

PHPER (PHP Enjoy Rust)

CI Crates Docs Lines License

Rust ❤️ PHP

The framework that allows us to write PHP extensions using pure and safe Rust whenever possible.

Documentation & Tutorial

Requirement

Necessary

  • rust 1.65 or later
  • libclang 9.0 or later
  • php 7.0 or later

Tested Support

  • OS
    • linux
    • macos
    • windows
  • PHP
    • version
      • 7.0
      • 7.1
      • 7.2
      • 7.3
      • 7.4
      • 8.0
      • 8.1
      • 8.2
      • 8.3
    • mode
      • nts
      • zts
    • sapi
      • cli
      • fpm
    • debug
      • disable
      • enable

Examples

See examples.

The projects using PHPER

  • apache/skywalking-php - The PHP Agent for Apache SkyWalking, which provides the native tracing abilities for PHP project.

License

MulanPSL-2.0.

phper's People

Contributors

chenhuaiyuan avatar erasin avatar gdamjan avatar jmjoy avatar juhojama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phper's Issues

It seems that private methods cannot be called in class methods

It seems that private methods cannot be called in class methods

 class
        .add_method("set_code", Visibility::Public, |this, arguments| {
            let code = arguments[0].expect_long().unwrap();
            let items = this.get_mut_property("items").expect_mut_z_obj()?;
            let mut items_mut = items.to_ref_owned();
            items_mut.set_property("code", code);
            this.set_property("items", items_mut);
            let ret = this.call(
                "set_data",
                &mut [ZVal::from("127.0.0.1")],
            );
            Ok::<_, phper::Error>(ret.ok())
        })
        .argument(Argument::by_val("code"));


   class
        .add_method("set_data", Visibility::Private, |this, arguments| {
            let items = this.get_mut_property("items").expect_mut_z_obj()?;
            let mut items_mut = items.to_ref_owned();
            items_mut.set_property("data", ZVal::from(arguments[0].clone()));
            this.set_property("items", items_mut);
            Ok::<_, phper::Error>(this.to_ref_owned())
        })
        .argument(Argument::by_val("data"));

php code:
var_export($a031_result->set_code(501), true)

result:
NULL

How should I return here to continue calling

$a031_result = new A031Result();
$a031_result->set_code(400)->get();

or
A031Result::set_code(400)->get();


--------------------------------------------------
pub fn make_result_class() -> ClassEntity<()> {
    let mut class = ClassEntity::new_with_state_constructor(A031_RESULT_CLASS_NAME, || ());
    class.bind(&A031_RESULT_CLASS);
    class.add_static_property("items", Visibility::Public, ());


class
        .add_static_method("set_code", Visibility::Public, |params| {
            let this_class =
                ClassEntry::from_globals(A031_RESULT_CLASS_NAME).expect("无法实例化类");
            let items_class = this_class
                .get_static_property("items")
                .map(ToOwned::to_owned)
                .unwrap_or_default();
            let mut binding = items_class.to_owned();
            let items_class_obj = binding.as_mut_z_obj().unwrap();
            items_class_obj.set_property("code", params[0].to_owned());
            this_class.set_static_property("items", items_class_obj.to_ref_owned());

//How should I return here to continue calling
            Ok::<_, phper::Error>(this_class.to_ref_owned())
        })
        .argument(Argument::by_val("code"));


    class.add_static_method("get", Visibility::Public, |_| {
        let this_class = ClassEntry::from_globals(A031_RESULT_CLASS_NAME).expect("无法实例化类");
        let items_class = this_class
            .get_static_property("items")
            .map(ToOwned::to_owned)
            .unwrap_or_else(|| panic!("取出items失败"));
        Ok::<_, phper::Error>(items_class)
    });
    class

//How should I return here to continue calling
Ok::<_, phper::Error>(this_class.to_ref_owned())

If returning self in non static state in static state
for example:

class
        .add_method("set_message", Visibility::Public, |this, arguments| {
            let message = arguments[0].expect_z_str()?.to_str()?;
            let items = this.get_mut_property("items").expect_mut_z_obj()?;
            let mut items_mut = items.to_ref_owned();
            items_mut.set_property("message", ZVal::from(message));
            this.set_property("items", items_mut);
            Ok::<_, phper::Error>(this.to_ref_owned())
        })
        .argument(Argument::by_val("message"));

union types

I think it would be great to add support for union types.

I have the following PHP function:

<?php

declare(strict_types=1);

namespace Psl\Math;

/**
 * @template T of int|float
 *
 * @param T $number
 *
 * @return T
 */
function abs(int|float $number): int|float {
    return $number < 0 ? -$number : $number;
}

and currently it's not possible to implement using phper, my suggestion is to add a Union enum, so that the following is possible:

pub fn abs(arguments: &mut [ZVal]) -> phper::Result<Union<f64, i64>> {
    if arguments[0].get_type_info().is_double() {
        Ok(Union::Left(arguments[0].expect_double()?.abs()))
    } else {
        Ok(Union::Right(arguments[0].expect_long()?.abs()))
    }
}

ref: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=053e92a7efb0bc82998ddd571b38a2df

How to write

Foo::setValue("nihao")->print();

Can we implement the form of types? It is very useful when writing databases or modules

Multiple missing `_Float64x` type errors in phper-sys

I just tried compiling the hello example against PHP 8 and PHP 7.4 and got this 54 times when compiling php-sys. I noticed in the build.rs of php-sys _Float64x is declared as a blocked item but when not blocked, it translates to a u128 which isn't FFI safe.

error[E0412]: cannot find type `_Float64x` in this scope
    --> /home/ps/dev/phper/target/debug/build/phper-sys-89df922599ad3f64/out/php_bindings.rs:9716:60
     |
3039 | pub type _Float64 = f64;
     | ------------------------ similarly named type alias `_Float64` defined here
...
9716 |     pub fn f64fmaf64x(__x: _Float64x, __y: _Float64x, __z: _Float64x) -> _Float64;
     |                                                            ^^^^^^^^^ help: a type alias with a similar name exists: `_Float64`

I've tried this with phper 0.6.0 and 0.5.1.

symbol flags.

The StatefulClass struct doesn't seem to allow defining interfaces, traits, or abstract classes ( can't set class flags ).

there also doesn't seem to be a way to set const flags, function/method flags .. etc.

PHP symbol flags ( list )

from: https://github.com/php/php-src/blob/e57d0568d8f21ab7c089a8277a14f1aeee9e9658/Zend/zend_compile.h#L196-L367

/* Class, property and method flags                  class|meth.|prop.|const*/
/*                                                        |     |     |     */
/* Common flags                                           |     |     |     */
/* ============                                           |     |     |     */
/*                                                        |     |     |     */
/* Visibility flags (public < protected < private)        |     |     |     */
#define ZEND_ACC_PUBLIC                  (1 <<  0) /*     |  X  |  X  |  X  */
#define ZEND_ACC_PROTECTED               (1 <<  1) /*     |  X  |  X  |  X  */
#define ZEND_ACC_PRIVATE                 (1 <<  2) /*     |  X  |  X  |  X  */
/*                                                        |     |     |     */
/* Property or method overrides private one               |     |     |     */
#define ZEND_ACC_CHANGED                 (1 <<  3) /*     |  X  |  X  |     */
/*                                                        |     |     |     */
/* Static method or property                              |     |     |     */
#define ZEND_ACC_STATIC                  (1 <<  4) /*     |  X  |  X  |     */
/*                                                        |     |     |     */
/* Promoted property / parameter                          |     |     |     */
#define ZEND_ACC_PROMOTED                (1 <<  5) /*     |     |  X  |  X  */
/*                                                        |     |     |     */
/* Final class or method                                  |     |     |     */
#define ZEND_ACC_FINAL                   (1 <<  5) /*  X  |  X  |     |     */
/*                                                        |     |     |     */
/* Abstract method                                        |     |     |     */
#define ZEND_ACC_ABSTRACT                (1 <<  6) /*  X  |  X  |     |     */
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS (1 <<  6) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Readonly property                                      |     |     |     */
#define ZEND_ACC_READONLY                (1 <<  7) /*     |     |  X  |     */
/*                                                        |     |     |     */
/* Immutable op_array and class_entries                   |     |     |     */
/* (implemented only for lazy loading of op_arrays)       |     |     |     */
#define ZEND_ACC_IMMUTABLE               (1 <<  7) /*  X  |  X  |     |     */
/*                                                        |     |     |     */
/* Function has typed arguments / class has typed props   |     |     |     */
#define ZEND_ACC_HAS_TYPE_HINTS          (1 <<  8) /*  X  |  X  |     |     */
/*                                                        |     |     |     */
/* Top-level class or function declaration                |     |     |     */
#define ZEND_ACC_TOP_LEVEL               (1 <<  9) /*  X  |  X  |     |     */
/*                                                        |     |     |     */
/* op_array or class is preloaded                         |     |     |     */
#define ZEND_ACC_PRELOADED               (1 << 10) /*  X  |  X  |     |     */
/*                                                        |     |     |     */
/* Flag to differentiate cases from constants.            |     |     |     */
/* Must not conflict with ZEND_ACC_ visibility flags      |     |     |     */
/* or IS_CONSTANT_VISITED_MARK                            |     |     |     */
#define ZEND_CLASS_CONST_IS_CASE         (1 << 6)  /*     |     |     |  X  */
/*                                                        |     |     |     */
/* Class Flags (unused: 21,30,31)                         |     |     |     */
/* ===========                                            |     |     |     */
/*                                                        |     |     |     */
/* Special class types                                    |     |     |     */
#define ZEND_ACC_INTERFACE               (1 <<  0) /*  X  |     |     |     */
#define ZEND_ACC_TRAIT                   (1 <<  1) /*  X  |     |     |     */
#define ZEND_ACC_ANON_CLASS              (1 <<  2) /*  X  |     |     |     */
#define ZEND_ACC_ENUM                    (1 << 28) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class linked with parent, interfaces and traits        |     |     |     */
#define ZEND_ACC_LINKED                  (1 <<  3) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class is abstract, since it is set by any              |     |     |     */
/* abstract method                                        |     |     |     */
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS (1 <<  4) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class has magic methods __get/__set/__unset/           |     |     |     */
/* __isset that use guards                                |     |     |     */
#define ZEND_ACC_USE_GUARDS              (1 << 11) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class constants updated                                |     |     |     */
#define ZEND_ACC_CONSTANTS_UPDATED       (1 << 12) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Objects of this class may not have dynamic properties  |     |     |     */
#define ZEND_ACC_NO_DYNAMIC_PROPERTIES   (1 << 13) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* User class has methods with static variables           |     |     |     */
#define ZEND_HAS_STATIC_IN_METHODS       (1 << 14) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Objects of this class may have dynamic properties      |     |     |     */
/* without triggering a deprecation warning               |     |     |     */
#define ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES (1 << 15) /* X  |     |     |     */
/*                                                        |     |     |     */
/* Readonly class                                         |     |     |     */
#define ZEND_ACC_READONLY_CLASS          (1 << 16) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Parent class is resolved (CE).                         |     |     |     */
#define ZEND_ACC_RESOLVED_PARENT         (1 << 17) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Interfaces are resolved (CEs).                         |     |     |     */
#define ZEND_ACC_RESOLVED_INTERFACES     (1 << 18) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class has unresolved variance obligations.             |     |     |     */
#define ZEND_ACC_UNRESOLVED_VARIANCE     (1 << 19) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class is linked apart from variance obligations.       |     |     |     */
#define ZEND_ACC_NEARLY_LINKED           (1 << 20) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* stored in opcache (may be partially)                   |     |     |     */
#define ZEND_ACC_CACHED                  (1 << 22) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* temporary flag used during delayed variance checks     |     |     |     */
#define ZEND_ACC_CACHEABLE               (1 << 23) /*  X  |     |     |     */
/*                                                        |     |     |     */
#define ZEND_ACC_HAS_AST_CONSTANTS       (1 << 24) /*  X  |     |     |     */
#define ZEND_ACC_HAS_AST_PROPERTIES      (1 << 25) /*  X  |     |     |     */
#define ZEND_ACC_HAS_AST_STATICS         (1 << 26) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* loaded from file cache to process memory               |     |     |     */
#define ZEND_ACC_FILE_CACHED             (1 << 27) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Class cannot be serialized or unserialized             |     |     |     */
#define ZEND_ACC_NOT_SERIALIZABLE        (1 << 29) /*  X  |     |     |     */
/*                                                        |     |     |     */
/* Function Flags (unused: 28-30)                         |     |     |     */
/* ==============                                         |     |     |     */
/*                                                        |     |     |     */
/* deprecation flag                                       |     |     |     */
#define ZEND_ACC_DEPRECATED              (1 << 11) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* Function returning by reference                        |     |     |     */
#define ZEND_ACC_RETURN_REFERENCE        (1 << 12) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* Function has a return type                             |     |     |     */
#define ZEND_ACC_HAS_RETURN_TYPE         (1 << 13) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* Function with variable number of arguments             |     |     |     */
#define ZEND_ACC_VARIADIC                (1 << 14) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* op_array has finally blocks (user only)                |     |     |     */
#define ZEND_ACC_HAS_FINALLY_BLOCK       (1 << 15) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* "main" op_array with                                   |     |     |     */
/* ZEND_DECLARE_CLASS_DELAYED opcodes                     |     |     |     */
#define ZEND_ACC_EARLY_BINDING           (1 << 16) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* closure uses $this                                     |     |     |     */
#define ZEND_ACC_USES_THIS               (1 << 17) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* call through user function trampoline. e.g.            |     |     |     */
/* __call, __callstatic                                   |     |     |     */
#define ZEND_ACC_CALL_VIA_TRAMPOLINE     (1 << 18) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* disable inline caching                                 |     |     |     */
#define ZEND_ACC_NEVER_CACHE             (1 << 19) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* op_array is a clone of trait method                    |     |     |     */
#define ZEND_ACC_TRAIT_CLONE             (1 << 20) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* functions is a constructor                             |     |     |     */
#define ZEND_ACC_CTOR                    (1 << 21) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* Closure related                                        |     |     |     */
#define ZEND_ACC_CLOSURE                 (1 << 22) /*     |  X  |     |     */
#define ZEND_ACC_FAKE_CLOSURE            (1 << 23) /*     |  X  |     |     */ /* Same as ZEND_CALL_FAKE_CLOSURE */
/*                                                        |     |     |     */
#define ZEND_ACC_GENERATOR               (1 << 24) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* function was processed by pass two (user only)         |     |     |     */
#define ZEND_ACC_DONE_PASS_TWO           (1 << 25) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* internal function is allocated at arena (int only)     |     |     |     */
#define ZEND_ACC_ARENA_ALLOCATED         (1 << 25) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* run_time_cache allocated on heap (user only)           |     |     |     */
#define ZEND_ACC_HEAP_RT_CACHE           (1 << 26) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* method flag used by Closure::__invoke() (int only)     |     |     |     */
#define ZEND_ACC_USER_ARG_INFO           (1 << 26) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* supports opcache compile-time evaluation (funcs)       |     |     |     */
#define ZEND_ACC_COMPILE_TIME_EVAL       (1 << 27) /*     |  X  |     |     */
/*                                                        |     |     |     */
/* op_array uses strict mode types                        |     |     |     */
#define ZEND_ACC_STRICT_TYPES            (1U << 31) /*    |  X  |     |     */

are there plans to support these flags in the future?

mac 下编译的问题

直接编译hello的时候报错

 Compiling hello v0.0.0 (/Users/...../workspace/phper/examples/hello)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/Users/.........-lc" "-lm" "-liconv"
  = note: Undefined symbols for architecture x86_64:
....

然后给项目追加了文件下 .cargo/config.toml 文件

[build]

[target.x86_64-apple-darwin]
rustflags = ["-Clink-args=-Wl,-undefined,dynamic_lookup"]

编译和测试可以走通

rust-lang/rust#62874

偶尔会502

自己编写了一个lib
但是刷新会偶尔
502 Bad Gateway
可以实现显示错误吗!
nginx和php都看不到错误
你的框架可以套个全局try吗
我现在用try无法拦截,只能502

constant definition

I can't seem to find a way to define constants for a specific module, is this feature support? if not, any plans to add it?

Title to get attention

I'm so sorry for the title, I don't have any inspiration for the title about this topic that I would like to discuss 😄. First of all, I want to thank you for this awesome library. It's a real enjoyment to use, really easy to understand and extend.

I'm the maintainer of the PHP extension for ScyllaDB/Apache Cassandra. For a long time, my buddy @DanielHe4rt and I wanted to rewrite the whole extension in Rust, for obvious reasons. It's an old codebase and contains some issues that aren't resolvable with the current state of the codebase (memory leaks, a mixture of C and C++, etc.).

The rewrite has started on V2 Branch since then, I found some missing parts needed for the full rewrite (e.g. Access to Zend Persistent Resources, Smart String API), so I forked the repo and made these changes needed. In the spirit of OpenSource, I wanted to announce these changes to you and if they align with your vision of the project we can merge them, if not, free feel to cherry-pick the stuff you like. Some changes are breaking (like replacing symtable API with str_* functions and dropping support for PHP < 8.1).

Changes can be found HERE.

Refactoring Exception.

I don't think the API design of Exception is very good at present, so I'm in the process of refactoring.

PHP 8.2 support

See apache/skywalking#9755

error[E0425]: cannot find value `name_length` in this scope
   --> /dev/shm/BUILD/php82-php-pecl-skywalking-agent-0.1.0/mycargo/phper/src/ini.rs:255:9
    |
255 |         name_length,
    |         ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `_zend_get_parameters_array_ex` in this scope
     --> /dev/shm/BUILD/php82-php-pecl-skywalking-agent-0.1.0/mycargo/phper/src/values.rs:135:13
      |
135   |               _zend_get_parameters_array_ex(num_args.try_into().unwrap(), arguments.as_mut_ptr());
      |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `zend_get_parameters_array_ex`
      |
     ::: /dev/shm/BUILD/php82-php-pecl-skywalking-agent-0.1.0/NTS/target/release/build/phper-sys-ddd865524bd4c63b/out/php_bindings.rs:35951:5
      |
35951 | /     pub fn zend_get_parameters_array_ex(param_count: u32, argument_array: *mut zval)
35952 | |         -> zend_result;
      | |______________________- similarly named function `zend_get_parameters_array_ex` defined here

Cannot override abstract classes in PHP

Example:

  • Declare a PHP class with an abstract method at Rust level
  • Extend this class at PHP level to override the abstract method

Trying to construct an object which derives the abstract class results in a panic here.
The current implementation seems like it only tries to lookup the state constructor from the current Zend class entry. I assume subclassing an abstract class exposed by Rust should either set the state constructor for derived classes properly or the current implementation of create_object() should scan the entire inheritance tree until it finds the proper state constructor.

Please let me know if you need further information to reproduce the issue. Thank you in advance!

Add owned state class entry.

The owned state class entry will hold the inner state with generic type, can be created with class registration (some way to make it always as static variable?)

Then we can new a state object by the state class entry, and then take the state without unsafe.

可以多增加点例子吗

现在的例子简单加复杂,不太好弄

use Response;
pub fn make_a031_class() -> StatefulClass<Response> {
    let mut class = StatefulClass::<Response>::new_with_default_state(A031_CLASS_NAME);
}

Response.rs(升级后改坏了,不知道怎么写了)

pub struct Response<T> {
    pub message: String,//这里希望使用&str,直接文字
    pub success: bool,
    pub data: T,
}
impl<T: Send + 'static> Response<T> {
    pub fn success<'a>(&self, message: String, data: T) -> Response<T> {
        Response {
            success: true,
            message: message,
            data,
        }
    }
}

我现在不会写这个StatefulClass的返回,怎么写泛型,以前0.4版本之前是正常,后来升级后不支持了
改版后希望增加点例子教我们怎么写。新版需要'static

我的需求是这样,希望执行后可以返回
{success:true,message:"这是返回信息",data:"这是一个泛型,所有种类的数据"}
或者
{success:false,message:"这是返回信息",data:"这是一个泛型,所有种类的数据"}

GCC 12 support

See apache/skywalking#9756

     --> /builddir/build/BUILD/php-pecl-skywalking-agent-0.1.0/NTS/target/release/build/phper-sys-730bb30f47c07323/out/php_bindings.rs:10727:30
      |
3020  | pub type _Float64 = f64;
      | ------------------------ similarly named type alias `_Float64` defined here
...
10727 |     pub fn fmaximumf64x(__x: _Float64x, __y: _Float64x) -> _Float64x;
      |                              ^^^^^^^^^ help: a type alias with a similar name exists: `_Float64`

error[E0412]: cannot find type `_Float64x` in this scope
     --> /builddir/build/BUILD/php-pecl-skywalking-agent-0.1.0/NTS/target/release/build/phper-sys-730bb30f47c07323/out/php_bindings.rs:10727:46
      |
3020  | pub type _Float64 = f64;
      | ------------------------ similarly named type alias `_Float64` defined here
...
10727 |     pub fn fmaximumf64x(__x: _Float64x, __y: _Float64x) -> _Float64x;
      |                                              ^^^^^^^^^ help: a type alias with a similar name exists: `_Float64`

error[E0412]: cannot find type `_Float64x` in this scope
     --> /builddir/build/BUILD/php-pecl-skywalking-agent-0.1.0/NTS/target/release/build/phper-sys-730bb30f47c07323/out/php_bindings.rs:10727:60
      |
3020  | pub type _Float64 = f64;
      | ------------------------ similarly named type alias `_Float64` defined here
...
10727 |     pub fn fmaximumf64x(__x: _Float64x, __y: _Float64x) -> _Float64x;
      |                                                            ^^^^^^^^^ help: a type alias with a similar name exists: `_Float64`

error[E0412]: cannot find type `_Float64x` in this scope
     --> /builddir/build/BUILD/php-pecl-skywalking-agent-0.1.0/NTS/target/release/build/phper-sys-730bb30f47c07323/out/php_bindings.rs:10730:32
      |
3020  | pub type _Float64 = f64;
      | ------------------------ similarly named type alias `_Float64` defined here
...
10730 |     pub fn __fmaximumf64x(__x: _Float64x, __y: _Float64x) -> _Float64x;
      |                                ^^^^^^^^^ help: a type alias with a similar name exists: `_Float64`



error: linking with `cc` failed: exit status: 1

Is it related to my inability to compile on Centos
rust-lang/rust#113104

rustc --version
rustc 1.69.0 (84c898d65 2023-04-16)

"-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/a031-2138c8368c6736ee.a031.6483571e-cgu.12.rcgu.o: in function `phper::functions::call_raw_common':
          a031.6483571e-cgu.12:(.text._ZN5phper9functions15call_raw_common17hb55ad66c3e9ecf43E+0x75): undefined reference to `executor_globals'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/a031-2138c8368c6736ee.a031.6483571e-cgu.12.rcgu.o: in function `phper::functions::ZFunc::call':
          a031.6483571e-cgu.12:(.text._ZN5phper9functions5ZFunc4call17h991d71825814632dE+0x55): undefined reference to `zend_call_known_function'
          /usr/bin/ld: a031.6483571e-cgu.12:(.text._ZN5phper9functions5ZFunc4call17h991d71825814632dE+0x93): undefined reference to `executor_globals'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/a031-2138c8368c6736ee.a031.6483571e-cgu.9.rcgu.o: in function `a031::main':
          a031.6483571e-cgu.9:(.text._ZN4a0314main17hb40a4c8c9b22b24fE+0xc): undefined reference to `zend_ce_exception'
          /usr/bin/ld: a031.6483571e-cgu.9:(.text._ZN4a0314main17hb40a4c8c9b22b24fE+0x8a): undefined reference to `zend_update_property'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper-17ed872cf194abb4.rlib(phper-17ed872cf194abb4.phper.2ca4b959-cgu.13.rcgu.o): in function `<phper::types::TypeInfo as core::fmt::Debug>::fmt':
          phper.2ca4b959-cgu.13:(.text._ZN59_$LT$phper..types..TypeInfo$u20$as$u20$core..fmt..Debug$GT$3fmt17hdae16aadc0245db3E+0xdb): undefined reference to `zend_get_type_by_const'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper-17ed872cf194abb4.rlib(phper-17ed872cf194abb4.phper.2ca4b959-cgu.14.rcgu.o): in function `std::thread::local::LocalKey<T>::with':
          phper.2ca4b959-cgu.14:(.text._ZN3std6thread5local17LocalKey$LT$T$GT$4with17h5840b6fcea976187E+0x23): undefined reference to `executor_globals'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper-17ed872cf194abb4.rlib(phper-17ed872cf194abb4.phper.2ca4b959-cgu.14.rcgu.o): in function `std::thread::local::LocalKey<T>::with':
          phper.2ca4b959-cgu.14:(.text._ZN3std6thread5local17LocalKey$LT$T$GT$4with17haca76368edcb164eE+0x3d): undefined reference to `executor_globals'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper-17ed872cf194abb4.rlib(phper-17ed872cf194abb4.phper.2ca4b959-cgu.4.rcgu.o): in function `phper::errors::ThrowObject::new':
          phper.2ca4b959-cgu.4:(.text._ZN5phper6errors11ThrowObject3new17h55aaf068a425ee7dE+0x1e): undefined reference to `zend_ce_throwable'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper_sys-ef863276b04bb385.rlib(php_wrapper.o): in function `phper_zval_ptr_dtor':
          php_wrapper.c:(.text.phper_zval_ptr_dtor+0x1): undefined reference to `zval_ptr_dtor'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper_sys-ef863276b04bb385.rlib(php_wrapper.o): in function `phper_object_init_ex':
          php_wrapper.c:(.text.phper_object_init_ex+0x5): undefined reference to `object_init_ex'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper_sys-ef863276b04bb385.rlib(php_wrapper.o): in function `phper_zend_object_release':
          php_wrapper.c:(.text.phper_zend_object_release+0x11): undefined reference to `zend_objects_store_del'
          /usr/bin/ld: php_wrapper.c:(.text.phper_zend_object_release+0x19): undefined reference to `gc_possible_root'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper_sys-ef863276b04bb385.rlib(php_wrapper.o): in function `phper_instanceof_function':
          php_wrapper.c:(.text.phper_instanceof_function+0x6): undefined reference to `instanceof_function_slow'
          /usr/bin/ld: /mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper_sys-ef863276b04bb385.rlib(php_wrapper.o): in function `phper_emalloc':
          php_wrapper.c:(.text.phper_emalloc+0x1): undefined reference to `_emalloc'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `a031` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name a031 --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=120 --crate-type bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=2138c8368c6736ee -C extra-filename=-2138c8368c6736ee --out-dir /mnt/x/xiaolu/rust/php/a031/target/release/deps -L dependency=/mnt/x/xiaolu/rust/php/a031/target/release/deps --extern a031=/mnt/x/xiaolu/rust/php/a031/target/release/deps/liba031-8b142ad1b90c8d09.rlib --extern gmsm=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libgmsm-5165a464c849750b.rlib --extern hex=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libhex-bac9e27907d25766.rlib --extern idgenerator_thin=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libidgenerator_thin-4fc1f95ac416344a.rlib --extern jieba_rs=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libjieba_rs-9e0c58d1ab587520.rlib --extern phper=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libphper-17ed872cf194abb4.rlib --extern quick_xml=/mnt/x/xiaolu/rust/php/a031/target/release/deps/libquick_xml-e26f1081692a9d8d.rlib -L native=/mnt/x/xiaolu/rust/php/a031/target/release/build/phper-sys-8ec2937c074e2932/out` (exit status: 1)

cargo build --release hello failed

root@a4d296ceddf3:/myapp/examples/hello# cargo build --release
Compiling proc-macro2 v1.0.66
Compiling libc v0.2.147
Compiling memchr v2.5.0
Compiling prettyplease v0.2.12
Compiling clang-sys v1.6.1
Compiling syn v1.0.109
Compiling thiserror v1.0.47
Compiling phper-example-hello v0.0.0 (/myapp/examples/hello)
Compiling bindgen v0.66.1
Compiling quote v1.0.33
Compiling nom v7.1.3
Compiling syn v2.0.29
Compiling which v4.4.0
Compiling cc v1.0.83
Compiling cexpr v0.6.0
Compiling derive_more v0.99.17
Compiling thiserror-impl v1.0.47
Compiling phper-macros v0.12.0 (/myapp/phper-macros)
Compiling phper-sys v0.12.1 (/myapp/phper-sys)
error: failed to run custom build command for phper-sys v0.12.1 (/myapp/phper-sys)

Caused by:
process didn't exit successfully: /myapp/target/release/build/phper-sys-9b03df3e9fae08f2/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=php_wrapper.c
cargo:rerun-if-env-changed=PHP_CONFIG

--- stderr
thread 'main' panicked at 'Execute command ["php-config", "--includes"] failed', phper-sys/build.rs:71:29
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for phper-sys v0.12.1 (/myapp/phper-sys)

Caused by:
process didn't exit successfully: /myapp/target/release/build/phper-sys-9b03df3e9fae08f2/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-changed=php_wrapper.c
cargo:rerun-if-env-changed=PHP_CONFIG

--- stderr
thread 'main' panicked at 'Execute command ["php-config", "--includes"] failed', phper-sys/build.rs:71:29
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Shower Than C Extension

Hi
I tested with xdebug profile option with grind cache.
Functions are slower than c. How to speed up?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.