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
r13804 breaks C++ builds Topic is solved
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: r13804 breaks C++ builds
No idea, those functions are required in syscall.c, I think those should not be used together.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: r13804 breaks C++ builds
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
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
Re: r13804 breaks C++ builds
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
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
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: r13804 breaks C++ builds
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
Could you try to include just syscalls.c and see if everything is OK? if so then I will make the change permanent.
Giovanni
Re: r13804 breaks C++ builds
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:
- Thomas
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.
Code: Select all
/* C stubs */
#if defined(__cplusplus)
/* C++ stubs */
#endif
- Thomas
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
- stertingen
- Posts: 21
- Joined: Mon Jan 13, 2020 10:55 pm
- Has thanked: 7 times
- Been thanked: 7 times
Re: r13804 breaks C++ builds
Removed the duplicate functions from syscalls_cpp.cpp.
- Attachments
-
- fix-cpp-linking.zip
- (558 Bytes) Downloaded 548 times
Re: r13804 breaks C++ builds
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.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: r13804 breaks C++ builds
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
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