繁体   English   中英

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

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

问题:在Ruby解释器C代码中有几个部分在macOS和BSD上调用__syscall函数。 这在macOS领域是非常不好的行为,因为它是一个私有(和易失性)API。

__syscall用法仅包含有条件地基于HAVE_定义,所以我想知道我是否可以在没有它的情况下编译Ruby。 以下是来自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
}

眼尖的读者也会注意到,即使Ruby开发人员不喜欢使用__syscall - 他们也希望用DL(小提琴)库代替它。

约束:我不想分叉Ruby解释器源来执行此操作,因为这会导致fork的连续繁琐维护。 相反,我想在编译执行此操作的Ruby时将参数传递给构建工具。

问题:我可以强制一个相关的HAVE__宏未定义,或者可能禁用configure.in中的AC_CHECK_HEADERS,因此通过将参数传递给构建工具来阻止在这里使用__syscall吗?

您应该能够在./configure时调整其中一个ac_cv_*变量。

特别是对于ruby-2.1.9,这应该工作:

./configure ac_cv_func___syscall=no

(作为参考,您可以在config.log看到ac_cv_*变量。)

暂无
暂无

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

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