rt-tests icon indicating copy to clipboard operation
rt-tests copied to clipboard

Build error with gcc 15 on Fedora 42

Open ycollet opened this issue 8 months ago • 1 comments

I am trying to build rt-test on Fedora 42 with gcc 15. The build fails with the following error message:

In file included from src/lib/rt-utils.c:28:
src/include/rt-sched.h:45:8: error: redefinition of ‘struct sched_attr’
   45 | struct sched_attr {
      |        ^~~~~~~~~~
In file included from /usr/include/bits/sched.h:63,
                 from /usr/include/sched.h:43,
                 from src/lib/rt-utils.c:14:
/usr/include/linux/sched/types.h:98:8: note: originally defined here
   98 | struct sched_attr {
      |        ^~~~~~~~~~
src/include/rt-sched.h:62:5: error: conflicting types for ‘sched_setattr’; have ‘int(pid_t,  const struct sched_attr *, unsigned int)’ {aka ‘int(int,  const struct sched_attr *, unsigned int)’}
   62 | int sched_setattr(pid_t pid,
      |     ^~~~~~~~~~~~~
/usr/include/bits/sched.h:148:5: note: previous declaration of ‘sched_setattr’ with type ‘int(pid_t,  struct sched_attr *, unsigned int)’ {aka ‘int(int,  struct sched_attr *, unsigned int)’}
  148 | int sched_setattr (pid_t tid, struct sched_attr *attr, unsigned int flags)
      |     ^~~~~~~~~~~~~
src/include/rt-sched.h:66:5: error: conflicting types for ‘sched_getattr’; have ‘int(pid_t,  struct sched_attr *, unsigned int,  unsigned int)’ {aka ‘int(int,  struct sched_attr *, unsigned int,  unsigned int)’}
   66 | int sched_getattr(pid_t pid,
      |     ^~~~~~~~~~~~~
/usr/include/bits/sched.h:153:5: note: previous declaration of ‘sched_getattr’ with type ‘int(pid_t,  struct sched_attr *, unsigned int,  unsigned int)’ {aka ‘int(int,  struct sched_attr *, unsigned int,  unsigned int)’}
  153 | int sched_getattr (pid_t tid, struct sched_attr *attr, unsigned int size,
      |     ^~~~~~~~~~~~~
src/lib/rt-utils.c: In function ‘tracemark’:
src/lib/rt-utils.c:479:9: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  479 |         write(tracemark_fd, tracebuf, len);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib/rt-utils.c:482:9: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  482 |         write(trace_fd, "0\n", 2);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:122: bld/rt-utils.o] Error 1

ycollet avatar May 13 '25 05:05 ycollet

This is because rt-sched.h re-defines functions and structs already present in sched.h This was fixed upstream, but in the meanwhile if an external tool is still using the latest version (Intel's LKP-tests in my case), you can quickly build removing the files and references.

In short, you need to remove all #include "rt-sched.h" and do not build rt-sched.o :

grep rt-sched -r -l | xargs sed -i '/include ["<]rt-sched.h/d'
sed -i 's/ rt-sched.o//' Makefile

glemco avatar Jun 30 '25 11:06 glemco