-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
cmake: use the warnings_as_errors flag for cpp files #78419
cmake: use the warnings_as_errors flag for cpp files #78419
Conversation
and now to all those build issues we missed previous and exposed through this change.... |
@fabiobaltieri would you like me to make these fixes in the tree? |
That'd be cool if you have time, I'm out for the next couple of days. |
Just noticed this is a duplicate of #69226 |
Thanks @nordicjm, borrowed some commits from there and added few more, still not done though but I could use a CI run, moving back to draft. |
2471799
a4bdf0a
to
2471799
Compare
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.
cpp changes look fine
@@ -63,13 +63,13 @@ struct z_device_mmio_rom { | |||
|
|||
#define Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) \ | |||
{ \ | |||
.phys_addr = DT_REG_ADDR(node_id), \ | |||
.phys_addr = UINT32_C(DT_REG_ADDR(node_id)), \ |
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.
tempted to have this as part of DT_REG_ADDR
(and potentially DT_REG_SIZE
too) macro itself but that would be a substantial change, definitely worth its own PR, I propose to patch this one up for now. Somewhat surprised CI does not hit more cases of this warning though.
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.
This looks really odd to me offhand, is the ADDR a 32 bit unsigned or not? If it is, then the DT macro should ensure that's the type being provided. If its not, then .phys_addr should have its type corrected. This looks a bit like a quick fix at the wrong place.
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.
it's a quick fix, that's pretty much what I meant in the comment above
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.
Please create an issue for this then, if its meant to be revisited
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.
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.
@jeppenodgaard what was wrong with that? CI errors? I was considering giving it a go as well
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.
@fabiobaltieri see this closing comment:
#70761 (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.
Some answers I think are needed for some of the more suspicious changes to appease the compiler, or perhaps some inline comments for the really odd ones (void)foo; looks like a no-op
@@ -63,13 +63,13 @@ struct z_device_mmio_rom { | |||
|
|||
#define Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) \ | |||
{ \ | |||
.phys_addr = DT_REG_ADDR(node_id), \ | |||
.phys_addr = UINT32_C(DT_REG_ADDR(node_id)), \ |
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.
This looks really odd to me offhand, is the ADDR a 32 bit unsigned or not? If it is, then the DT macro should ensure that's the type being provided. If its not, then .phys_addr should have its type corrected. This looks a bit like a quick fix at the wrong place.
@@ -42,7 +42,7 @@ struct i2c_target_callbacks emulated_callbacks[FORWARD_COUNT] = { | |||
DT_FOREACH_PROP_ELEM(CONTROLLER_LABEL, forwards, DEFINE_EMULATED_CALLBACK)}; | |||
|
|||
#define DEFINE_EMULATED_TARGET_CONFIG(node_id, prop, n) \ | |||
[n] = { \ | |||
{ \ |
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.
This looks like its doing something completely different than it was before? Confused by this change, why is "[n] = " no longer needed, why was it needed before?
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.
no idea why it was introduced originally, I guess to do something with that n
variable? regardless, the compiler does not like it, the alternative would be to shut off that warning, happy with either. @yperess?
f783f3b
to
333a11a
Compare
Fix a type mismatch compiler warning in the c++ tests. Signed-off-by: Yuval Peress <peress@google.com> Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Dropped the XS tag as its a bit more than one line, hopefully no one is offended by this. |
Add a dummy byte to struct mspi_timing_cfg, for C++ compatibility, same as what's done in include/zephyr/arch/structs.h, include/zephyr/arch/arm/structs.h, include/zephyr/kernel/thread.h and others. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix the compiler error: comparison of integer expressions of different signedness: ‘const int’ and ‘unsigned int’ Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
On some architecture (qemu_x86) this tests generate an unused reference warning for the PM device structure, as nothing in the structure macro definition is referencing itself. Reference the struct in the device define, keep the compiler happy. Also change one of the device priority to dodge a '__device_dts_ord_8' causes a section type conflict with '__device_dts_ord_9' error with llvm. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Drop the array dasignators as they generate a warning: array designators are a C99 extension warning when compiling with clang. Not too sure if this is an actual problem or if the warning should be disabled instead but since it's just a test it should be fine to just drop them. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add an explicit unsigned literal suffix (U) for addresses obtained from devicetree, this is to work around a specific warning: zephyrproject/zephyr/include/zephyr/arch/arm/cortex_a_r/timer.h:40:2: warning: this decimal constant is unsigned only in ISO C90 When compling west build -p -b qemu_cortex_a9 -T tests/lib/cpp/cxx/cpp.main.cpp98 Argueably all devicetree addresses and sizes should be unsigned but this is enough to make CI pass, may look into changing the device.h macro as a followup. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
C++ file compilation is actually missing the warning-as-error handling, causing warnings in build files to be unnoticed in CI. Add a flag to handle them as well. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Ok this is interesting now: $ export ZEPHYR_TOOLCHAIN_VARIANT=llvm
$ west build -p -b native_sim -T tests/lib/cpp/cxx/cpp.main.minimal
...
zephyr/tests/lib/cpp/cxx/src/main.cpp:154:1: error: '__device_dts_ord_8' causes a section type conflict with '__device_dts_ord_9' Only on LLVM, seems to not like the two devices one with PM data one without at the same priority, this is the expanded definition if anyone wants to have a go at figuring what is going on static __attribute__((__aligned__(__alignof(struct device_state)))) struct device_state __devstate_dts_ord_9 __attribute__((__section__(".z_devstate"))); static_assert(sizeof("\"dev1\"") <= 48U, "" "DEVICE_NAME_GET(\"dev1\")" " too long"); static const struct device_dt_nodelabels __dev_dt_nodelabels_dts_ord_9 = { .num_nodelabels = 1, .nodelabels = { "test_dev1_dfr", }, }; static const struct device_dt_metadata __dev_dt_meta_dts_ord_9 = { .nl = &__dev_dt_nodelabels_dts_ord_9, };; const __attribute__((__aligned__(__alignof(struct device)))) struct device __device_dts_ord_9 __attribute__((section("." "_device" "." "static" "." "3_33_"))) __attribute__((__used__)) = { .name = "dev1", .config = (__null), .api = (__null), .state = (&__devstate_dts_ord_9), .data = (__null), .pm_base = (__null), .dt_meta = &__dev_dt_meta_dts_ord_9, }; static const __attribute__((__aligned__(__alignof(struct init_entry)))) struct init_entry __attribute__((__used__)) __attribute__((__section__(".z_deferred_init"))) __init___device_dts_ord_9 = { .init_fn = {.dev = (__null)}, .dev = &__device_dts_ord_9, };;
static int fake_pm_action(const struct device *dev,
enum pm_device_action pm_action) { return -1; }
; static struct pm_device __pm_device_dts_ord_8 = { .base = { .flags = (((0 << PM_DEVICE_FLAG_WS_CAPABLE) | (0 << PM_DEVICE_FLAG_RUNTIME_AUTO) | (0 << PM_DEVICE_FLAG_PD)) | (0 ? (1UL << (PM_DEVICE_FLAG_ISR_SAFE)) : 0)), .state = PM_DEVICE_STATE_ACTIVE, .action_cb = fake_pm_action, .domain = __null, }, .lock = { .wait_q = { { {(&(&(__pm_device_dts_ord_8.lock).wait_q)->waitq)}, {(&(&(__pm_device_dts_ord_8.lock).wait_q)->waitq)} } }, .count = (1), .limit = (1), }, .event = { .wait_q = { { {(&(&__pm_device_dts_ord_8.event.wait_q)->waitq)}, {(&(&__pm_device_dts_ord_8.event.wait_q)->waitq)} } }, .events = 0 }, };
static __attribute__((__aligned__(__alignof(struct device_state)))) struct device_state __devstate_dts_ord_8 __attribute__((__section__(".z_devstate"))); static_assert(sizeof("\"dev0\"") <= 48U, "" "DEVICE_NAME_GET(\"dev0\")" " too long"); static const struct device_dt_nodelabels __dev_dt_nodelabels_dts_ord_8 = { .num_nodelabels = 1, .nodelabels = { "test_dev0_boot", }, }; static const struct device_dt_metadata __dev_dt_meta_dts_ord_8 = { .nl = &__dev_dt_nodelabels_dts_ord_8, };; const __attribute__((__aligned__(__alignof(struct device)))) struct device __device_dts_ord_8 __attribute__((section("." "_device" "." "static" "." "3_33_"))) __attribute__((__used__)) = { .name = "dev0", .config = (__null), .api = (__null), .state = (&__devstate_dts_ord_8), .data = (__null), .pm_base = (((struct pm_device_base *)&__pm_device_dts_ord_8)), .dt_meta = &__dev_dt_meta_dts_ord_8, }; static const __attribute__((__aligned__(__alignof(struct init_entry)))) struct init_entry __attribute__((__used__)) __attribute__((__section__( ".z_init_" "POST_KERNEL" "33""_" "00008""_"))) __init___device_dts_ord_8 = { .init_fn = {.dev = (__null)}, .dev = &__device_dts_ord_8, };; I'll change the priority for now, no doubt it'll come to bite me back down the road anyway. |
333a11a
to
66a71f3
Compare
Dug a bit more, seems like having that field set moves the device structure from rodata to data, with different prio and no pm:
with pm:
no idea why it's doing that, does not look right to me but I'll just add it to the ever growing list of c++ stuff I don't understand. |
Unsolved Mysteries of C++, maybe one of the people who wished to add C++ can help here, I have no idea either. |
Yeah, anyway CI seems to be happy again so at least the workarounds are working around. |
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.
Noted issue exists for the unsigned dt stuff, all other mysterious things look better. Seems good to me.
C++ file compilation is actually missing the warning-as-error handling, causing warnings in build files to be unnoticed in CI. Add a flag to handle them as well.
Fixes #78348
Pushed on https://github.com/zephyrproject-rtos/zephyr-testing/tree/vfabio-testing-branch as well