yank: Avoid linking into executables that don't want it
PATCH 1/1 yank: Avoid linking into executables that don't want it
util/yank.c and stubs/yank.c are both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.
To fix this, the non-stub yank.c from sourceset util_ss to sourceset qmp_ss. This requires moving it from util/ to monitor/.
---
{util => monitor}/yank.c | 0
MAINTAINERS | 2 +-
monitor/meson.build | 1 +
util/meson.build | 1 -
4 files changed, 2 insertions(+), 2 deletions(-)
rename {util => monitor}/yank.c (100%)monitor/yank.c renamed from util/yank.c +0 -0
MAINTAINERS +1 -1
@@ -2799,7 +2799,7 @@ F: tests/unit/test-uuid.c Yank feature M: Lukas Straub <[email protected]> S: Odd fixes -F: util/yank.c +F: monitor/yank.c F: stubs/yank.c F: include/qemu/yank.h F: qapi/yank.json
monitor/meson.build +1 -0
@@ -1,4 +1,5 @@ qmp_ss.add(files('monitor.c', 'qmp.c', 'qmp-cmds-control.c')) +qmp_ss.add(files('yank.c')) softmmu_ss.add(files( 'hmp-cmds.c',
util/meson.build +0 -1
@@ -51,7 +51,6 @@ endif if have_system util_ss.add(files('crc-ccitt.c')) util_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus.c'), gio]) - util_ss.add(files('yank.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c')) endif
Signature · 1 line
2.26.2
Quoted 7 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourceset
This sentence no verb.
Quoted 4 lines
qmp_ss. This requires moving it from util/ to monitor/.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 8 lines
---
{util => monitor}/yank.c | 0
MAINTAINERS | 2 +-
monitor/meson.build | 1 +
util/meson.build | 1 -
4 files changed, 2 insertions(+), 2 deletions(-)
rename {util => monitor}/yank.c (100%)Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 10 lines · Eric Blake
Quoted 7 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourcesetThis sentence no verb.
To fix this, move the non-stub ...
Quoted 13 lines
Quoted 4 lines
qmp_ss. This requires moving it from util/ to monitor/.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Quoted 8 lines
--- {util => monitor}/yank.c | 0 MAINTAINERS | 2 +- monitor/meson.build | 1 + util/meson.build | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) rename {util => monitor}/yank.c (100%)
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>
Thanks!
Quoted 11 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourcesetqmp_ss. This requires moving it from util/ to monitor/.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 7 lines
---
{util => monitor}/yank.c | 0
MAINTAINERS | 2 +-
monitor/meson.build | 1 +
util/meson.build | 1 -
4 files changed, 2 insertions(+), 2 deletions(-)
rename {util => monitor}/yank.c (100%)I'm still determining if I need an NBD pull request for soft freeze today; if so, I'm happy to include this one if it doesn't make it into the tree elsewhere first. I also consider it to be a build issue and therefore suitable for inclusion in -rc1 if it misses the boat today.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 20 lines · Eric Blake
Quoted 11 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourcesetqmp_ss. This requires moving it from util/ to monitor/.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>Quoted 7 lines
--- {util => monitor}/yank.c | 0 MAINTAINERS | 2 +- monitor/meson.build | 1 + util/meson.build | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) rename {util => monitor}/yank.c (100%)
Quoted 4 lines
I'm still determining if I need an NBD pull request for soft freeze today; if so, I'm happy to include this one if it doesn't make it into the tree elsewhere first. I also consider it to be a build issue and therefore suitable for inclusion in -rc1 if it misses the boat today.
It's not urgent, just something I spotted when I looked for buddies of another bug that bit me.
Quoted 51 lines · On Tue, 16 Mar 2021 14:59:07 +0100 Markus Armbruster <[email protected]> wrote:
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourcesetqmp_ss. This requires moving it from util/ to monitor/.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- {util => monitor}/yank.c | 0 MAINTAINERS | 2 +- monitor/meson.build | 1 + util/meson.build | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) rename {util => monitor}/yank.c (100%)monitor/yank.c renamed from util/yank.c +0
-0MAINTAINERS +1
-1@@ -2799,7 +2799,7 @@ F: tests/unit/test-uuid.c Yank feature M: Lukas Straub <[email protected]> S: Odd fixes -F: util/yank.c +F: monitor/yank.c F: stubs/yank.c F: include/qemu/yank.h F: qapi/yank.jsonmonitor/meson.build +1
-0@@ -1,4 +1,5 @@ qmp_ss.add(files('monitor.c', 'qmp.c', 'qmp-cmds-control.c')) +qmp_ss.add(files('yank.c')) softmmu_ss.add(files( 'hmp-cmds.c',util/meson.build +0
-0
util/meson.build endif · line 56
Quoted 7 lines
util/meson.build +0
-1@@ -51,7 +51,6 @@ endif if have_system util_ss.add(files('crc-ccitt.c')) util_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus.c'), gio]) - util_ss.add(files('yank.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c')) endif
Looks good to me, applied and fixed commit message.
Regards,
Lukas Straub
Quoted 8 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.To fix this, the non-stub
yank.cfrom sourcesetutil_ssto sourcesetqmp_ss. This requires moving it from util/ to monitor/.
In another patch ("tests: Use the normal yank code instead of stubs in relevant tests"), Lukas now changed the tests to always explicitly link against the real yank.c code. That makes me wonder whether we need the yank stubs at all ... it's not that much code after all, and it's very much self-contained without references to other files, so I think it should also be ok if we simply always keep it in the utils library and ditch the stubs?
Thomas
Quoted 9 lines · Thomas Huth
Quoted 7 lines · Markus Armbruster
util/yank.candstubs/yank.care both in libqemuutil.a, even though their external symbols conflict. The linker happens to pick the former. This links a bunch of unneeded code into the executables that actually want the latter: qemu-io, qemu-img, qemu-nbd, and several tests. Amazingly, none of them fails to link.
To fix this, the non-stubyank.cfrom sourcesetutil_ssto sourcesetqmp_ss. This requires moving it from util/ to monitor/.
Quoted 7 lines
In another patch ("tests: Use the normal yank code instead of stubs in relevant tests"), Lukas now changed the tests to always explicitly link against the real
yank.ccode. That makes me wonder whether we need the yank stubs at all ... it's not that much code after all, and it's very much self-contained without references to other files, so I think it should also be ok if we simply always keep it in the utils library and ditch the stubs?
Any solution that links and doesn't put duplicate symbols in .a is fine with me.