Skip to content

Allow building with clang + lto

Tom Stellard requested to merge tstellar1/NetworkManager:clang-lto-fix into main

The configure script was requiring the -flto-partition in order to build with lto, but this is a gcc-specific flag.

I had to write my own code to detect clang as the compiler. There is also a macro for this: https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html#ax_compiler_vendor but I wasn't sure if using these ax_* macros was allowed in the source.

This problem was reported an issue #593 (closed). With this patch the configure script succeeds, but the build fails with this error:

/usr/bin/ld: /tmp/lto-llvm-0f3f19.o: in function nm_device_get_metered': /builddir/build/BUILD/NetworkManager-1.32.12/src/libnm-client-impl/nm-device.c:2198: multiple definition of nm_device_get_metered' /usr/bin/ld: /tmp/lto-llvm-0f3f19.o: in function nm_access_point_get_last_seen': /builddir/build/BUILD/NetworkManager-1.32.12/src/libnm-client-impl/nm-access-point.c:231: multiple definition of nm_access_point_get_last_s /usr/bin/ld: /tmp/lto-llvm-0f3f19.o: in function nm_device_wifi_request_scan_options': /builddir/build/BUILD/NetworkManager-1.32.12/src/libnm-client-impl/nm-device-wifi.c:305: multiple definition of nm_device_wifi_request_scan /usr/bin/ld: /tmp/lto-llvm-0f3f19.o: in function nm_device_wifi_request_scan_options_async': /builddir/build/BUILD/NetworkManager-1.32.12/src/libnm-client-impl/nm-device-wifi.c:379: multiple definition of nm_device_wifi_request_scan clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

It appears that this problem is related to the use of the NM_BACKPORT_SYMBOL macro which also seems to have caused an issue with gcc LTO see issue #63 (closed).

Edited by Tom Stellard

Merge request reports

Loading