x86_64-pc-linux-gnu-gcc -o tests/plugin/libempty.so tests/plugin/libempty.so.p/empty.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libempty.so -Wl,--warn-common -Wl,- z,relro -Wl,-z,now -m64 -fstack-protector-strong -fPIE -DPIE -std=gnu99 -Wall -pie -Wl,-O1 -Wl,--as-needed -Wl,--export-dynamic -pthread -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -Wl,--end-group x86_64-pc-linux-gnu-gcc -o tests/plugin/libhotpages.so tests/plugin/libhotpages.so.p/hotpages.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libhotpages.so -Wl,--warn- common -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong -fPIE -DPIE -std=gnu99 -Wall -pie -Wl,-O1 -Wl,--as-needed -Wl,--export-dynamic -pthread -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -Wl,--end-group /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64/Scrt1.o: in function `_start': (.text+0x20): undefined reference to `main' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests/plugin/libempty.so.p/empty.c.o: in function `qemu_plugin_install': empty.c:(.text+0x1c): undefined reference to `qemu_plugin_register_vcpu_tb_trans_cb' collect2: error: ld returned 1 exit status /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64/Scrt1.o: in function `_start': (.text+0x20): undefined reference to `main' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests/plugin/libhotpages.so.p/hotpages.c.o: in function `vcpu_tb_trans': hotpages.c:(.text+0xb1): undefined reference to `qemu_plugin_tb_n_insns' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0xdb): undefined reference to `qemu_plugin_tb_get_insn' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0xf0): undefined reference to `qemu_plugin_register_vcpu_mem_cb' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests/plugin/libhotpages.so.p/hotpages.c.o: in function `vcpu_haddr': hotpages.c:(.text+0x128): undefined reference to `qemu_plugin_get_hwaddr' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0x145): undefined reference to `qemu_plugin_hwaddr_is_io' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0x184): undefined reference to `qemu_plugin_mem_is_store' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0x1dd): undefined reference to `qemu_plugin_hwaddr_is_io' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0x1ed): undefined reference to `qemu_plugin_hwaddr_device_offset' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests/plugin/libhotpages.so.p/hotpages.c.o: in function `plugin_exit': hotpages.c:(.text+0x2d5): undefined reference to `qemu_plugin_outs' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: tests/plugin/libhotpages.so.p/hotpages.c.o: in function `qemu_plugin_install': hotpages.c:(.text+0x395): undefined reference to `qemu_plugin_register_vcpu_tb_trans_cb' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: hotpages.c:(.text+0x3a6): undefined reference to `qemu_plugin_register_atexit_cb' make: *** [Makefile.ninja:2591: tests/plugin/libempty.so] Error 1 make: *** Waiting for unfinished jobs.... collect2: error: ld returned 1 exit status make: *** [Makefile.ninja:2611: tests/plugin/libhotpages.so] Error 1 [ebuild R ] app-emulation/qemu-9999 USE="-accessibility aio alsa bzip2 caps capstone curl -debug -doc fdt filecaps -glusterfs -gnutls gtk -infiniband io-uring -iscsi -jack% -jemalloc jpeg lzo -multipath ncurses nfs nls numa opengl oss pin-upstream-blobs plugins png pulseaudio python -rbd -sasl sdl -sdl-image* seccomp (-selinux) slirp -smartcard snappy spice ssh -static -static-user systemtap tci -test usb usbredir -vde vhost-net vhost-user-fs virgl virtfs vnc vte xattr xen -xfs xkb zstd" PYTHON_TARGETS="python3_6 python3_7 python3_8" QEMU_SOFTMMU_TARGETS="-aarch64 -alpha -arm -avr -cris -hppa -i386 -lm32 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -moxie -nios2 -or1k -ppc -ppc64 -riscv32 -riscv64 -rx -s390x -sh4 -sh4eb -sparc -sparc64 -tricore -unicore32 x86_64 -xtensa -xtensaeb" QEMU_USER_TARGETS="-aarch64 -aarch64_be -alpha -arm -armeb -cris -hppa -i386 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -mipsn32 -mipsn32el -nios2 -or1k -ppc -ppc64 -ppc64abi32 -ppc64le -riscv32 -riscv64 -s390x -sh4 -sh4eb -sparc -sparc32plus -sparc64 -tilegx -x86_64 -xtensa -xtensaeb" Reproducible: Always
Created attachment 658944 [details] emerge --info
Created attachment 658946 [details] build log
Reproduce locally as well.
(In reply to Rafael Kitover from comment #0) > x86_64-pc-linux-gnu-gcc -o tests/plugin/libempty.so > tests/plugin/libempty.so.p/empty.c.o -Wl,--as-needed > -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group > -Wl,-soname,libempty.so -Wl,--warn-common -Wl,- > z,relro -Wl,-z,now -m64 -fstack-protector-strong -fPIE -DPIE -std=gnu99 > -Wall -pie -Wl,-O1 -Wl,--as-needed -Wl,--export-dynamic -pthread > -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -Wl,--end-group > x86_64-pc-linux-gnu-gcc -o tests/plugin/libhotpages.so > tests/plugin/libhotpages.so.p/hotpages.c.o -Wl,--as-needed > -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group > -Wl,-soname,libhotpages.so -Wl,--warn- > common -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong -fPIE -DPIE > -std=gnu99 -Wall -pie -Wl,-O1 -Wl,--as-needed -Wl,--export-dynamic -pthread > -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -Wl,--end-group > /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ > ld: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64/Scrt1.o: in > function `_start': > (.text+0x20): undefined reference to `main' The result should be a shared library with a few undefined symbols from plugin API. But for some reason the module is linked as an executable (regardless of -shared) and required main(). That is strange. -pie linker flag for shared libs is a probable cause.
One of workarounds should be to disable USE=-plugins until -pie passing gets sorted upstream.
Thank you, I get a successful build with -plugins.