Skip to content

libpsx.so linking fails on powerpc 464fp (psx_wrap.o) #8

Open

Description

@AndrewGMorgan

[Migrating bugs from bugzilla.kernel.org to a GitHub based tracker, as the future of bugzilla.kernel.org is no longer certain.]

This bug was originally https://bugzilla.kernel.org/show_bug.cgi?id=220860

Hauke Mehrtens 2025-12-16 00:21:22 UTC

We switched from libcap 2.69 to 2.77 in OpenWrt. libcap 2.69 was building fine, but libcap 2.77
fails to build on power pc with musl libc. It works fine with x86, arm, aarch64, mips and some others.

It fails with this error message. When I remove psx_wrap.o from the linking operation it passes.

powerpc-openwrt-linux-musl-gcc-ar rcs libpsx.a ../psx/psx.o ../psx/psx_calls.o ../psx/wrap/psx_wrap.o
powerpc-openwrt-linux-musl-gcc-ranlib libpsx.a
make[6]: Leaving directory '/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap'
make libpsx.so
make[6]: Entering directory '/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap'
powerpc-openwrt-linux-musl-gcc -Os -pipe -mcpu=464fp -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77=libcap-2.77 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DPIC -fPIC -DSHELL='"/bin/sh"' -Dpthread_yield=sched_yield -Dlinux -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap/../libcap/include/uapi -I/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap/../libcap/include -DLIBRARY_VERSION=\"libpsx-2.77\" -DSHARED_LOADER=\"/lib/ld-musl-powerpc.so.1\" -c psx_exec.c -o psx_magic.o
powerpc-openwrt-linux-musl-gcc -Wl,-x -shared -Os -pipe -mcpu=464fp -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77=libcap-2.77 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DPIC -fPIC -DSHELL='"/bin/sh"' -Dpthread_yield=sched_yield -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/lib -fuse-ld=bfd -znow -zrelro -Wl,-soname,libpsx.so.2 -o libpsx.so.2.77 ../psx/psx.o ../psx/psx_calls.o ../psx/wrap/psx_wrap.o psx_magic.o -Wl,-e,__so_start -lpthread
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/libgcc.a(generic-morestack-thread.o): in function `stack_split_initialize_thread':
/builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:129:(.text+0x26): undefined reference to `__stack_split_initialize'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:129:(.text+0x2a): undefined reference to `__stack_split_initialize'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:129:(.text+0x2c): undefined reference to `__stack_split_initialize'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:129:(.text+0x30): undefined reference to `__stack_split_initialize'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:135:(.text+0x8a): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:135:(.text+0x8e): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:135:(.text+0x90): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:135:(.text+0x94): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/libgcc.a(generic-morestack-thread.o): in function `create_key':
/builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:102:(.text+0x12a): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/libgcc.a(generic-morestack-thread.o):/builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:102: more undefined references to `__morestack_fail' follow
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/libgcc.a(generic-morestack-thread.o): in function `free_segments':
/builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:87:(.text+0x1be): undefined reference to `__morestack_release_segments'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:87:(.text+0x1c2): undefined reference to `__morestack_release_segments'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:87:(.text+0x1c8): undefined reference to `__morestack_release_segments'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:87:(.text+0x1e0): undefined reference to `__morestack_release_segments'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/libgcc.a(generic-morestack-thread.o): in function `__wrap_pthread_create':
/builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:167:(.text+0x242): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:167:(.text+0x24a): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:167:(.text+0x24c): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: /builder/shared-workdir/build/build_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/gcc-14.3.0/libgcc/generic-morestack-thread.c:167:(.text+0x250): undefined reference to `__morestack_fail'
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: libpsx.so.2.77: hidden symbol `__morestack_fail' isn't defined
/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/bin/../lib/gcc/powerpc-openwrt-linux-musl/14.3.0/../../../../powerpc-openwrt-linux-musl/bin/ld.bfd: final link failed: bad value
collect2: error: ld returned 1 exit status
make[6]: *** [Makefile:133: libpsx.so] Error 1
make[6]: Leaving directory '/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap'
make[5]: *** [Makefile:47: all] Error 2
make[5]: Leaving directory '/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/libcap'
make[4]: *** [Makefile:12: all] Error 2
make[4]: Leaving directory '/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77'
make[3]: *** [Makefile:119: /builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77/.built] Error 2
time: package/feeds/base/libcap/compile#2.41#0.88#9.60

Andrew G. Morgan 2025-12-16 16:19:24 UTC

What version of musl are you using? There is a lot of text in that output, I think this is the command
that is failing:

powerpc-openwrt-linux-musl-gcc -Wl,-x -shared -Os -pipe -mcpu=464fp -fno-caller-saves -fno-plt -fhonour-copts -ffile-prefix-map=/builder/shared-workdir/build/sdk/build_dir/target-powerpc_464fp_musl/libcap-2.77=libcap-2.77 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DPIC -fPIC -DSHELL='"/bin/sh"' -Dpthread_yield=sched_yield -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-powerpc_464fp_gcc-14.3.0_musl/lib -fuse-ld=bfd -znow -zrelro -Wl,-soname,libpsx.so.2 -o libpsx.so.2.77 ../psx/psx.o ../psx/psx_calls.o ../psx/wrap/psx_wrap.o psx_magic.o -Wl,-e,__so_start -lpthread

The error logs look like things are not getting fully linked against some libgcc internal dependency.
None of the missing symbols are to be found in libpsx.so.

https://github.com/gcc-mirror/gcc/blob/f3b51711dcbdd023e9928d866c8d32053ba520dc/libgcc/generic-morestack.c#L355

Hauke Mehrtens 2025-12-16 22:53:10 UTC

This was seen in OpenWrt main using musl libc 1.2.5, gcc 14.3.0 and binutils 2.44.

When I remove ../psx/wrap/psx_wrap.o from the linker call it links the shared library successfully.

Andrew G. Morgan 2025-12-26 18:42:40 UTC

Can you execute the following:

cd libcap
make clean
make libpsx.so

and include all of the log output?

I don't see any difference in the compilation options for the three files in the ../psx directory tree.
But you clearly have extra flags being applied in your general compilation. I don't see anything in
the psx_wrap.c file that should act differently, so I'd like to see if your are compiling that file
differently in some way?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions