Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation of programs for the Pololu 3pi+ 2040 robot broke with the 0.7.0 release #2282

Closed
NiklasRentzCAU opened this issue May 13, 2024 · 15 comments

Comments

@NiklasRentzCAU
Copy link

With the newest release of Lingua Franca 0.7.0, the compilation of programs for the Pololu 3pi 2040 robot throws errors and does not compile correctly anymore. I tested one of the programs of the Embedded Systems Lab, specifically the AccelerometerDisplay.lf example with both the 0.6.0 and 0.7.0 versions of the VS Code extension and the lfc tool. Both old versions 0.6.0 compile fine, while the 0.7.0 versions show this in the output and the error log (taken from the VS Code extension):

CMakeError.log
CMakeOutput.log

Cleaning /home/nre/git/lf-3pi/include
Cleaning /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build
--- Current working directory: /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build
--- Executing command: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/nre/git/lf-3pi -DCMAKE_INSTALL_BINDIR=bin -DLF_FILE_SEPARATOR="/" -DLF_SOURCE_DIRECTORY="/home/nre/git/lf-3pi/src" -DLF_PACKAGE_DIRECTORY="/home/nre/git/lf-3pi" -DLF_SOURCE_GEN_DIRECTORY="/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay" /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
Using PICO_SDK_PATH from environment ('/home/nre/git/lf-3pi/pico-sdk')
PICO_SDK_PATH is /home/nre/git/lf-3pi/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
PICO compiler is pico_arm_gcc
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from /home/nre/git/lf-3pi/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
TinyUSB available at /home/nre/git/lf-3pi/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at /home/nre/git/lf-3pi/pico-sdk/lib/btstack
cyw43-driver available at /home/nre/git/lf-3pi/pico-sdk/lib/cyw43-driver
-- Including sources for single-threaded runtime.
-- Including the following sources: tag.c, clock.c, port.c, mixed_radix.c, reactor_common.c, lf_token.c, environment.c, reactor.c, utils/vector.c, utils/pqueue_base.c, utils/pqueue_tag.c, utils/pqueue.c, utils/util.c, utils/hashset/hashset.c, utils/hashset/hashset_itr.c
-- Applying preprocessor definitions to platform...
-- LF_SINGLE_THREADED=1
-- LOG_LEVEL=2
-- NUMBER_OF_WATCHDOGS=0
-- Applying preprocessor definitions...
-- LF_REACTION_GRAPH_BREADTH=3
-- LF_SINGLE_THREADED=1
-- LOG_LEVEL=2
-- NUMBER_OF_WATCHDOGS=0
-- LF_SOURCE_DIRECTORY="/home/nre/git/lf-3pi/src"
-- LF_SOURCE_GEN_DIRECTORY="/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay"
-- LF_PACKAGE_DIRECTORY="/home/nre/git/lf-3pi"
-- LF_FILE_SEPARATOR="/"
-- Configuring incomplete, errors occurred!
See also "/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/CMakeFiles/CMakeOutput.log".
See also "/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/CMakeFiles/CMakeError.log".
Pico W Bluetooth build support available.
lwIP available at /home/nre/git/lf-3pi/pico-sdk/lib/lwip
mbedtls available at /home/nre/git/lf-3pi/pico-sdk/lib/mbedtls
CMake Error at CMakeLists.txt:56 (target_link_libraries):
  Cannot specify link libraries for target "core" which is not built by this
  project.

Executing from lfc results in very similar errors.

@erlingrj
Copy link
Collaborator

Could you see if this PR fixes your problem? #2283

@NiklasRentzCAU
Copy link
Author

There are still issues after testing a manual build. I have not manually built LF before, so please verify that my build process was correct: I checked out your branch, made sure to update the git submodules via git submodule update --init --recursive and built the project with ./gradlew build. Then I unpacked the snapshot-CLI from the build/distributions folder and re-tried the compilation, now with this new error message after the same general configuration messages on the console:

-- Configuring incomplete, errors occurred!
See also "/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/CMakeFiles/CMakeOutput.log".
See also "/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/CMakeFiles/CMakeError.log".
TinyUSB available at /home/nre/git/lf-3pi/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at /home/nre/git/lf-3pi/pico-sdk/lib/btstack
cyw43-driver available at /home/nre/git/lf-3pi/pico-sdk/lib/cyw43-driver
Pico W Bluetooth build support available.
lwIP available at /home/nre/git/lf-3pi/pico-sdk/lib/lwip
mbedtls available at /home/nre/git/lf-3pi/pico-sdk/lib/mbedtls
CMake Error at robot-lib.txt:2 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "AccelerometerDisplay".  All uses of target_link_libraries with
  a target must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * CMakeLists.txt:70 (target_link_libraries)

Call Stack (most recent call first):
  CMakeLists.txt:88 (include)

Something in the CMakeLists.txt file still seems to be off, but I have never worked with it to really understand the message.

@erlingrj
Copy link
Collaborator

Yes, this build process works. An even more convenient way is to just use bin/lfc-dev. You can use that in place of lfc and what it does is to first call gradle and possibly recompiles itself if there are any changes in the repo.

The CMake error is because in our Cmake system we are now using PUBLIC/PRIVATE keywords when adding compile defs or linking targets. Can you try with this version of the lab: lf-lang/lf-3pi-template#5

@NiklasRentzCAU
Copy link
Author

Thanks for your quick support! Your PR solves that issue, but the next one is right around the corner. As the same compilation worked with 0.6.0, I assume the issue is not really that the pico/stdlib is not there, but some new configuration causes the compilation to not find it anymore.

(cutting to the relevant part)

--- Executing command: cmake --build . --target install --parallel 8 --config Debug
[  0%] Creating directories for 'PioasmBuild'
[  1%] Creating directories for 'ELF2UF2Build'
[  2%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  2%] Building C object core/CMakeFiles/lf-platform-impl.dir/__/platform/impl/platform.c.obj
[  2%] Building C object core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_rp2040_support.c.obj
[  2%] Building C object core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_platform_util.c.obj
[  3%] No download step for 'PioasmBuild'
[  4%] Building C object core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_atomic_irq.c.obj
[  4%] No download step for 'ELF2UF2Build'
[  4%] Linking ASM executable bs2_default.elf
[  4%] No update step for 'PioasmBuild'
[  5%] No update step for 'ELF2UF2Build'
[  5%] Built target bs2_default
[  6%] No patch step for 'PioasmBuild'
[  6%] No patch step for 'ELF2UF2Build'
[  6%] Performing configure step for 'PioasmBuild'
loading initial cache file /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/tmp/PioasmBuild-cache-Release.cmake
[  7%] Performing configure step for 'ELF2UF2Build'
In file included from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/low_level_platform.h:52,
                 from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/platform/impl/platform.c:13:
/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/platform/lf_rp2040_support.h:10:10: fatal error: pico/stdlib.h: No such file or directory
   10 | #include <pico/stdlib.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [core/CMakeFiles/lf-platform-impl.dir/build.make:76: core/CMakeFiles/lf-platform-impl.dir/__/platform/impl/platform.c.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1791: core/CMakeFiles/lf-platform-impl.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
In file included from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/impl/src/lf_rp2040_support.c:38:
/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/platform/lf_rp2040_support.h:10:10: fatal error: pico/stdlib.h: No such file or directory
   10 | #include <pico/stdlib.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [core/CMakeFiles/lf-low-level-platform-impl.dir/build.make:76: core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_rp2040_support.c.obj] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/low_level_platform.h:52,
                 from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/impl/src/lf_atomic_irq.c:12:
/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/platform/lf_rp2040_support.h:10:10: fatal error: pico/stdlib.h: No such file or directory
   10 | #include <pico/stdlib.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [core/CMakeFiles/lf-low-level-platform-impl.dir/build.make:90: core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_atomic_irq.c.obj] Error 1
In file included from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/low_level_platform.h:52,
                 from /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/impl/src/lf_platform_util.c:1:
/home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/low_level_platform/api/platform/lf_rp2040_support.h:10:10: fatal error: pico/stdlib.h: No such file or directory
   10 | #include <pico/stdlib.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [core/CMakeFiles/lf-low-level-platform-impl.dir/build.make:104: core/CMakeFiles/lf-low-level-platform-impl.dir/__/low_level_platform/impl/src/lf_platform_util.c.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1765: core/CMakeFiles/lf-low-level-platform-impl.dir/all] Error 2
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting CXX compiler ABI info
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/pioasm
-- Detecting C compiler ABI info - done
[  8%] Performing build step for 'PioasmBuild'
-- Check for working C compiler: /nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
[ 20%] Building CXX object CMakeFiles/pioasm.dir/main.cpp.o
[ 20%] Building CXX object CMakeFiles/pioasm.dir/pio_assembler.cpp.o
[ 30%] Building CXX object CMakeFiles/pioasm.dir/pio_disassembler.cpp.o
[ 40%] Building CXX object CMakeFiles/pioasm.dir/gen/lexer.cpp.o
[ 50%] Building CXX object CMakeFiles/pioasm.dir/gen/parser.cpp.o
[ 60%] Building CXX object CMakeFiles/pioasm.dir/c_sdk_output.cpp.o
[ 70%] Building CXX object CMakeFiles/pioasm.dir/python_output.cpp.o
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nre/git/lf-3pi/src-gen/AccelerometerDisplay/build/elf2uf2
[  8%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
[ 80%] Building CXX object CMakeFiles/pioasm.dir/hex_output.cpp.o
[ 90%] Building CXX object CMakeFiles/pioasm.dir/ada_output.cpp.o
[100%] Linking CXX executable elf2uf2
[100%] Built target elf2uf2
[  8%] No install step for 'ELF2UF2Build'
[  9%] Completed 'ELF2UF2Build'
[  9%] Built target ELF2UF2Build
[100%] Linking CXX executable pioasm
[100%] Built target pioasm
[  9%] No install step for 'PioasmBuild'
[  9%] Completed 'PioasmBuild'
[  9%] Built target PioasmBuild
gmake: *** [Makefile:136: all] Error 2
lfc: error: CMake failed with error code 2
lfc: error: Compilation was unsuccessful.
lfc: fatal error: Aborting due to 2 previous errors.

@lhstrh
Copy link
Member

lhstrh commented May 17, 2024

Also getting

_rp2040_support.h:10:10: fatal error: pico/stdlib.h: No such file or directory
   10 | #include <pico/stdlib.h>
      |          ^~~~~~~~~~~~~~~

@NiklasRentzCAU
Copy link
Author

In our run of the lab we also want to show some of the newer layout-related features present since version 0.7.0, but this issue is preventing us from switching to 0.7.x for the robots. Can someone help us out here?

@edwardalee
Copy link
Collaborator

I'm trying to help here, despite finding cmake to be a total mystery, but I ran into other problems. First, I've issued a PR (lf-lang/reactor-c#440) that fixes erroneous CMake syntax. But this just took me to this problem:

$ lfc-dev src/AccelerometerDisplay.lf
lfc: info: Generating code for: file:/Users/edwardlee/git/lf-3pi-template/src/AccelerometerDisplay.lf
...
CMake Error at CMakeLists.txt:51 (target_link_libraries):
  Cannot specify link libraries for target "core" which is not built by this
  project.

Suggestions for how to get past this problem?

@erlingrj
Copy link
Collaborator

I believe this issues should have been addressed by Samules recent merges to lingua-franca and reactor-c. The fix in your PR, Edward, is not related to the error reported here

@erlingrj
Copy link
Collaborator

@NiklasRentzCAU could you try out latest version of lingua-franca and do git submodule update

@NiklasRentzCAU
Copy link
Author

I updated my master branch and the submodule and built the project as above, now yet another issue shows up during compilation:

CMake Error at low_level_platform/impl/CMakeLists.txt:64 (if):
  if given arguments:

    "DEFINED" "NUMBER_OF_WORKERS" "AND" "GREATER" "2"

  Unknown arguments specified
Call Stack (most recent call first):
  core/CMakeLists.txt:90 (include)

The related CMakeLists.txt file in src-gen/AccelerometerDisplay/low_level_platform/impl/CMakeLists.txt:64 around that line is generated to look like this:

    if (DEFINED NUMBER_OF_WORKERS AND ${NUMBER_OF_WORKERS} GREATER 2)
        message(FATAL_ERROR "RP2040 can have at most 2 workers (one per core).\
            Number of requested workers is ${NUMBER_OF_WORKERS}.")
    endif()

I did not add any property related to the number of workers in the C target declaration, only the usual single-threaded: true line, if that is related.

@edwardalee
Copy link
Collaborator

This issue is fixed in lf-lang/reactor-c#440.

@edwardalee
Copy link
Collaborator

I have issued two more PRs, one in lingua-franca and one in reactor-c. Together with @erlingrj 's fix in lf-3pi-template, I was able to get the AccelerometerDisplay.lf program to compile.

@lhstrh
Copy link
Member

lhstrh commented May 31, 2024

@edwardalee, you mention https://github.com/lf-lang/lf-3pi-template/pull/5/files but that's a draft PR which doesn't pass the tests. I don't get the full picture here. Could it be that there is a circular dependency in the tests not passing?

@edwardalee
Copy link
Collaborator

I don't understand CMake well enough to be able to explain this magic, but the code does not compile without the change in https://github.com/lf-lang/lf-3pi-template/pull/5/files. I've gone ahead and pushed this change to main and closed the draft PR. I would not expect the tests to pass because building rp2040 code is broken with changes needed in both lingua-franca master and reactor-c.

@NiklasRentzCAU
Copy link
Author

NiklasRentzCAU commented Jun 3, 2024

@edwardalee Thank you, you fixes also solve all compilation problems on my machine as well. Tomorrow I can test if the compiled program actually executes correctly on the Pololu robots as well, but this looks promising.

edit: this works on the robot in the latest nightly build of the extension, this issue may be closed.

@lhstrh lhstrh closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants