Linker error (multiple definition) during LD_STAGE 2 with custom scheduler
Тимофей Масленников <[email protected]> Sat, 20 Jun 2026 03:44:55 +0500
| Newsgroups | gmane.os.netbsd.devel.kernel |
|---|---|
| Message-ID | <CAEPDNa6=OaxKaMpuEiy=GbU4eJLsSAWx7_kgYCgcFwLcxMb4=w@mail.gmail.com> |
--0000000000006969610654a30bce Content-Type: text/plain; charset="UTF-8" Hello, I am working on porting a custom scheduler to NetBSD, cross-compiling on Void Linux using build.sh. I am trying to follow the modular design and using sched_m2.c as a reference. My scheduler implements some of the core scheduling functions but still relies on kern_runq.c for the rest of the fallback logic. However, during LD_STAGE 2, the build fails with "multiple definition" errors because the linker hits identical symbols in both my scheduler's object file and kern_runq.o. I have closely inspected kern_runq.c, and there are no conditional compilation macros (like #ifndef) to exclude these overlapping functions when a different scheduler is chosen. Could someone please explain how the NetBSD build system and linker handle symbol overriding for alternative schedulers? How does sched_m2.c avoid multiple definition conflicts with kern_runq.c, and what is the proper way to hook a custom scheduler into the kernel to avoid this collision? Please CC me in your replies, as I am not subscribed to the list. Thank you, [Timofey Maslennikov] --0000000000006969610654a30bce Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">Hello,<div dir=3D"auto"><br></div><div dir=3D"auto">I am = working on porting a custom scheduler to NetBSD, cross-compiling on Void Li= nux using build.sh. I am trying to follow the modular design and using sche= d_m2.c as a reference.</div><div dir=3D"auto"><br></div><div dir=3D"auto">M= y scheduler implements some of the core scheduling functions but still reli= es on kern_runq.c for the rest of the fallback logic. However, during LD_ST= AGE 2, the build fails with "multiple definition" errors because = the linker hits identical symbols in both my scheduler's object file an= d kern_runq.o.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I have cl= osely inspected kern_runq.c, and there are no conditional compilation macro= s (like #ifndef) to exclude these overlapping functions when a different sc= heduler is chosen.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Could= someone please explain how the NetBSD build system and linker handle symbo= l overriding for alternative schedulers? How does sched_m2.c avoid multiple= definition conflicts with kern_runq.c, and what is the proper way to hook = a custom scheduler into the kernel to avoid this collision?</div><div dir= =3D"auto"><br></div><div dir=3D"auto">Please CC me in your replies, as I am= not subscribed to the list.</div><div dir=3D"auto"><br></div><div dir=3D"a= uto">Thank you,</div><div dir=3D"auto">[Timofey Maslennikov]</div></div> --0000000000006969610654a30bce--