espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.84k stars 7.32k forks source link

mac book m3 pro set-target error (IDFGH-13972) #14802

Closed huangganggui closed 2 weeks ago

huangganggui commented 4 weeks ago

Answers checklist.

IDF version.

v5.2.3

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

success

What is the actual behavior?

faild

Steps to reproduce.

git clone -b v5.2.3 --recursive https://github.com/espressif/esp-idf.git

cd esp-idf ./install.sh esp32 . $HOME/esp/esp-idf/export.sh cd ~/esp cp -r $IDF_PATH/examples/get-started/hello_world . cd ~/esp/hello_world idf.py set-target esp32

Build or installation Logs.

idf.py set-target esp32

Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory '/Users/huangganggui/esp/hello_world/build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32, new sdkconfig will be created.
Running cmake in directory /Users/huangganggui/esp/hello_world/build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=/Users/huangganggui/.espressif/python_env/idf5.2_py3.12_env/bin/python -DESP_PLATFORM=1 -DIDF_TARGET=esp32 -DCCACHE_ENABLE=0 /Users/huangganggui/esp/hello_world"...
-- Found Git: /opt/homebrew/bin/git (found version "2.47.0")
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc
-- Check for working C compiler: /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc - broken
CMake Error at /opt/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/Users/huangganggui/esp/hello_world/build/CMakeFiles/CMakeScratch/TryCompile-2cNieM'

    Run Build Command(s): /opt/homebrew/bin/ninja -v cmTC_b00e9
    [1/2] /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address  -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -o CMakeFiles/cmTC_b00e9.dir/testCCompiler.c.obj -c /Users/huangganggui/esp/hello_world/build/CMakeFiles/CMakeScratch/TryCompile-2cNieM/testCCompiler.c
    [2/2] : && /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address  -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy :-L/opt/homebrew/opt/libffi/lib CMakeFiles/cmTC_b00e9.dir/testCCompiler.c.obj -o cmTC_b00e9   && :
    FAILED: cmTC_b00e9 
    : && /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc -mlongcalls -Wno-frame-address  -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy :-L/opt/homebrew/opt/libffi/lib CMakeFiles/cmTC_b00e9.dir/testCCompiler.c.obj -o cmTC_b00e9   && :
    /Users/huangganggui/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: cannot find :-L/opt/homebrew/opt/libffi/lib: No such file or directory
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  /Users/huangganggui/esp/esp-idf/tools/cmake/project.cmake:506 (__project)
  CMakeLists.txt:6 (project)

-- Configuring incomplete, errors occurred!
cmake failed with exit code 1, output of the command is in the /Users/huangganggui/esp/hello_world/build/log/idf_py_stderr_output_84932 and /Users/huangganggui/esp/hello_world/build/log/idf_py_stdout_output_84932
huangganggui@caiqiurudeMacBook-Pro hello_world %

More Information.

huangganggui commented 3 weeks ago

NOTE That: When I used vscode extensions named esp-idf to install all, every thing is ok. may be I miss some steps?

peterdragun commented 3 weeks ago

Hi @huangganggui, I am also using macOS with M3 Pro and have never seen such an issue. Can you please tell us more details about your environment? Which version of macOS are you running? MacOS should already contain libffi without need to install it using brew. In your case the lib from brew is getting used (TBH I don't think that should matter but is definitely not the default state for most users). When you install libffi using brew there is some additional information printed that you can export some variables to override the system libffi with the one from homebrew. Have you by any chance set those environment variables? Please check if any of PKG_CONFIG_PATH, LDFLAGS or CPPFLAGS is set for you. This would also make sense why installation from VSCode might work, because those environment variables might not be set there.

fhrbata commented 3 weeks ago

Hi @huangganggui, I am also using macOS with M3 Pro and have never seen such an issue. Can you please tell us more details about your environment? Which version of macOS are you running? MacOS should already contain libffi without need to install it using brew. In your case the lib from brew is getting used (TBH I don't think that should matter but is definitely not the default state for most users). When you install libffi using brew there is some additional information printed that you can export some variables to override the system libffi with the one from homebrew. Have you by any chance set those environment variables? Please check if any of PKG_CONFIG_PATH, LDFLAGS or CPPFLAGS is set for you. This would also make sense why installation from VSCode might work, because those environment variables might not be set there.

I'm no mac user, but I think @peterdragun is right. It seems there might be problem with LDFLAGS. Why is the : present before the -L option? :-L/opt/homebrew/opt/libffi/lib. This seems to be the culprit.

huangganggui commented 2 weeks ago

Thanks for yours reply @fhrbata @peterdragun . Installing by vscode extensions works well for me. when I want to use idf.py in command line, I use . ~/esp/v5.2.3/esp-idf/export.sh and everythings work well.

So I will close this issue for now. If anyone encounters this problem again, please feel free to reopen it.