Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build v6.0.0 with nix #4427

Open
adamcstephens opened this issue Apr 5, 2024 · 16 comments · Fixed by #4428
Open

Unable to build v6.0.0 with nix #4427

adamcstephens opened this issue Apr 5, 2024 · 16 comments · Fixed by #4428
Assignees

Comments

@adamcstephens
Copy link
Contributor

adamcstephens commented Apr 5, 2024

Issue description

Hi, I'm trying to upgrade the nixpkgs package to v6.0.0 but I'm currently stuck due to changes which have broken our build's ability to link. Whether using multi-binary or tools-multicall, the only way I've found to build v6.0 is by reverting #4401.

[135/139] Linking target src/lxc/cmd/lxc-monitord
FAILED: src/lxc/cmd/lxc-monitord
gcc  -o src/lxc/cmd/lxc-monitord src/lxc/cmd/lxc-monitord.p/lxc_monitord.c.o src/lxc/cmd/lxc-monitord.p/.._.._include_netns_ifaddrs.c.o -flto -Wl,--no-undefined -pie -Wl,--no-as-needed -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now -fstack-protector -fstack-protector-strong -Wl,-fuse-ld=gold -Wl,--warn-common '-Wl,-rpath,$ORIGIN/../../..' -Wl,-rpath-link,/home/adam/git/lxc/build/ -Wl,--start-group src/lxc/liblxc.a liblxc.so.1.8.0 /nix/store/jnlxl2ry9y03vq4skhm26igfd84xwa93-dbus-1.14.10-lib/lib/libdbus-1.so -pthread /nix/store/iglb2fmla149fbprj6fb18swfls033q4-libseccomp-2.5.4-lib/lib/libseccomp.so /nix/store/5mfk83ikgk62gv0xj95xylnkf0f52chv-libselinux-3.3/lib/libselinux.so /nix/store/wp5c5sjlvm6nxavvs1prdnw5n41mgciq-libapparmor-3.1.6/lib/libapparmor.so /nix/store/c7rf6w8xvxc4423m9rsgq5nsqhknshvy-openssl-3.0.12/lib/libssl.so /nix/store/c7rf6w8xvxc4423m9rsgq5nsqhknshvy-openssl-3.0.12/lib/libcrypto.so /nix/store/lmj8lfkd8h448grf1nf92lsm5gm2fnf6-libcap-2.69-lib/lib/libcap.so -lutil -Wl,--end-group
../src/lxc/cmd/lxc_monitord.c:67: error: undefined reference to 'lxc_monitor_fifo_name'
../src/lxc/cmd/lxc_monitord.c:104: error: undefined reference to 'lxc_monitor_fifo_name'
../src/lxc/cmd/lxc_monitord.c:140: error: undefined reference to 'lxc_read_nointr'
../src/lxc/cmd/lxc_monitord.c:193: error: undefined reference to 'lxc_mainloop_add_handler'
../src/lxc/cmd/lxc_monitord.c:219: error: undefined reference to 'lxc_monitor_sock_name'
../src/lxc/cmd/lxc_monitord.c:222: error: undefined reference to 'lxc_abstract_unix_open'
../src/lxc/cmd/lxc_monitord.c:236: error: undefined reference to 'lxc_monitor_sock_name'
../src/lxc/cmd/lxc_monitord.c:258: error: undefined reference to 'lxc_abstract_unix_close'
../src/lxc/cmd/lxc_monitord.c:277: error: undefined reference to 'lxc_read_nointr'
../src/lxc/cmd/lxc_monitord.c:284: error: undefined reference to 'lxc_write_nointr'
../src/lxc/cmd/lxc_monitord.c:297: error: undefined reference to 'lxc_mainloop_add_handler'
../src/lxc/cmd/lxc_monitord.c:306: error: undefined reference to 'lxc_mainloop_add_handler'
../src/lxc/cmd/lxc_monitord.c:343: error: undefined reference to 'lxc_global_config_value'
../src/lxc/cmd/lxc_monitord.c:351: error: undefined reference to 'lxc_safe_int'
../src/lxc/cmd/lxc_monitord.c:388: error: undefined reference to 'lxc_mainloop_open'
../src/lxc/cmd/lxc_monitord.c:405: error: undefined reference to 'lxc_write_nointr'
../src/lxc/cmd/lxc_monitord.c:420: error: undefined reference to 'lxc_mainloop'
../src/lxc/cmd/lxc_monitord.c:442: error: undefined reference to 'lxc_mainloop_close'
../src/include/netns_ifaddrs.c:430: error: undefined reference to 'addattr'
collect2: error: ld returned 1 exit status
[137/139] Linking target src/lxc/tools/lxc
FAILED: src/lxc/tools/lxc
gcc  -o src/lxc/tools/lxc src/lxc/tools/lxc.p/lxc_multicall.c.o src/lxc/tools/lxc.p/arguments.c.o src/lxc/tools/lxc.p/.._.._include_netns_ifaddrs.c.o src/lxc/tools/lxc.p/lxc_attach.c.o src/lxc/tools/lxc.p/lxc_autostart.c.o src/lxc/tools/lxc.p/lxc_cgroup.c.o src/lxc/tools/lxc.p/lxc_checkpoint.c.o src/lxc/tools/lxc.p/lxc_config.c.o src/lxc/tools/lxc.p/lxc_console.c.o src/lxc/tools/lxc.p/lxc_copy.c.o src/lxc/tools/lxc.p/lxc_create.c.o src/lxc/tools/lxc.p/lxc_destroy.c.o src/lxc/tools/lxc.p/lxc_device.c.o src/lxc/tools/lxc.p/lxc_execute.c.o src/lxc/tools/lxc.p/lxc_freeze.c.o src/lxc/tools/lxc.p/lxc_info.c.o src/lxc/tools/lxc.p/lxc_ls.c.o src/lxc/tools/lxc.p/lxc_snapshot.c.o src/lxc/tools/lxc.p/lxc_start.c.o src/lxc/tools/lxc.p/lxc_stop.c.o src/lxc/tools/lxc.p/lxc_top.c.o src/lxc/tools/lxc.p/lxc_unfreeze.c.o src/lxc/tools/lxc.p/lxc_unshare.c.o src/lxc/tools/lxc.p/lxc_wait.c.o src/lxc/tools/lxc.p/lxc_monitor.c.o -flto -Wl,--no-undefined -pie -Wl,--no-as-needed -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now -fstack-protector -fstack-protector-strong -Wl,-fuse-ld=gold -Wl,--warn-common '-Wl,-rpath,$ORIGIN/../../..' -Wl,-rpath-link,/home/adam/git/lxc/build/ -Wl,--start-group src/lxc/liblxc.a liblxc.so.1.8.0 /nix/store/jnlxl2ry9y03vq4skhm26igfd84xwa93-dbus-1.14.10-lib/lib/libdbus-1.so -pthread /nix/store/iglb2fmla149fbprj6fb18swfls033q4-libseccomp-2.5.4-lib/lib/libseccomp.so /nix/store/5mfk83ikgk62gv0xj95xylnkf0f52chv-libselinux-3.3/lib/libselinux.so /nix/store/wp5c5sjlvm6nxavvs1prdnw5n41mgciq-libapparmor-3.1.6/lib/libapparmor.so /nix/store/c7rf6w8xvxc4423m9rsgq5nsqhknshvy-openssl-3.0.12/lib/libssl.so /nix/store/c7rf6w8xvxc4423m9rsgq5nsqhknshvy-openssl-3.0.12/lib/libcrypto.so /nix/store/lmj8lfkd8h448grf1nf92lsm5gm2fnf6-libcap-2.69-lib/lib/libcap.so -lutil -Wl,--end-group
../src/lxc/tools/arguments.c:214: error: undefined reference to 'remove_trailing_slashes'
../src/include/netns_ifaddrs.c:430: error: undefined reference to 'addattr'
../src/lxc/tools/lxc_attach.c:41: error: undefined reference to 'lxc_rexec'
../src/lxc/tools/lxc_attach.c:165: error: undefined reference to 'lxc_namespace_2_std_identifiers'
../src/lxc/tools/lxc_attach.c:168: error: undefined reference to 'lxc_fill_namespace_flags'
../src/lxc/tools/lxc_attach.c:202: error: undefined reference to 'lxc_safe_uint'
../src/lxc/tools/lxc_attach.c:206: error: undefined reference to 'lxc_safe_uint'
../src/lxc/tools/lxc_attach.c:331: error: undefined reference to 'lxc_caps_init'
../src/lxc/tools/lxc_attach.c:442: error: undefined reference to 'lxc_wait_for_pid_status'
../src/lxc/tools/lxc_autostart.c:48: error: undefined reference to 'lxc_safe_long'

Steps to reproduce

─❯ incus launch images:nixos/unstable --ephemeral -c security.nesting=true
Launching the instance
Instance name is: proud-maggot

─❯ incus exec proud-maggot -- nix --extra-experimental-features 'flakes nix-command' build 'github:nixos/nixpkgs?ref=refs/pull/301564/head#lxc' --print-build-logs

https://github.com/adamcstephens/nixpkgs/blob/lxc/6/pkgs/by-name/lx/lxc/generic.nix

@mihalicyn
Copy link
Member

Hi @adamcstephens

Thanks for your report!

This is really odd issue. I have tried to play with NixOS a bit but it has very unusual build environment. Couldn't you provide some clear steps how I can reproduce the issue with local LXC source tree? If I had this local environment I would be able to experiment with it a bit and try to tackle down the problem. The reproducer that you've shown is about getting sources directly from github/NixOS servers AFAIU.

@adamcstephens
Copy link
Contributor Author

adamcstephens commented Apr 5, 2024

Hi @mihalicyn

You can use either nixos (e.g. the incus image) or another distro with nix installed. Assuming the basic incus nixos image:

nix-env -iA nixos.git
git clone https://github.com/lxc/lxc -b v6.0.0
cd lxc
nix --refresh --extra-experimental-features 'flakes nix-command' develop github:nixos/nixpkgs?ref=refs/pull/301564/head#lxc
# you'll now in be in a shell with all needed dependencies that match our build environment
meson setup build
meson compile -C build

You'll get the same errors here.

mihalicyn added a commit to mihalicyn/lxc that referenced this issue Apr 5, 2024
Fixes: lxc#4427
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
@mihalicyn
Copy link
Member

Huge thanks, Adam!

I have posted a PR with fix.

@juippis
Copy link

juippis commented Apr 6, 2024

I wonder if this fix should be shipped for every distribution? Or does it matter if the lxc was successfully built?

@geaaru
Copy link
Contributor

geaaru commented Apr 6, 2024

Hi, i have the same issue in the Funtoo/Macaroni OS ebuild.
It seems that the problem is related to the visibility of the hidden functions. But without using a patch I can compile it if I set -Db_lto=false on meson setup.

mihalicyn added a commit to mihalicyn/lxc that referenced this issue Apr 6, 2024
Fixes: lxc#4427
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
@mihalicyn
Copy link
Member

Dear friends,

really sorry for making troubles for you with this.

I have just updated my PR (#4428) with fix for this.
I have tested this with Ubuntu and NixOS (huge thanks to Adam for clear instructions and report) and it looks working just fine.

@geaaru Daniele, couldn't you check that fix from PR #4428 works for you too on Gentoo/Funtoo/Macaroni OS?

@juippis no, if it builds, it builds. It does not matter if LXC builds successfully. There is no security or any other risks. It's just a matter of different versions of GCC/ld/meson and distro-specific configuration for this tool-chain.

@geaaru
Copy link
Contributor

geaaru commented Apr 6, 2024

@mihalicyn hi, with your fix I haven't resolved the problem from my side. It compiles without your patch too, only when i use -Db_lto=false. Sorry if i don't clarify this in my previous post.
Tested also now from main branch:

/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.3: error: undefined reference to 'lxc_safe_uint'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0: error: undefined reference to 'lxc_safe_uint'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0: error: undefined reference to 'lxc_namespace_2_std_identifiers'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0: error: undefined reference to 'lxc_fill_namespace_flags'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0: error: undefined reference to 'lxc_safe_uint'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.12: error: undefined reference to 'lxc_safe_long'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.1: error: undefined reference to 'lxc_safe_long'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.13: error: undefined reference to 'lxc_safe_int'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function get_config_integer: error: undefined reference to 'lxc_safe_int'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.5: error: undefined reference to 'get_fssize'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get_ips: error: undefined reference to 'lxc_string_join'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get_ips: error: undefined reference to 'lxc_free_array'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function create_helpfn: error: undefined reference to 'get_template_path'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function do_destroy: error: undefined reference to 'file_exists'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function stdin_handler: error: undefined reference to 'lxc_read_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function do_destroy_with_snapshots: error: undefined reference to 'lxc_read_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function is_interface.part.0: error: undefined reference to 'switch_to_ns'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function is_interface: error: undefined reference to 'wait_for_pid'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.7: error: undefined reference to 'lxc_safe_uint'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function print_net_stats: error: undefined reference to 'lxc_read_from_file'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function print_net_stats: error: undefined reference to 'lxc_read_from_file'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_recv_str: error: undefined reference to 'lxc_read_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_recv_str: error: undefined reference to 'lxc_read_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function stat_get_blk_stats: error: undefined reference to 'lxc_string_split_and_trim'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function stat_get_blk_stats: error: undefined reference to 'lxc_free_array'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function stat_get_blk_stats: error: undefined reference to 'lxc_string_split_and_trim'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function stat_get_blk_stats: error: undefined reference to 'lxc_free_array'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_send_str: error: undefined reference to 'lxc_write_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_send_str: error: undefined reference to 'lxc_write_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_remove_lock: error: undefined reference to 'get_rundir'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_remove_lock: error: undefined reference to 'lxc_rm_rf'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_append_paths'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'dir_exists'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_string_replace'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_string_split_and_trim'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_array_len'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_free_array'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_append_paths'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_string_join'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'lxc_append_paths'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get: error: undefined reference to 'wait_for_pid'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get_wrapper: error: undefined reference to 'lxc_write_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function ls_get_wrapper: error: undefined reference to 'lxc_write_nointr'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.14: error: undefined reference to 'lxc_namespace_2_std_identifiers'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.14: error: undefined reference to 'lxc_fill_namespace_flags'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_arguments_parse: error: undefined reference to 'remove_trailing_slashes'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_attach_main: error: undefined reference to 'lxc_caps_init'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_attach_main: error: undefined reference to 'lxc_wait_for_pid_status'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_checkpoint_main: error: undefined reference to 'wait_for_pid'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_create_main: error: undefined reference to 'lxc_mkdir_p'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_execute_main: error: undefined reference to 'lxc_caps_init'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_execute_main: error: undefined reference to 'lxc_string_split_quoted'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_ls_main: error: undefined reference to 'lxc_string_split_and_trim'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_ls_main: error: undefined reference to 'lxc_array_len'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_start_main: error: undefined reference to 'lxc_caps_init'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_top_main: error: undefined reference to 'lxc_mainloop_open'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_top_main: error: undefined reference to 'lxc_mainloop_add_handler'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_top_main: error: undefined reference to 'lxc_mainloop'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_top_main: error: undefined reference to 'lxc_mainloop_close'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_unshare_main: error: undefined reference to 'lxc_caps_init'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_unshare_main: error: undefined reference to 'lxc_clone'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_unshare_main: error: undefined reference to 'wait_for_pid'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: hidden symbol 'write_id_mapping' is not defined locally
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'get_fssize'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_split'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_split'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_join'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_array_len'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_split'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_split'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_string_join'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.4: error: undefined reference to 'lxc_array_len'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans0.ltrans.o:<artificial>:function lxc_attach_rexec: error: undefined reference to 'lxc_rexec'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'lxc_monitor_open'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'lxc_monitor_open'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'lxc_safe_int'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'null_stdfds'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'lxc_monitor_read_fdset'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function lxc_monitor_main: error: undefined reference to 'lxc_state2str'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function do_clone_ephemeral.constprop.0: error: undefined reference to 'lxc_is_dir'
/var/tmp/portage/app-emulation/lxc-9999/temp/cckyppZS.ltrans1.ltrans.o:<artificial>:function do_clone_ephemeral.constprop.0: error: undefined reference to 'lxc_is_dir'

So, with -Db_lto=false i can compile with or without tools-multicalls correctly.
It seems something related to the compiler and the __hidden functions.

@geaaru
Copy link
Contributor

geaaru commented Apr 6, 2024

Just another note... if I remove __hidden from the functions undefined all works fine. So, the problem is related to the exporting of the symbols now that the binary is linked dynamically.
We use: binutils-2.40, meson 1.3.2 and GCC 11.3.0.

@mihalicyn mihalicyn reopened this Apr 7, 2024
@mihalicyn
Copy link
Member

It's interesting.

Have tried with Gentoo:

assuring-lionfish ~/lxc_pkg # cat /etc/os-release 
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/"
SUPPORT_URL="https://www.gentoo.org/support/"
BUG_REPORT_URL="https://bugs.gentoo.org/"
VERSION_ID="2.14"
assuring-lionfish ~/lxc_pkg # ld -v
GNU ld (Gentoo 2.41 p5) 2.41.0
assuring-lionfish ~/lxc_pkg # meson -v
1.3.2
assuring-lionfish ~/lxc_pkg # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-13.2.1_p20240210/work/gcc-13-20240210/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/13/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 13.2.1_p20240210 p14' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --enable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --without-isl --enable-default-pie --enable-default-ssp --disable-fixincludes --with-build-config=bootstrap-cet
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20240210 (Gentoo 13.2.1_p20240210 p14) 

This configuration:

meson setup genbuild \
                -Dtests=true \
                -Dman=false \
                -Dinit-script=sysvinit \
                -Dpam-cgroup=false \
                -Ddbus=false \
                -Dwerror=false \
                -Dtools-multicall=true \
                -Db_lto=true

ninja -C genbuild

builds without any errors...

I'm on the way to try with Funtoo.

@mihalicyn
Copy link
Member

mihalicyn commented Apr 7, 2024

Ok, tried with Funtoo. The same.

suited-marmot ~/lxc_pkg # cat /etc/os-release 
ID="funtoo"
NAME="Funtoo"
PRETTY_NAME="Funtoo Linux"
ANSI_COLOR="0;34"
HOME_URL="https://www.funtoo.org"
BUG_REPORT_URL="https://bugs.funtoo.org"
VERSION=1.4-release-std-2023-07-13
VERSION_ID=2023-07-13
suited-marmot ~/lxc_pkg # ld -v
GNU ld (Gentoo 2.36.1 p1) 2.36.1
suited-marmot ~/lxc_pkg # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9.2.0/configure --disable-libssp --disable-multilib --enable-version-specific-runtime-libs --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/9.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9.2.0 --enable-clocale=gnu --host=x86_64-pc-linux-gnu --enable-obsolete --disable-werror --enable-libmudflap --enable-secureplt --enable-lto --with-system-zlib --without-cloog --with-bugurl=http://bugs.funtoo.org --with-pkgversion='Funtoo 9.2.0' --enable-stage1-checking=assert,runtime,misc,tree,gc,rtlflag --enable-checking=assert,runtime --enable-languages=c,c++,fortran --disable-libgcj --enable-threads=posix --enable-__cxa_atexit --enable-libstdcxx-time --enable-libgomp --disable-bootstrap --enable-shared --build=x86_64-pc-linux-gnu --disable-libsanitizer --enable-default-pie --enable-default-ssp --disable-libstdcxx-pch --disable-vtable-verify --disable-libvtv --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/python --enable-nls --with-included-gettext --with-tune=generic
Thread model: posix
gcc version 9.2.0 (Funtoo 9.2.0) 
suited-marmot ~/lxc_pkg # meson -v
/usr/lib/python-exec/python3.7/meson:15: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import load_entry_point
1.1.1
meson setup funbuild \
                -Dtests=true \
                -Dman=false \
                -Dinit-script=sysvinit \
                -Dpam-cgroup=false \
                -Ddbus=false \
                -Dwerror=false \
                -Dtools-multicall=true \
                -Db_lto=true

ninja -C funbuild

builds just fine.

@geaaru any suggestions how to reproduce this?

@adamcstephens
Copy link
Contributor Author

adamcstephens commented Apr 8, 2024

#4428 did fix non-multicall for nix, but multicall still fails with

[561/561] Linking target src/lxc/tools/lxc
FAILED: src/lxc/tools/lxc
gcc  -o src/lxc/tools/lxc src/lxc/tools/lxc.p/lxc_multicall.c.o src/lxc/tools/lxc.p/arguments.c.o src/lxc/tools/lxc.p/.._.._include_netns_ifaddrs.c.o src/lxc/tools/lxc.p/lxc_attach.c.o src/lxc/tools/lxc.p/lxc_autostart.c.o src/lxc/tools/lxc.p/lxc_cgroup.c.o src/lxc/tools/lxc.p/lxc_checkpoint.c.o src/lxc/tools/lxc.p/lxc_config.c.o src/lxc/tools/lxc.p/lxc_console.c.o src/lxc/tools/lxc.p/lxc_copy.c.o src/lxc/tools/lxc.p/lxc_create.c.o src/lxc/tools/lxc.p/lxc_destroy.c.o src/lxc/tools/lxc.p/lxc_device.c.o src/lxc/tools/lxc.p/lxc_execute.c.o src/lxc/tools/lxc.p/lxc_freeze.c.o src/lxc/tools/lxc.p/lxc_info.c.o src/lxc/tools/lxc.p/lxc_ls.c.o src/lxc/tools/lxc.p/lxc_snapshot.c.o src/lxc/tools/lxc.p/lxc_start.c.o src/lxc/tools/lxc.p/lxc_stop.c.o src/lxc/tools/lxc.p/lxc_top.c.o src/lxc/tools/lxc.p/lxc_unfreeze.c.o src/lxc/tools/lxc.p/lxc_unshare.c.o src/lxc/tools/lxc.p/lxc_wait.c.o src/lxc/tools/lxc.p/lxc_monitor.c.o -flto -Wl,--no-undefined -pie -Wl,--no-as-needed -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now -fstack-protector -fstack-protector-strong -Wl,-fuse-ld=gold -Wl,--warn-common '-Wl,-rpath,$ORIGIN/../../..' -Wl,-rpath-link,/build/source/build/ -Wl,--start-group src/lxc/liblxc.a liblxc.so.1.8.0 /nix/store/qdah6gc69156iqaaji3hk2ryfckg5k9y-dbus-1.14.10-lib/lib/libdbus-1.so -pthread /nix/store/jssya8piz395z2yy90yshiqky5alimk2-libseccomp-2.5.5-lib/lib/libseccomp.so /nix/store/hmf4nmykf657qi7i0mra1jsfc7myy6m8-libselinux-3.6/lib/libselinux.so /nix/store/98l574asrjjnw0by1van3j4m814lzapi-libapparmor-3.1.7/lib/libapparmor.so /nix/store/p25ghy7y53lyc834xnw5mrhfq096wa4x-openssl-3.0.13/lib/libssl.so /nix/store/p25ghy7y53lyc834xnw5mrhfq096wa4x-openssl-3.0.13/lib/libcrypto.so /nix/store/afks7dzrymfc5lkzjn2wp7sry0k730bi-libcap-2.69-lib/lib/libcap.so -lutil -Wl,--end-group
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.3:(.text+0x123f): error: undefined reference to 'lxc_safe_uint'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0:(.text+0x13bb): error: undefined reference to 'lxc_safe_uint'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0:(.text+0x13de): error: undefined reference to 'lxc_namespace_2_std_identifiers'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0:(.text+0x13f5): error: undefined reference to 'lxc_fill_namespace_flags'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.0:(.text+0x141b): error: undefined reference to 'lxc_safe_uint'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.12:(.text+0x1597): error: undefined reference to 'lxc_safe_long'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.1:(.text+0x165b): error: undefined reference to 'lxc_safe_long'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.13:(.text+0x16aa): error: undefined reference to 'lxc_safe_int'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function get_config_integer:(.text+0x176b): error: undefined reference to 'lxc_safe_int'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function restore:(.text+0x1ba6): error: undefined reference to 'wait_for_pid'
/build/ccMZWcRr.ltrans0.ltrans.o:<artificial>:function my_parser.lto_priv.5:(.text+0x1d7c): error: undefined reference to 'get_fssize'
<snip>

setting -Db_lto=false allows the linking to succeed. setting it to true gives the same error as above, so I'll assume it's on by default in the nix build environment.

@geaaru
Copy link
Contributor

geaaru commented Apr 8, 2024

@mihalicyn hi, unlucky the current Incus images are related to Funtoo 1.4 EOL. The Funtoo Next images were disabled a few months ago for an issue with DHCP. I need to look at this to drop those images and restore funtoo Next.
Indeed, if you take a look at your output you use GCC 9.2.0 and old binutils.
Btw, you can use the Macaroni images at the moment only available over the our GARR mirror:
https://www.macaronios.org/docs/getting-started/#install-macaroni-lxd-containers
These Simplestreams server works with both LXD and Incus client. You can use the macaroni/phoenix-builder image for the test. On binutils changelog I see that binutils 2.40 that maybe could be the cause but I'm not sure.

@geaaru
Copy link
Contributor

geaaru commented Apr 8, 2024

I fear that could depend on something with sandbox container.... just try to compile it directly from the repo works, but using emerge on sandbox generates the issue. I dunno.

@geaaru
Copy link
Contributor

geaaru commented Apr 9, 2024

@mihalicyn Sorry, I'm a bit busy these days, I will try to share a way to reproduce my issues next weekend.

@mihalicyn
Copy link
Member

@mihalicyn Sorry, I'm a bit busy these days, I will try to share a way to reproduce my issues next weekend.

No problem. I'm a bit busy too right now, but I'll try to address this issue on this week.

@geaaru
Copy link
Contributor

geaaru commented Apr 17, 2024

Sorry for the delay. With these steps I can reproduce the issue every time with both multicall or without multicall mode.

$> docker run --rm -ti macaronios/phoenix-minimal-devel:latest-amd64
$> anise repo update 

$> anise i -y meta-repo meta-geaaru-kit binutils sys-devel-2.69/autoconf m4 automake gcc-config git diffutils baselayout meson ninja linux-headers libseccomp pkgconf gperf re2c pkgconfig cython wget ca-certificates dbus portage

$> gcc-config 1

$> source /etc/profile

$> cd /var/git/extra-kits/geaaru-kit

$> git checkout funtoo
$> git pull -ff

$> export FEATURES="-sandbox -usersandbox -ipc-sandbox -pid-sandbox -network-sandbox"
$> # without multicall
$> USE="lto " emerge lxc --nodeps 
$> # with multicall
$> USE="lto tools-multicall" emerge lxc --nodeps 

If I compile with -lto on USE it works correctly.

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

Successfully merging a pull request may close this issue.

4 participants