-
Notifications
You must be signed in to change notification settings - Fork 94
fix error implicit declaration of ltimer functions #195
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
Conversation
|
So to me it seems the real fix for sel4test Cheshire builds is to unset |
Yes; it turns link time errors into compile time errors. But in this case I'm turning a compile time error (because of an implicit function declaration) into no compile time error (because the I could remove the Why I did it this way is that I am essentially removing the
No, it already does. This underlying issue is this issue. |
Okay.
That seems better to me than having those ugly attributes everywhere. If you get link errors for ltimer functions it is clear that the platform doesn't support them, saying the same at compile time doesn't help in figuring out why not. But that's my opinion, no strong feelings about this.
Well, you said "Instead, use The problem for me was the emphasis on I'd have done your initial problem description + say what the fix is, but then explain why instead of reverting, you add the error attribute. |
108ccd7 to
afcc52f
Compare
|
I've rewritten the commit message now, hopefully it should be a bit clearer. |
Indanz
left a comment
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.
0cd54a6 to
cddcbec
Compare
Signed-off-by: julia <git.ts@trainwit.ch>
When a platform does not have `CONFIG_LIB_PLAT_SUPPORT_HAVE_TIMER` set, we _were_ removing the declaration of `ltimer_default_init` since seL4#193. This was because there was also no definition and so caused a linker error anyway, so I thought it wouldn't matter if it was defined or not. This was fine for sel4bench uses, as we used `#ifdef` to remove the callers of `ltimer_default_init` when there was no timer. However, this broke sel4test: seL4/ci-actions#411 for Cheshire, as whilst sel4test had its CONFIG_HAVE_TIMER disabled, the compiler still saw a call to `ltimer_default_init`: /sel4test/apps/sel4test-driver/src/main.c: In function ‘init_timer’: /sel4test/apps/sel4test-driver/src/main.c:180:17: error: implicit declaration of function ‘ltimer_default_init’ 180 | error = ltimer_default_init(&env.ltimer, env.ops, NULL, NULL); | ^~~~~~~~~~~~~~~~~~~ The implementation of sel4test has: if (config_set(CONFIG_HAVE_TIMER)) { int error; error = ltimer_default_init(&env.ltimer, env.ops, NULL, NULL); ZF_LOGF_IF(error, "Failed to setup the timers"); /* ... */ } When `ltimer_default_init` was still declared, the compiler would elide the link to the `ltimer_default_init` symbol and so it would compile fine, as `CONFIG_HAVE_TIMER`` is a compile-time constant. This commit undoes this change, and leaves `ltimer_default_init` always declare, unbreaking the sel4test builds when there is no timer. In addition, we add `__attribute__((error(msg)))` to the declaration of `ltimer_default_init` conditionally. This is documented by both GCC [1] and by Clang [2] to only fire if it can't be elided with compile-time optimisations. This is then fine for sel4bench (function call `#ifdef` out entirely) and sel4test (`CONFIG_HAVE_TIMER` is compile-time known). We were implicitly relying on the compiler to elide the link against `ltimer_default_init` based on the compile-time constant anyway; so this doesn't make the builds any more reliant on compiler optimisations. As a demonstration of the diagnostic emitted if sel4test doesn't disable the timer tests when the platform has no timer, the following error is emitted during builds: /sel4test/apps/sel4test-driver/src/main.c:180:17: error: call to ‘ltimer_default_init’ declared with attribute error: no ltimer support for this platform 180 | error = ltimer_default_init(&env.ltimer, env.ops, NULL, NULL); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This should hopefully be much clearer than a link-time failure. [1]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html [2]: https://clang.llvm.org/docs/AttributeReference.html#error-warning Signed-off-by: julia <git.ts@trainwit.ch>
cddcbec to
c49ddd7
Compare
Depends on #197 to be merged first.
When a platform does not have
CONFIG_LIB_PLAT_SUPPORT_HAVE_TIMERset,we were removing the declaration of
ltimer_default_initsince #193.This was because there was also no definition and so caused a linker
error anyway, so I thought it wouldn't matter if it was defined or not.
This was fine for sel4bench uses, as we used
#ifdefto remove thecallers of
ltimer_default_initwhen there was no timer. However,this broke sel4test: seL4/ci-actions#411 for
Cheshire, as whilst sel4test had its CONFIG_HAVE_TIMER disabled, the
compiler still saw a call to
ltimer_default_init:The implementation of sel4test has:
When
ltimer_default_initwas still declared, the compiler would elidethe link to the
ltimer_default_initsymbol and so it would compilefine, as `CONFIG_HAVE_TIMER`` is a compile-time constant.
This commit undoes this change, and leaves
ltimer_default_initalwaysdeclare, unbreaking the sel4test builds when there is no timer.
In addition, we add
__attribute__((error(msg)))to the declaration ofltimer_default_initconditionally. This is documented by both GCC 1and by Clang 2 to only fire if it can't be elided with compile-time
optimisations. This is then fine for sel4bench (function call
#ifdefout entirely) and sel4test (
CONFIG_HAVE_TIMERis compile-time known).We were implicitly relying on the compiler to elide the link against
ltimer_default_initbased on the compile-time constant anyway; so thisdoesn't make the builds any more reliant on compiler optimisations.
As a demonstration of the diagnostic emitted if sel4test doesn't disable
the timer tests when the platform has no timer, the following error is
emitted during builds:
This should hopefully be much clearer than a link-time failure.