linuxmint / cinnamon-control-center

A collection of configuration plugins used in cinnamon-settings
GNU General Public License v2.0
62 stars 67 forks source link

4.8.0 faills to build with networkmanager=true, modemmanager=false #254

Closed tkemmer closed 3 years ago

tkemmer commented 3 years ago
 * cinnamon-control-center version 4.8.0
 * Distribution - Gentoo Linux (binaryden overlay)
 * Graphics hardware *and* driver used: NVIDIA GTX 1050 Ti, nvidia-drivers 455.38
 * 64 bit

Issue Compilation fails for the specific combination of meson options networkmanager=true and modemmanager=false:

[96/99] Linking target panels/network/libnetwork.so
FAILED: panels/network/libnetwork.so 
cc  -o panels/network/libnetwork.so panels/network/libnetwork.so.p/meson-generated_.._cc-network-resources.c.o panels/network/libnetwork.so.p/cc-network-panel.c.o panels/network/libnetwork.so.p/net-device-ethernet.c.o panels/network/libnetwork.so.p/net-device-simple.c.o panels/network/libnetwork.so.p/net-device-wifi.c.o panels/network/libnetwork.so.p/net-device.c.o panels/network/libnetwork.so.p/net-object.c.o panels/network/libnetwork.so.p/net-proxy.c.o panels/network/libnetwork.so.p/net-vpn.c.o panels/network/libnetwork.so.p/network-dialogs.c.o panels/network/libnetwork.so.p/network-module.c.o panels/network/libnetwork.so.p/panel-common.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libnetwork.so -Wl,--whole-archive panels/network/connection-editor/libconnection_editor.a -Wl,--no-whole-archive shell/libcinnamon-control-center.so.1.0.0 panels/network/wireless-security/libwireless_security.a /usr/lib64/libglib-2.0.so /usr/lib64/libgtk-3.so /usr/lib64/libgdk-3.so /usr/lib64/libpangocairo-1.0.so /usr/lib64/libpango-1.0.so /usr/lib64/libatk-1.0.so /usr/lib64/libcairo-gobject.so /usr/lib64/libcairo.so /usr/lib64/libgdk_pixbuf-2.0.so /usr/lib64/libgio-2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libnm.so /usr/lib64/libnma.so /usr/lib64/libpolkit-gobject-1.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/../../shell' -Wl,-rpath-link,/home/thomas/tmp/cinnamon-control-center/build/shell
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: panels/network/libnetwork.so.p/cc-network-panel.c.o: in function `panel_add_device':
/home/thomas/tmp/cinnamon-control-center/build/../panels/network/cc-network-panel.c:655: undefined reference to `net_device_mobile_get_type'
collect2: error: ld returned 1 exit status

Steps to reproduce meson <src_folder> -Dnetworkmanager=true -Dmodemmanager=false && ninja

Expected behaviour Build success.

Other information The function in question (net_device_mobile_get_type) is provided by net-devices-mobile.c, which is only included when modemmanager is found. https://github.com/linuxmint/cinnamon-control-center/blob/13477da648f4f0771ebe4b397f9f825c0868014c/panels/network/meson.build#L23-L25

However, the function is used unconditionally in https://github.com/linuxmint/cinnamon-control-center/blob/13477da648f4f0771ebe4b397f9f825c0868014c/panels/network/cc-network-panel.c#L655 leading to the error above.

Soapux commented 3 years ago

I've hit this same issue. I think this is a meson build rule issue, because it looks like the only thing that has changed in the relevant files is that it's using meson now. Version 4.6.2 builds fine with networkmanager on and modemmanager off.

One thing I noticed was the dependencies of panel_network library. It unconditionally requires modemmanager: https://github.com/linuxmint/cinnamon-control-center/blob/13477da648f4f0771ebe4b397f9f825c0868014c/panels/network/meson.build#L28-L44

It should probably be something like this:

network_deps = [
  glib,
  gtk,
  libnm,
  libnma,
  polkit_gobj,
]

 if get_option('modemmanager')
   network_deps += modemmanager
 endif

panel_network = shared_library('network',
  panel_network_sources,
  include_directories: rootInclude,
  link_whole: [
    libconnection_editor,
  ],
  link_with: [
    libcinnamon_control_center,
  ],
  dependencies: network_deps,

  install: true,
  install_dir: panels_dir
)

It still fails for me with that change though, so I must be something else going on.

Soapux commented 3 years ago

@Salamandar wondering if you have any idea?

SparkyBluefang commented 3 years ago

The unconditional modemmanager dependency shouldn't be a problem because meson will ignore dependencies that are not found.

net-device-mobile.h is being included, which contains both NET_TYPE_DEVICE_MOBILE and net_device_mobile_get_type, so the define is being resolved but the GType symbol is not.

#define NET_TYPE_DEVICE_MOBILE          (net_device_mobile_get_type ())
GType            net_device_mobile_get_type             (void);

It seems like this symbol is getting stripped out during compilation/linking or glib isn't declaring the type correctly. But this is testing the limits of my minimal C and nonexistent glib knowledge.

Salamandar commented 3 years ago

Oooops, the message i wrote 2 weeks ago didn't send.

Yeah, so as said @SparkyBluefang, the modemmanager dependency isn't an issue as it's a not-found dependency.

Also, this looks like a code issue because cc-network-panel.c should not include net-device-mobile.h if BUILD_MODEM is undefined.

I'm going to push a Merge Request soon, it only adds two #ifdef BUILD_MODEM in cc-network-panel.c and resolves the issue. It needs more testing though.

Salamandar commented 3 years ago

@tkemmer Could you give a minute to test my fork ? If you're too lazy to add a remote and fetch (I would be) the diff is only 4 lines :)

tkemmer commented 3 years ago

@Salamandar Thanks! I can confirm that the build error is gone now but I still need to do some runtime testing, though