-
Notifications
You must be signed in to change notification settings - Fork 168
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
Feat/weak attribute #47
Conversation
Could I ask you why does need the attribute((weak)) symbol ? |
Hi! I tried to reason the need in issue 43 . In short, i have a set of files (generated), that define fake functions for all real functions. This is compiled to be library -- say "libfake.a". Now when linking a test binary, i have maybe one or two real functions, and this binary is linked against the fakelib (i have many of those binaries - one for each set of real functions!). Now without the weak one gets linker error -- the real function is defined also in fakelib. With weak linker is instructed to select the other one with no error. I could surely pick the files for compiling, but that would require additional "makefile"-logic -- now i can compile the whole fakelib once, and let the linker select suitable implementation for required functions. |
I am a bit reluctant to merge this one...
|
Then users could include fff.h to turn on the option:
|
@susundberg, please resolve your conflicts before review moves forward. |
d7a3b96
to
97f3210
Compare
❌ Build fff 23-appveyor failed (commit a90dd84fe2 by @susundberg) |
97f3210
to
e041371
Compare
✅ Build fff 24-appveyor completed (commit 1de1f05c54 by @susundberg) |
Hi! Sorry for long delay. I (force) pushed new update; i replaced the hardcoded I updated also the generated fff.h but there seems to be whitespace differences also on unmodified master. I am running ubuntu 18.04 with
Any suggestions what version to use (and maybe add that to readme?). |
@susundberg, the only whitespace changes I can see in your PR are good ones. It looks like you've used your editor to strip them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@susundberg, before I go ahead and do anything, can you please add some test cases?
Hi! Sorry for the delay again. I actually did checked out the tests before making the pull request but decided not to go there since it was not clear me how they are structured etc. I now went back to look how it goes - and would an examples/weak_linking/ with some tests included be sufficient? Happy holidays! |
Just define an example weak function and fake it, as was the need for this
functionality.
On 21 Dec. 2018 1:01 am, "Pauli Salmenrinne" <notifications@github.com> wrote:
Hi! Sorry for the delay again. I actually did checked out the tests before
making the pull request but decided not to go there since it was not clear
me how they are structured etc.
I now went back to look how it goes - and would an examples/weak_linking/
with some tests included be sufficient?
Happy holidays!
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#47 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA6TtLl_9eB5jkvCxAuuW-DBaX14NIPNks5u65gtgaJpZM4TBg_E>
.
|
e041371
to
799d64d
Compare
✅ Build fff 41-appveyor completed (commit 88b177b41e by @susundberg) |
Uh sorry, ignore, force pushed after pulling to latest, examples still missing .. |
…attributes for functions. More specifically, allow __weak__ attribute.
799d64d
to
18af3ae
Compare
✅ Build fff 42-appveyor completed (commit 20af33657d by @) |
18af3ae
to
489ea3d
Compare
✅ Build fff 43-appveyor completed (commit 767dbfaa3f by @) |
489ea3d
to
2848c81
Compare
✅ Build fff 44-appveyor completed (commit 7818963220 by @) |
2848c81
to
0a7fbec
Compare
✅ Build fff 45-appveyor completed (commit cdb6a8c5c2 by @) |
Hi all again. I took a while but i added an example "weak_linking". Its compiled and runned on the normal command. The example itself is silly - as you can guess - but the Makefile includes three example cases where weak linking is required. I did not make any (automatic) check that the compiling fails if the weak linking flag is not set. I did try manually though. How does it look? |
@@ -26,6 +26,13 @@ def output_constants | |||
putd "#define FFF_CALL_HISTORY_LEN (#{$MAX_CALL_HISTORY}u)" | |||
} | |||
putd "#endif" | |||
# If user has defined functions to have some attributes, use those. If not, define as empty so it wont affect others. | |||
putd "#ifndef FFF_FUNCTION_ATTRIBUTES" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather this be named:
FFF_GCC_FUNCTION_ATTRIBUTES
commit e5a5749 Author: James Fraser <wulfgar.pro@gmail.com> Date: Sun Feb 3 19:57:31 2019 +1100 PR #47: Minor review fixes to tests files. commit e9f11b9 Author: James Fraser <wulfgar.pro@gmail.com> Date: Sun Feb 3 19:57:04 2019 +1100 PR #47: Minor review fixes. commit 0a7fbec Author: Pauli Salmenrinne <pauli.salmenrinne@pexraytech.com> Date: Tue Jan 22 15:11:10 2019 +0200 Add example for the weak linking commit 6477373 Author: susundberg <susundberg@gmail.com> Date: Wed Mar 21 13:14:05 2018 +0200 Add "FFF_FUNCTION_ATTRIBUTES" definition that can be used to declare attributes for functions. More specifically, allow __weak__ attribute.
@susundberg, see merge 0b9e9f5. Thank you for the contribution. |
Hi!
Here is pull request for issue #43. I have tested it only with gcc (i guess clang will be tested with the CI) - and used in my own project.