Page 1 of 1

Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-08-31 14:00
by nkteam
Hello,

I'm having troubles installing the "cffi" package as linker fails because of "-lgcc" is not available (package gcc-multilink is not available).

It fails with "/usr/bin/ld: cannot find -lgcc" error.


To reproduce do the following:
* flash clean ubuntu image on pico ultra w board
* install apt packages: python3.10-venv and libffi-dev
* create virtual environment
* activate virtual environment
* execute "pip install cffi"

This is the complete output:

Code: Select all

(env) master@luckfox:/srv/env$ pip install cffi
Collecting cffi
  Using cached cffi-1.17.0.tar.gz (516 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pycparser (from cffi)
  Using cached pycparser-2.22-py3-none-any.whl.metadata (943 bytes)
Using cached pycparser-2.22-py3-none-any.whl (117 kB)
Building wheels for collected packages: cffi
  Building wheel for cffi (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cffi (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [50 lines of output]
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      collect2: error: ld returned 1 exit status
      Note: will not use '__sync_synchronize()' in the C code
      ***** The above error message can be safely ignored.

      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-cpython-310
      creating build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/cparser.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/_imp_emulation.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/ffiplatform.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/vengine_gen.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/recompiler.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/lock.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/pkgconfig.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/setuptools_ext.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/model.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/error.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/cffi_opcode.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/backend_ctypes.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/api.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/verifier.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/_shimmed_dist_utils.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/commontypes.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/__init__.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/vengine_cpy.py -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/_cffi_include.h -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/parse_c_type.h -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/_embedding.h -> build/lib.linux-armv7l-cpython-310/cffi
      copying src/cffi/_cffi_errors.h -> build/lib.linux-armv7l-cpython-310/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-armv7l-cpython-310
      creating build/temp.linux-armv7l-cpython-310/src
      creating build/temp.linux-armv7l-cpython-310/src/c
      arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DFFI_BUILDING=1 -DUSE__THREAD -I/usr/include/ffi -I/usr/include/libffi -I/srv/env/include -I/usr/include/python3.10 -c src/c/_cffi_backend.c -o build/temp.linux-armv7l-cpython-310/src/c/_cffi_backend.o
      In file included from src/c/cffi1_module.c:20,
                       from src/c/_cffi_backend.c:8027:
      src/c/call_python.c:211:5: warning: #warning "no definition for read_barrier(), missing synchronization for multi-thread initialization in embedded mode" [-Wcpp]
        211 | #   warning "no definition for read_barrier(), missing synchronization for\
            |     ^~~~~~~
      arm-linux-gnueabihf-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-armv7l-cpython-310/src/c/_cffi_backend.o -L/usr/lib/arm-linux-gnueabihf -lffi -o build/lib.linux-armv7l-cpython-310/_cffi_backend.cpython-310-arm-linux-gnueabihf.so
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cffi
Failed to build cffi
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (cffi)
Please provide help as we're trying to evaluate the board and test if it's suitable for production purposes, and currently this is a blocker.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-02 6:39
by Crocodile
Hello, based on the log you provided, it seems that the corresponding library files are missing. Please try executing the following commands to resolve the issue:

Code: Select all

sudo apt-get install gcc
sudo apt-get install gcc-multilib
When setting up a Python virtual environment, you might need various development tool packages (*-dev). Compiling these packages can be time-consuming. In the future, we plan to introduce a Docker-based rootfs image building method, allowing some of these time-consuming tasks to be executed on a PC.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-02 12:32
by nkteam
GCC was installed from the start (as well as the needed *-dev packages).

As I wrote in my question, GCC is missing gcc-multilink package, which is not available in default "ports" repository for ARM.

Can you please provide further info on how to install gcc-multilink package?

Code: Select all

master@pico:~$ sudo apt install gcc-multilib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package gcc-multilib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-02 13:33
by Crocodile
We haven't conducted related tests, and there are too many Python packages for us to check each one individually. Previously, when I was porting Home Assistant to Alpine, I also encountered issues with installing the cffi dependency. Unfortunately, I didn't document how I resolved it, so I've forgotten the solution. If there's any progress later, I'll inform you immediately.

If it's convenient, could you let me know the project you plan to validate? Perhaps I can suggest a better alternative.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-03 12:57
by nkteam
Please try to remember if possible.

Project we're trying to deploy is our internal project.
And cffi is dependency of poetry which we cannot install currently.
Yes, using the plain pip for dependency management is an alternative, but having this also working would be perfect.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-08 16:21
by Josper
Crocodile wrote: 2024-09-02 13:33 We haven't conducted related tests, and there are too many Python packages for us to check each one individually. Previously, when I was porting Home Assistant to Alpine, I also encountered issues with installing the cffi dependency. Unfortunately, I didn't document how I resolved it, so I've forgotten the solution. If there's any progress later, I'll inform you immediately.

If it's convenient, could you let me know the project you plan to validate? Perhaps I can suggest a better alternative.
No, I try to set up HomeAssistant on luckfox pro max, and can't do nothing. cffi 1.17.1 needed, but default older version. build not possible. How can I resolve this? Thank you.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-09 1:26
by Crocodile
When porting Home Assistant, I chose not to use Ubuntu as the root filesystem (Ubuntu consumes too many memory resources). Instead, I used armv7l/Alpine in a Docker container on a PC to execute the build, which eventually ran successfully (even though it took a lot of time on the PC). On Ubuntu, I'm unsure how to verify if CFFI is working correctly (I don't have the time to spend significant effort trying to port Home Assistant on Ubuntu again). Therefore, for now, the CFFI issue on Ubuntu will remain a pending task. I will inform you as soon as there is progress.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-11 6:56
by Josper
Thank's for an answer.
Do you have instructions, how to install HA on Alpine ?
And correct way to install alpine on sd card for Luckfox?
I kill a week, to try install gcc with multilab :(
Thank you.

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-09-11 7:34
by Crocodile
I will update this article to the wiki in the future, and I will let you know in this topic when it is updated

Re: Cannot build cffi on Pico Ultra W "/usr/bin/ld: cannot find -lgcc"

Posted: 2024-10-24 17:57
by IndianaTux
I'm running in the same issue trying to install a python module that requires compilation:

Code: Select all

root@luckfox:~/gas-index-algorithm/python-wrapper# pip install sensirion-gas-index-algorithm
Collecting sensirion-gas-index-algorithm
  Using cached sensirion-gas-index-algorithm-3.2.2.tar.gz (49 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: sensirion-gas-index-algorithm
  Building wheel for sensirion-gas-index-algorithm (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.10
      creating build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/sensirion_gas_index_algorithm_wrap.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/version.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/gas_index_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/nox_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/voc_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/__init__.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      running build_ext
      building 'sensirion_gas_index_algorithm._sensirion_gas_index_algorithm_wrap' extension
      creating build/temp.linux-armv7l-3.10
      creating build/temp.linux-armv7l-3.10/swig
      arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iswig -I/usr/include/python3.10 -c swig/sensirion_gas_index_algorithm.c -o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm.o
      arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iswig -I/usr/include/python3.10 -c swig/sensirion_gas_index_algorithm_wrap.c -o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm_wrap.o
      arm-linux-gnueabihf-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm.o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm_wrap.o -Lswig -o build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm/_sensirion_gas_index_algorithm_wrap.cpython-310-arm-linux-gnueabihf.so
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for sensirion-gas-index-algorithm
  Running setup.py clean for sensirion-gas-index-algorithm
Failed to build sensirion-gas-index-algorithm
Installing collected packages: sensirion-gas-index-algorithm
  Running setup.py install for sensirion-gas-index-algorithm ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for sensirion-gas-index-algorithm did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running install
      /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-armv7l-3.10
      creating build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/sensirion_gas_index_algorithm_wrap.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/version.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/gas_index_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/nox_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/voc_algorithm.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      copying sensirion_gas_index_algorithm/__init__.py -> build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm
      running build_ext
      building 'sensirion_gas_index_algorithm._sensirion_gas_index_algorithm_wrap' extension
      creating build/temp.linux-armv7l-3.10
      creating build/temp.linux-armv7l-3.10/swig
      arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iswig -I/usr/include/python3.10 -c swig/sensirion_gas_index_algorithm.c -o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm.o
      arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Iswig -I/usr/include/python3.10 -c swig/sensirion_gas_index_algorithm_wrap.c -o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm_wrap.o
      arm-linux-gnueabihf-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm.o build/temp.linux-armv7l-3.10/swig/sensirion_gas_index_algorithm_wrap.o -Lswig -o build/lib.linux-armv7l-3.10/sensirion_gas_index_algorithm/_sensirion_gas_index_algorithm_wrap.cpython-310-arm-linux-gnueabihf.so
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      /usr/bin/ld: cannot find -lgcc: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> sensirion-gas-index-algorithm

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Any ways to solve this ?

I tried building from source, and I'm getting the same error.

Thanks.