pyenv / pyenv

Simple Python version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install script unable to compile python on debian based system (gcc 11, error: implicit declaration of function ‘close_range’)

Youjin1985 opened this issue · comments

Description

  • Platform information (e.g. Ubuntu Linux 16.04): Deepin Linux 23, /etc/debian_version: bookworm/sid
  • OS architecture (e.g. amd64): uname -a: Linux youjin-PC 6.1.32-amd64-desktop-hwe x86_64 GNU/Linux
  • pyenv version: 2.3.35
  • Python version: 3.11.7
  • C Compiler information (e.g. gcc 7.3): gcc 11.2.0
  • Please attach the debug trace of the failing command as a gist:
    command 'pyenv install 3.11.7' fails at python compilation:

Python/fileutils.c: In function ‘_Py_closerange’:
Python/fileutils.c:2650:9: error: implicit declaration of function ‘close_range’ [-Werror=implicit-function-declaration]
2650 | if (close_range(first, last, 0) == 0) {
| ^~~~~~~~~~~

  • If the build succeeds but the problem is still with the build process (e.g. the resulting Python is missing a feature), please attach
    • the debug trace from reinstalling the faulty version with env PYENV_DEBUG=1 pyenv install -f -k -v <version> 2>&1 | tee trace.log
      trace.log
  • If you have a problem with installing Python, please also attach config.log from the build directory
    • The build directory is reported after the "BUILD FAILED" message and is usually under /tmp.
    • config.log from the build directory. When using pyenv install with -k as per above, the build directory will be under $PYENV_ROOT/sources.
      config.log

(I installed usual *dev packages and checked a lot of internet before posting there)

I found this post https://bbs.deepin.org/zh/post/260319, edited file Python/fileutils.c, updated checksum in pyenv script, and all almost compiled, but at very end build fails with

File "/home/youjin/.pyenv/sources/3.11.7/Python-3.11.7/Lib/ensurepip/init.py", line 4, in
import subprocess
File "/home/youjin/.pyenv/sources/3.11.7/Python-3.11.7/Lib/subprocess.py", line 104, in
from _posixsubprocess import fork_exec as _fork_exec
ModuleNotFoundError: No module named '_posixsubprocess'
make: *** [Makefile:1883:install] 错误 1

????

Turns out _posixsubprocess module was not compiled because of same reason - error: implicit declaration of function ‘close_range’. After fix from link above 3.11.7 can be compiled.
Please fix the issue by applying patch to all places containing calls of close_range function in python code - I am not sure I can do it myself and pull request.

Looks like a problem with either the compiler toolchain or CPython build logic. The function close_range is found by Configure but somehow not found during actual compilation.
I'll try to reproduce the problem and examine the details when I'm back home.

I remember that gcc-12 on another linux distribution was compiling successfully, I got this problem only with gcc-11.2 mentioned above.
(I didn't want to mess with system compiler, so I just used workaround with declaring extern function.)

How did you install the gcc-11 package? Deepin has a "package installer" to install 3rd-party deb's, but it requires all the package's dependencies, too. Is there a way easier than discovering and downloading them all manually?

Adding declarations of functions that should be in system headers in a certain no-go -- that'll break the build in other environments where those functions are defined differently.

Strictly speaking, you are installing deb packages into an environment that they were not designed for.
Nobody guarantees you that they will work properly.

  • Is using the system compiler not an option? That should be the easiest way to proceed
  • You can provide a custom patch to apply to the source code with the -p option to pyenv install
  • A "good" solution I have in mind is to pinpoint the place in your specific compiler toolchain where it goes wrong and fix that -- perhaps possible by defining an envvar or preprocessor symbol.
    For that, I need to be able to reproduce the issue -- which I'm having trouble with, so your help in that would be very welcome.

Thank you so much. Seems patch is only option (but I already did it manually faster than I would figure out how to apply it - I am not using it in development).
I'll gladly provide any information which can help.

How did you install the gcc-11 package? Deepin has a "package installer" to install 3rd-party deb's, but it requires all the package's dependencies, too. Is there a way easier than discovering and downloading them all manually?
Is using the system compiler not an option? That should be the easiest way to proceed

I did not install it. It was available out of box just after OS installation, and no *deb packages were manually installed. For installation of all required packages (like libreadline-dev), I only used sudo apt install with default repos.

For that, I need to be able to reproduce the issue -- which I'm having trouble with, so your help in that would be very welcome.

My OS is Deepin linux, installed from deepin-desktop-community-23-Beta2-amd64.iso available from official site - in case you have time and resources for reproducing it in virtual machine

Okay, I've installed Deepin 13 Beta2 into a VM.
When I installed Pyenv build dependencies as per https://github.com/pyenv/pyenv/wiki#suggested-build-environment , it installed GCC 13 as a dependency, so there isn't an obvious reason to use GCC 11.
Regardless, then I installed GCC 11, and it installed gcc-11 11.4.0-3.

Neither of those had a build problem with 3.11.7.

So I suggest you just upgrade the compiler package and/or the Pyenv dependency packages. (Note: only upgrade those. The distro doesn't seem to be very stable, a full apt upgrade bricked my system; Apt also suggested some packages for autoremove, I didn't do that, either.)

I upgraded system gcc to 13.2.0 which is also available, and python compiles without problems

commented

I'm having a similar problem, but my gcc version is 13.2, is there any solution? @native-api @Youjin1985

Here are some of my dependencies:
➜ ~ pyenv --version
pyenv 2.4.3
➜ ~ uname -a
Linux so1n-PC 6.6.25-amd64-desktop-hwe #23.01.00.25 SMP PREEMPT_DYNAMIC Wed Apr 10 21:20:25 CST 2024 x86_64 GNU/Linux
➜ ~ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Deepin 13.2.0-3deepin2' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/usr/src/packages/BUILD/debian/tmp-nvptx/usr,amdgcn-amdhsa=/usr/src/packages/BUILD/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=8
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Deepin 13.2.0-3deepin2)

@so1n Can't say anything without the necessary diagnostic details as per the issue template.

commented

@native-api I'm so sorry and I created an issue (#2988) according to the issue template.