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

[Backport v1.14-branch] C++: fix builds with non-Zephyr toolchain #18552

Merged
merged 3 commits into from
Sep 25, 2019

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Aug 21, 2019

This backports the change and test case from #18242, which will close #15603 in the original poster's context of 1.14.

@pabigot pabigot added area: Tests Issues related to a particular existing or missing test area: C++ labels Aug 21, 2019
@zephyrbot zephyrbot added area: C Library C Standard Library area: Test Framework Issues related not to a particular test, but to the framework instead labels Aug 21, 2019
@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 21, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Background from issue zephyrproject-rtos#17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

Backport: c0d3397
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <[email protected]>
The solution from zephyrproject-rtos#14312 of using -isystem to prioritize the position of
the libc directory bypasses the effect of -ffreestanding with respect to
libc symbols expected to be present in a non-hosted environment.

Further, it breaks C++ with the ARM Embedded toolchain as the system
fails to find the right file with #include_next.

Use a more fine-grained solution that explicitly includes the underlying
newlib header required for <inttypes.h> support before moving on to
include the next available one, whether system or non-system.

Closes zephyrproject-rtos#17564

Backport: 96c1b05
Signed-off-by: Peter Bigot <[email protected]>
Confirms build (and run) of C++17 applications that make use of STL
containers and other features.

Backport: aded6a5
Signed-off-by: Peter Bigot <[email protected]>
@pabigot pabigot added this to the v1.14.1 milestone Sep 17, 2019
@nashif nashif merged commit 3d18496 into zephyrproject-rtos:v1.14-branch Sep 25, 2019
@pabigot pabigot deleted the backport/18242 branch September 30, 2019 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C Library C Standard Library area: C++ area: Test Framework Issues related not to a particular test, but to the framework instead area: Tests Issues related to a particular existing or missing test
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants