在 Ubuntu 14.04 上构建 Python 3.5.1 时检查 getrandom() 函数 returns 否

Checking for getrandom() function returns no when building Python 3.5.1 on Ubuntu 14.04

我正在尝试在 GCE Ubuntu 14.04 VM 上构建 Python 3.5.1,当 运行 ./configure 在解压缩的文件夹中时,我得到:

checking for the Linux getrandom() syscall... no
checking for the getrandom() function... no

uname -a命令returns:

Linux server.mydomain.com 3.19.0-58-generic #64~14.04.1-Ubuntu SMP Fri Mar 18 19:05:43 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

我不明白为什么 configure 无法检测到 getrandom(),在 Python 3.5.1 发布文档中它说 Python 解释器 will detect and use this function/system call in Linux Kernels above 3.17

我在这里错过了什么?有人遇到同样的问题吗?

提前感谢您的回答。

达尼洛

Python用来判断你是否有getrandom()的测试程序在这里:https://hg.python.org/cpython/rev/4491bdb6527b/#l3.176

#include <sys/syscall.h>

int main() {
    const int flags = 0;
    char buffer[1];
    int n;
    /* ignore the result, Python checks for ENOSYS at runtime */
    (void)syscall(SYS_getrandom, buffer, sizeof(buffer), flags);
    return 0;
}

如果您尝试在您的系统上构建该程序,您会得到什么?如果有效,您的 Python 应该使用 getrandom(),否则您应该从编译器输出中看到问题所在。

编辑:现在我们看到您确实没有 SYS_getrandom,我们可以确定问题出在哪里:您的内核足够新,可以支持 getrandom(),但是您的 libc 不是。解决方案是升级您的 glibc-dev.