Skip to content

Silence trivial warnings#305

Merged
pjaaskel merged 23 commits intocpc:mainfrom
gtkiku:warnings
Feb 16, 2026
Merged

Silence trivial warnings#305
pjaaskel merged 23 commits intocpc:mainfrom
gtkiku:warnings

Conversation

@gtkiku
Copy link
Contributor

@gtkiku gtkiku commented Feb 12, 2026

Currently, with at least gcc >= 14, a couple thousand lines of trivally fixable warnings are emitted when doing a full rebuild. This PR fixes the majority of them, and the full stderr log for a clean build now looks like the following (on my machine, at least):

$ make -j$(nproc) >/dev/null
NetlistGenerator.cc: In member function 'ProGe::NetlistBlock* ProGe::NetlistGenerator::generate(const ProGeOptions&, int, TCEString, std::ostream&)':
NetlistGenerator.cc:190:29: warning: unused parameter 'options' [-Wunused-parameter]
  190 |         const ProGeOptions& options, int imemWidthInMAUs,
      |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~
AlteraIntegrator.cc: In member function 'virtual MemoryGenerator& AlteraIntegrator::imemInstance(MemInfo, int)':
AlteraIntegrator.cc:104:50: warning: unused parameter 'coreId' [-Wunused-parameter]
  104 | AlteraIntegrator::imemInstance(MemInfo imem, int coreId) {
      |                                              ~~~~^~~~~~
ar: `u' modifier ignored since `D' is the default (see `U')
Makefile:1404: warning: overriding recipe for target 'lib_a-mbtowc_r.o'
Makefile:820: warning: ignoring old recipe for target 'lib_a-mbtowc_r.o'
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
Makefile:1404: warning: overriding recipe for target 'lib_a-mbtowc_r.o'
Makefile:820: warning: ignoring old recipe for target 'lib_a-mbtowc_r.o'
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
Makefile:1404: warning: overriding recipe for target 'lib_a-mbtowc_r.o'
Makefile:820: warning: ignoring old recipe for target 'lib_a-mbtowc_r.o'
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')
ar: `u' modifier ignored since `D' is the default (see `U')

The ar warnings are fixable by something like

grep -rI 'ARFLAGS = cru' | awk -F':' '{print $2}' | xargs sed -i 's/ARFLAGS = cru/ARFLAGS = rc/'

but that modifies generated Makefile.in files in newlib, which I'm not entirely sure about. Same goes for Makefile:1404.

Other than that, the archaic function definition style used in parts of newlib becomes a hard error in gcc >= 15 when the default C version is upped to C23 IIUC, so while this PR does a fair bit of modifications to newlib, they would likely have to be done sooner or later anyway.

The remaining warnings are kind of annoying in that the unused parameters are unused in the public OpenASIP, but are used in the internal branch, so commenting them out here would likely lead to compilation failures when merged.

This PR looks big, but most of the linecount comes from just 3d5f5a7, where a fairly widely used deprecated method of making objects noncopyable is replaced by marking constructors/assignments = deleted. This clarifies semantics and helps the compiler produce more informative error messages if an object is used incorrectly. With C++26, we could also attach an explanation to = deleted to explain why the object is noncopyable, but that's probably pretty far in the future.

Silencing warnings might be good for the CI as well, we could potentially do something like make 2>err.log and check that a commit doesn't introduce new warnings easier, but that's future work.

@gtkiku gtkiku requested review from Joonari and pjaaskel February 12, 2026 10:15
+ Use set_terminate instead, which is not a direct replacement as it
  handles a few more cases but the end result is identical from a user's
  perspective. As a bonus, now regular exceptions print out nicely.
+ Makes the intentions a bit more clear and silences some warnings with
  gcc >= 14
+ The boolean is only used for overload resolution, so it doesn't need a
  name
+ C23 removes the old style completely, meaning this change would've
  been done in a couple years anyway
  (C23 is default starting with gcc >= 16, IIUC)
@@ -43,9 +43,7 @@ DESCRIPTION
*/

int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if newer newlibs have updated the files to newer C standards? Otherwise we better avoid unnecessary changes as it makes diffing against upstream newlib more difficult.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem to still be using the old style: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/reent/closer.c;h=2d72b2ab59e3332e44ee0c40acfa8da0abfbed7b;hb=HEAD

Compiling upstream newlib doesn't produce warnings because they just don't enable warnings :p Tried checking if anyone had sent patches upstream to see if there maybe was a reason the files hadn't been changed but didn't find any references to C23 or the specific warning message:

a function definition without a prototype is deprecated in all versions of C and is not supported in C2x

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I think it's better for us also to silence those warnings for newlib than to patch a lot our downstream copy, and then when it's fixed upstream we can synch from there.

bool finalized_;
/// LineReader for interpreter.
LineReader* reader_;
virtual void initialize(int argc, char* argv[],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indent looks wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd, for whatever reason format-branch.sh didn't see anything wrong here. I ran the whole file through the formatter which returned the file back to normal. Unsure what the deal here was.



void inline addAssignment(
const SimValue& assignValue, SimValue* assignTarget, int latency);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is the original TCE style guide indentation. If this cannot be fixed easily in clang format, let it be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: Do you mean that the original style was to place all parameters on their own line if they didn't fit on a single line? That's easily configured, but the .clang-format file has seemingly always been set to produce code like the above and a fair bit of the codebase seems to follow the autoformatting style.

The relevant parameters in this case:

https://clang.llvm.org/docs/ClangFormatStyleOptions.html#allowallparametersofdeclarationonnextline
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#binpackparameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I remember the indenting was different in .hh than the .cc, but do whatever seems the most uniform style here.

#ifdef Avoid_Underflow
if (scale && y <= 2*P*Exp_msk1) {
if (aadj <= 0x7fffffff) {
if (aadj <= 0x80000000) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCC emits

warning: implicit conversion from 'int' to 'double' changes value from 2147483647 to 2147483648

so 0x80000000 at least matches the comparison that takes place, if not what is intended to happen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, perhaps check if the newer Newlibs have this fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight correction: Warning comes from tcecc, where double is (in this case at least) apparently 32 bits in size. Couldn't get the warning to show up when compiling on my home computer. 32 bit doubles I goes against the C standard, so I guess the proper fix would be to implement 64 bit doubles in the compiler :)

newlib does have a macro _DOUBLE_IS_32BITS which is used, so I guess a workaround might be do to something like

#ifdef _DOUBLE_IS_32BITS
// use 0x8000000
#else
// use 0x7ffffffff
#endif

I don't think there's a proper testsuite for newlib on tce, so would have to test it with some other architecture that has one and defines _DOUBLE_IS_32BITS, maybe avr or something, to check if the implicit conversion is unintended and as such a bug, or intended and just happens to trigger a warning.

Copy link
Contributor

@Joonari Joonari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple of minor comments from me.

It's not directly related to this PR, but it popped up again here, that the coprocessor generator tool doesn't have a proper systemtest that would run RTL simulations. Currently it only checks that the generated RTL can be compiled. The manual has instructions on how to do that manually, but it requires the user to install CVA6 + rocket chip toolchains. It would be good to do that in the CI, but maybe not require those when running systemtests locally?

+ Was a bit too excited and removed one line too many.
+ For whatever reason, when only given the git patch the formatter
  indented one step too far
@pjaaskel pjaaskel merged commit 4e2066a into cpc:main Feb 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants