Skip to content

CMake: fix application config #13799

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

Merged
merged 1 commit into from
Oct 23, 2020

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented Oct 22, 2020

Summary of changes

These settings like enable_language should be done in the application and just once.
We hit the issue when you expose sources to an app (interface or public), CMake errors as some of the internal settings have not been configured.

From the CMake docs for enable_language:

This command must be called in file scope, not in a function call. Furthermore, it must be called in the highest directory common to all targets using the named language directly for compiling sources or indirectly through link dependencies. It is simplest to enable all needed languages in the top-level directory of a project.

This is why it should be in the top project (application). Not mbed-os target as it was previously. We found some issue with the previous setup.

There might be another way to fix it, open for discussion.

The bareminimum would be in the app enable_language(C CXX ASM) . However this setup compilers and there should be properly set up via cmake toolchain file (or not?).

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[x] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


These settings like enable_language should be done in the application and just once.
We hit the issue when you expose sources to an app (interface or public), CMake errors as some of the internal settings have not been configured.
@ciarmcom
Copy link
Member

@0xc0170, thank you for your changes.
@ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested a review from a team October 22, 2020 08:00
@0xc0170 0xc0170 requested review from hugueskamba and rajkan01 and removed request for a team October 22, 2020 08:02
Copy link
Collaborator

@hugueskamba hugueskamba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try this with a modified Blinky application? If so, can you provide a link to the branch you used? With what I showed you before, I also had to call everything except for enable language in Mbed OS.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Oct 22, 2020

Yes, the only change in the app to do is to add include(${MBED_ROOT}/tools/cmake/app.cmake).

Please test with your minimal blinky. I tested .S files being added to the app, no error given(the only error you get if you use public for a file that is part of Mbed OS, as it would be copied to an app as well - duplicated symbols errors then).

@hugueskamba
Copy link
Collaborator

Yes, the only change in the app to do is to add include(${MBED_ROOT}/tools/cmake/app.cmake).

Please test with your minimal blinky. I tested .S files being added to the app, no error given(the only error you get if you use public for a file that is part of Mbed OS, as it would be copied to an app as well - duplicated symbols errors then).

I ported your changes to https://github.com/hugueskamba/mbed-os/tree/hk_cmake_mbed-os-rtos and used it with https://github.com/hugueskamba/mbed-os-example-blinky/tree/hk_cmake_mbed-os-rtos.

I had to do the following in the app:

target_link_libraries(${APP_TARGET}
    PRIVATE
        mbed-os
    INTERFACE
        mbed-os-rtos
)

Other wise I get duplicated symbols because I am guessing some are weak symbols and they are both included instead of selecting just the strong one.

Warning: L3912W: Option 'legacyalign' is deprecated.
Warning: L6439W: Multiply defined Global Symbol software_init_hook_rtos defined in .text.software_init_hook_rtos(CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/source/mbed_boot.o) rejected in favor of Symbol defined in .text.software_init_hook_rtos(mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Warning: L6439W: Multiply defined Global Symbol mbed_main defined in .text.mbed_main(CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/source/mbed_boot.o) rejected in favor of Symbol defined in .text.mbed_main(mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Error: L6200E: Symbol os_cb_sections multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_lib.o and mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Error: L6200E: Symbol osThreadFlagsSet multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_thread.o and mbed-os/CMakeFiles/mbed-os.dir/rtos/source/ThisThread.o).
Error: L6200E: Symbol mbed_init multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/source/mbed_boot.o and mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Error: L6200E: Symbol mbed_stack_isr_start multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/source/mbed_boot.o and mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Error: L6200E: Symbol mbed_stack_isr_size multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/source/mbed_boot.o and mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Error: L6200E: Symbol mbed_toolchain_init multiply defined (by CMakeFiles/mbed-os-example-blinky.dir/mbed-os/cmsis/device/rtos/TOOLCHAIN_ARM_STD/mbed_boot_arm_std.o and mbed-os/CMakeFiles/mbed-os.dir/platform/source/mbed_sdk_boot.o).
Not enough information to list the image map.
Finished: 1 information, 3 warning and 6 error messages.
ninja: build stopped: subcommand failed.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Oct 23, 2020

Waiting until we get the name fixing in the CMake, and lets see what we need

@hugueskamba
Copy link
Collaborator

I have this PR for Blinky: ARMmbed/mbed-os-example-blinky#244

@0xc0170 0xc0170 merged commit 37f4670 into ARMmbed:feature-cmake Oct 23, 2020
@0xc0170 0xc0170 deleted the feature-cmake-fix-app-config branch October 23, 2020 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants