Created attachment 875869 [details] Successfull emerge of broken gcc:11 After a successfull emerge of sys-devel/gcc:11[cet,d] on musl you get a D compiler with a broken shandard library. This is because the library references functions like swapcontext, makecontext, getcontext which do not exist on musl. The root cause of this problem is https://github.com/gcc-mirror/gcc/blob/7eaf95689bf495ab07473951ededa835eb618123/libphobos/libdruntime/core/thread/fiber.d#L76-L80. In which cet support disables the assembly implementations of some of the functions in that module, falling back to the ucontext implementations. Since musl doesn't implement makecontext, swapcontext or getcontext, even though it provided prototypes in ucontext.h linker errors appear. An example of the errors when trying to compile a hello_world program: ------ /usr/lib/gcc/x86_64-gentoo-linux-musl/11/../../../../x86_64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/x86_64-gentoo-linux-musl/11/libgphobos.a(fiber.o): in function `fiber_switchContext': (.text.fiber_switchContext+0x3b): undefined reference to `swapcontext' /usr/lib/gcc/x86_64-gentoo-linux-musl/11/../../../../x86_64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/x86_64-gentoo-linux-musl/11/libgphobos.a(fiber.o): in function `_D4core6thread5fiber5Fiber9initStackMFNbNiZv': (.text._D4core6thread5fiber5Fiber9initStackMFNbNiZv+0x2e): undefined reference to `getcontext' /usr/lib/gcc/x86_64-gentoo-linux-musl/11/../../../../x86_64-gentoo-linux-musl/bin/ld: (.text._D4core6thread5fiber5Fiber9initStackMFNbNiZv+0x5f): undefined reference to `makecontext' /usr/lib/gcc/x86_64-gentoo-linux-musl/11/../../../../x86_64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/x86_64-gentoo-linux-musl/11/libgphobos.a(fiber.o): in function `_D4core6thread5fiber5Fiber12_staticCtor1FZv': (.text._D4core6thread5fiber5Fiber12_staticCtor1FZv+0x1c): undefined reference to `getcontext' collect2: error: ld returned 1 exit status ------ The same errors appear, during emerge this time, for sys-devel/gcc:13 and it should happen to the other slots as well though I have not tested them specifically. A snippet: ------ /usr/x86_64-gentoo-linux-musl/bin/ld: /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/build/prev-x86_64-gentoo-linux-musl/libphobos/src/.libs/libgphobos.a(fiber.o): in function `fiber_switchContext': /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/gcc-13-20231014/libphobos/libdruntime/core/thread/fiber.d:430: undefined reference to `swapcontext' /usr/x86_64-gentoo-linux-musl/bin/ld: /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/build/prev-x86_64-gentoo-linux-musl/libphobos/src/.libs/libgphobos.a(fiber.o): in function `_D4core6thread5fiber5Fiber9initStackMFNbNiZv': /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/gcc-13-20231014/libphobos/libdruntime/core/thread/fiber.d:1537: undefined reference to `getcontext' /usr/x86_64-gentoo-linux-musl/bin/ld: /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/gcc-13-20231014/libphobos/libdruntime/core/thread/fiber.d:1540: undefined reference to `makecontext' /usr/x86_64-gentoo-linux-musl/bin/ld: /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/build/prev-x86_64-gentoo-linux-musl/libphobos/src/.libs/libgphobos.a(fiber.o): in function `_D4core6thread5fiber5Fiber19_staticCtor_L921_C9FZv': /var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/gcc-13-20231014/libphobos/libdruntime/core/thread/fiber.d:925: undefined reference to `getcontext' collect2: error: ld returned 1 exit status make[3]: *** [/var/tmp/portage/sys-devel/gcc-13.2.1_p20231014/work/gcc-13-20231014/gcc/d/Make-lang.in:236: d21] Error 1 ------ A fix upstream would be to also check if cet support is enabled when deciding if needing a ucontext implementation for the D runtime in the autoconf macro: https://github.com/gcc-mirror/gcc/blob/7eaf95689bf495ab07473951ededa835eb618123/libphobos/m4/druntime/libraries.m4#L213
Created attachment 875870 [details] build.log of gcc:13