简体   繁体   English

如何通过将参数传递给Autoconf来取消定义HAVE_ [function]宏?

[英]How can I undefine a HAVE_[function] macro by passing arguments to Autoconf?

The problem: In the Ruby interpreter C code there's a couple of sections that call the __syscall function on macOS and BSD. 问题:在Ruby解释器C代码中有几个部分在macOS和BSD上调用__syscall函数。 This is very bad behaviour in macOS land because it is a private (and volatile) API. 这在macOS领域是非常不好的行为,因为它是一个私有(和易失性)API。

The __syscall usage is only included conditionally based on HAVE_ defines, so I would like to find out if I can compile Ruby without it. __syscall用法仅包含有条件地基于HAVE_定义,所以我想知道我是否可以在没有它的情况下编译Ruby。 Here is an example from io.c : 以下是来自io.c的示例:

#if defined(HAVE___SYSCALL) && (defined(__APPLE__) || defined(__OpenBSD__))
/* Mac OS X and OpenBSD have __syscall but don't define it in headers */
    off_t __syscall(quad_t number, ...);
#endif

...some time later...

static VALUE
rb_f_syscall(int argc, VALUE *argv)
{
    VALUE arg[8];

    ...a bunch of platform checks that usually end up doing this...

    # define SYSCALL __syscall

    ...some time later...

    switch (argc) {
      case 1:
        retval = SYSCALL(num);
        break;
      case 2:
        retval = SYSCALL(num, arg[0]);
        break;
      case 3:
        retval = SYSCALL(num, arg[0],arg[1]);
        break;

      ... and so on up to case 8...

    }

    ... function returns and then...

    #undef SYSCALL
}

Sharp-eyed readers will also notice that even the Ruby devs don't like using __syscall - they want to replace it with the DL (Fiddle) library instead. 眼尖的读者也会注意到,即使Ruby开发人员不喜欢使用__syscall - 他们也希望用DL(小提琴)库代替它。

The constraint: I do not want to fork the Ruby interpreter source to do this as that will lead to continuous cumbersome maintenance of the fork. 约束:我不想分叉Ruby解释器源来执行此操作,因为这会导致fork的连续繁琐维护。 Instead I would like to pass an argument to the build tool when it compiles Ruby that does this. 相反,我想在编译执行此操作的Ruby时将参数传递给构建工具。

The question: Can I force one of the related HAVE__ macros to be undefined, or perhaps disable the AC_CHECK_HEADERS in configure.in, and so prevent the use of __syscall here, by passing an argument to the build tool? 问题:我可以强制一个相关的HAVE__宏未定义,或者可能禁用configure.in中的AC_CHECK_HEADERS,因此通过将参数传递给构建工具来阻止在这里使用__syscall吗?

You should be able to tweak one of the ac_cv_* variables at ./configure time. 您应该能够在./configure时调整其中一个ac_cv_*变量。

Particularly, for ruby-2.1.9 this should work: 特别是对于ruby-2.1.9,这应该工作:

./configure ac_cv_func___syscall=no

(For reference, you can see the ac_cv_* variables set in config.log .) (作为参考,您可以在config.log看到ac_cv_*变量。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM