r13804 breaks C++ builds

Report here problems in any of ChibiOS components. This forum is NOT for support.
Thargon
Posts: 118
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 12 times
Been thanked: 21 times
Contact:

r13804 breaks C++ builds

Postby Thargon » Wed Aug 19, 2020 12:19 pm

Commit 13804 (https://osdn.net/projects/chibios/scm/svn/commits/13804) introduced some functions in syscalls.c, which are already present in syscalls_cpp.cpp. As a result, building any project which requires both files to be built will no longer compile.

In case this is actually no bug, I am curious about why those stubs needed to be added to syscalls.c?
Is the syscalls C++ wrapper now deprecated (but function definitions differ between C++ and C) or should it be used in a different way?

Regards
Thomas

User avatar
Giovanni
Site Admin
Posts: 13807
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 796 times
Contact:

Re: r13804 breaks C++ builds

Postby Giovanni » Wed Aug 19, 2020 12:33 pm

No idea, those functions are required in syscall.c, I think those should not be used together.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 13807
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 796 times
Contact:

Re: r13804 breaks C++ builds

Postby Giovanni » Sat Sep 12, 2020 2:30 pm

Hi,

Back on this, question, in which case is syscalls_cpp actually needed? all those stubs are already present in syscalls.c. Probably syscalls_cpp should just be removed and replaced with an inclusion of syscalls.c.

Giovanni

Thargon
Posts: 118
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 12 times
Been thanked: 21 times
Contact:

Re: r13804 breaks C++ builds

Postby Thargon » Mon Sep 14, 2020 8:33 am

syscalls_cpp.cpp was needed for C++ builds, obviously. It should be fine to implement all stubs in syscalls.c since the footprint for the unused functions in C builds is minimal and even zero if LTO is enabled. Maybe the preprocessor can be used to filter not required stubs (#ifdef __cplusplus), but I am not sure, if this might break at some point.

As I pointed out in my original post, however, implementations of the 'new' stubs in syscalls.c differ from the 'old' ones in syscalls_cpp.cpp. I wonder if this is intended, but I honestly do not have enough background knowledge on stubs to comment on this.

- Thomas

User avatar
Giovanni
Site Admin
Posts: 13807
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 796 times
Contact:

Re: r13804 breaks C++ builds

Postby Giovanni » Mon Sep 14, 2020 9:59 am

I think those should be equivalent, the files were done by 2 different persons.

Could you try to include just syscalls.c and see if everything is OK? if so then I will make the change permanent.

Giovanni

Thargon
Posts: 118
Joined: Wed Feb 04, 2015 5:03 pm
Location: CITEC, Bielefeld University, germany
Has thanked: 12 times
Been thanked: 21 times
Contact:

Re: r13804 breaks C++ builds

Postby Thargon » Tue Sep 15, 2020 7:37 am

I ran some brief tests using the latest commit of the stable_20.3.x branch on a NUCLEO-F401RE, a NUDLEO-L476RG and a custom board (F405RG) and everything seems to be okay.

The implementations, however, are not equivalent:
  • _exit() calls abort() (abnormal program termination) now, whereas the old implementation 'terminated' in an infinite loop.
  • _kill() now just returns -1, whereas the old implementation set an global ERRNO status value.
  • Several stubs that were defined before have now been removed entirely.
Furthermore, the C++ relevant stubs in the new implementation are always present - even for C builds. This could be optimized by simply guarding that part of the file:

Code: Select all

  /* C stubs */
#if defined(__cplusplus)
  /* C++ stubs */
#endif

- Thomas

User avatar
Giovanni
Site Admin
Posts: 13807
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 796 times
Contact:

Re: r13804 breaks C++ builds

Postby Giovanni » Sat Feb 13, 2021 10:26 am

bump

could anyone look into this?

User avatar
stertingen
Posts: 21
Joined: Mon Jan 13, 2020 10:55 pm
Has thanked: 7 times
Been thanked: 7 times

Re: r13804 breaks C++ builds

Postby stertingen » Wed Aug 25, 2021 8:27 pm

Removed the duplicate functions from syscalls_cpp.cpp.
Attachments
fix-cpp-linking.zip
(558 Bytes) Downloaded 31 times

dflogeras
Posts: 197
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 3 times
Been thanked: 16 times

Re: r13804 breaks C++ builds

Postby dflogeras » Wed Oct 13, 2021 1:35 am

I had to do the same in order to link a c++ program with 21.6.0. Removing, or marking the offending duplicate functions with __attribute__((__weak__)) works for me as well.

User avatar
Giovanni
Site Admin
Posts: 13807
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 934 times
Been thanked: 796 times
Contact:

Re: r13804 breaks C++ builds

Postby Giovanni » Thu Oct 21, 2021 11:05 am

Hi,

I removed the syscalls_cpp.* files (in trunk), now the wrapper includes the normal syscalls.c file. Could you retest the current wrapper? my demo is not failing but something could still be missing.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests