28 Commits

Author SHA1 Message Date
Jan Vaclav
12b5b8317b build: remove autotools configuration from scripts 2024-09-11 12:18:15 +00:00
Jan Vaclav
17ec5da34a contrib/fedora: update scripts to expect autotools deprecation
(cherry picked from commit 7b4acf938c)
2024-05-09 12:00:14 +02:00
Daniel Kolesa
97abbbb987 build: fix pretty() sed invocation portability in .ver script
The `\0` being used to refer to the whole match is a GNU
extension. On other implementations of sed, this will simply
replace the each matched line with `	0;`, resulting in symbols
being missing in the NetworkManager executable, which breaks the
wifi plugin and others.

Use `&` instead, which behaves as expected in all implementations.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1562
2023-03-07 08:02:22 +01:00
orbea
68913466af tools: use libtool --mode=execute
Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732

The original issue was that when compiling NetworkManager with slibtool
the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym
slibtool wrapper script to nm(1) instead of the actual binary. This is
because slibtool and GNU libtool do not place the compiled programs in
the same location. The original fix was to test both locations, but this
is bit of a hack especially since the build system should not be using the
.libs directory directly. However with $(LIBTOOL) --mode=execute this is
not a problem since both implementations can figure out where the correct
binary is.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805
2021-04-04 09:27:35 +02:00
Thomas Haller
ac1a9e03e4 all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
orbea
e643662348 tools: find the NetworkManager-all-sym binary location
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732
2021-01-26 19:34:00 +01:00
Thomas Haller
1b2bee0e76 build: fix "create-exports-NetworkManager.sh" to fail if "nm" fails
Despite `set -e`, the shell script does not fail if the command in the
here document fails. This can happen if binutils' "nm" fails.

  NM=/bin/false "./tools/create-exports-NetworkManager.sh" --called-from-build "."

(cherry picked from commit 7fe76f54e3)
2020-10-06 13:34:22 +02:00
Thomas Haller
c92a3ca5c2 build: fix generating "NetworkManager.ver" with LTO
We use a linker version script "NetworkManager.ver", to hide
symbols from NetworkManager that are not used. That is important
due to our habit of using internal helper libraries that we link
statically everywhere, without handpicking the symbols we actually
need. We want the tooling to get rid of unnecessary symbols.

However, NetworkManager loads shared libraries for settings and device
plugins. These libraries require symbols from the NetworkManager binary,
but which one depends on build options. Hence, we also generate
"NetworkManager.ver" by the "tools/create-exports-NetworkManager.sh"
script.

For that the script uses "nm" to find symbols that are undefined in the
plugin libraries but defined in NetworkManager. With autotools the
script looked at "./src/.libs/libNetworkManager.a" to find the present
symbols. Note that for meson that already didn't work, and we build
instead an intermediate NetworkManager binary first (with all symbols
exposed). With LTO, "nm" doesn't find all symbols in
"./src/.libs/libNetworkManager.a", and consequently they are not
exported and dropped/hidden.

This also causes unit tests to fail with LTO, because our test script
"tools/check-exports.sh" catches such bugs.

Fix that by also with autotools generate a complete "NetworkManager-all-sym"
binary that is used to generate "NetworkManager.ver", before rebuilding
"NetworkManager" again.
2020-08-17 15:18:05 +02:00
Thomas Haller
3b70efa9b6 tools: minor cleanup to ensure "from_meson" variable is yet set from extern 2020-08-12 12:10:33 +02:00
Thomas Haller
7b6f1c2d90 tools: export more symbols from NetworkManager binary to plugins
Plugins also may use nmtst_*() functions (when built with --with-more-asserts)
or c_list_*(). Whitelist them too.
2019-06-26 12:26:11 +02:00
Thomas Haller
74641be816 settings: drop ibft settings plugin
The functionality of the ibft settings plugin is now handled by
nm-initrd-generator. There is no need for it anymore, drop it.

Note that ibft called iscsiadm, which requires CAP_SYS_ADMIN to work
([1]). We really want to drop this capability, so the current solution
of a settings plugin (as it is implemented) is wrong. The solution
instead is nm-initrd-generator.

Also, on Fedora the ibft was disabled and probably on most other
distributions as well. This was only used on RHEL.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1371201#c7
2019-06-20 16:06:44 +02:00
Beniamino Galvani
1408ffd9f6 build: fix ibft option in create-exports-NetworkManager.sh 2018-10-24 22:10:31 +02:00
Thomas Haller
15857ad958 build: silence message in "tools/create-exports-NetworkManager.sh" about missing directory
When building with meson -Dppp=false, the following message is printed
during build:

  [623/671] Generating NetworkManager.ver with a custom command. find: ‘./src/ppp/’: No such file or directory

The message is harmless. Hide it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/43
2018-10-01 18:38:38 +02:00
Beniamino Galvani
19a718bc13 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
2018-09-19 16:03:32 +02:00
Beniamino Galvani
10ca2444b9 build: support meson builds in create-exports script
(cherry picked from commit 9b4bc0824c)
2018-09-13 14:35:25 +02:00
Thomas Haller
921db9132e build: fix whitelisting c-siphash symbols in NetworkManager.ver for device plugin
NetworkManager.ver needs to whitelist symbols needed by device,
settings, and ppp plugin. Fix the generator script to also allow
using c_siphash_*() symbols. These are needed by nm_hash_*().

Without this, wifi device plugin is broken.

Fixes: ccf36ff4ce
2018-09-05 16:55:45 +02:00
Thomas Haller
0474441e22 settings: drop unmaintained ifnet settings plugin of Gentoo
Even Gentoo disables this plugin since before 0.9.8 release
of NetworkManager. Time to say goodbye.

If somebody happens to show up to maintain it, we may resurrect it
later.

If "$distro_plugins=ifnet" was set, configure.ac would use that
to autodetect --with-hostname-persist=gentoo. Replace that autodetect
part by checking for /etc/gentoo-release file.
2017-12-21 10:50:33 +01:00
Lubomir Rintel
aa0707005c tools: fix the PowerPC build
On ppc archtecture the "nm_bt_vtable_network_server" symbol in the small
objects section instead of .bss, represencted by a "S" letter. Also
include "G" which is an equivalent thing for initialized data. We don't
seem to have such objects at the moment, but when we do it could result
in a nasty surprise.
2017-06-28 18:35:23 +02:00
Thomas Haller
484d666485 build: fix nm binutils tool when building with LTO
When building with -flto, we need to use linker plugins.
In case of binutils' nm, it means to prefer gcc-nm if
available.

Like for ranlib and ar, prefer gcc-nm.

- replace AC_PATH_TOOL() by AC_CHECK_TOOLS(). That is consistent
  with what we do for ar,ranlib and suggested on bgo#783311.
- instead of using the variable $BINUTILS_NM, replace it by
  $NM, which is more common according to bgo#783311.
- Keep recognizing $BINUTILS_NM environment, which was introduced
  by commit 8bc88bcc7c. This is purely to keep previous build
  scripts working. Originally I named it "$BINUTILS_NM" because
  using $NM in NetworkManager seemed confusing. But well...

https://bugs.gentoo.org/show_bug.cgi?id=620052
https://bugzilla.gnome.org/show_bug.cgi?id=782525
https://bugzilla.gnome.org/show_bug.cgi?id=783311
2017-06-01 12:51:31 +02:00
Lubomir Rintel
eb0228713d tools: only consider SOs that exist when finding symbols to export
Also, set pipefail to catch the failures of all components of a
pipeline.
2017-02-16 16:12:02 +01:00
Thomas Haller
8bc88bcc7c build: allow configuring path to binutils's nm tool during build
`nm` is used by "tools/create-exports-NetworkManager.sh" script.
Alloc configuring an explicit path during configure.

  BINUTILS_NM=/usr/bin/nm ./configure
2017-02-08 16:52:23 +01:00
Thomas Haller
0dfb5d2452 build: remove "src/NetworkManager.ver-orig"
Generating "src/NetworkManager.ver" each time seems to work well.
Thus, src/NetworkManager.ver-orig is unused an gets easily out
of date. Just remove it. It's not useful anymore.
2016-12-18 17:45:15 +01:00
Beniamino Galvani
025235e00f ppp: split ppp manager into a plugin
Moving the PPP manager to a separate plugin that is loaded when needed
has the advantage of slightly reducing memory footprint and makes it
possible to install the PPP support only where needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773482
2016-12-06 11:08:11 +01:00
Thomas Haller
7b78a931df build: generate src/NetworkManager.ver during build
This adds 0.4 seconds to the build time.

You can disable it by setting $NM_BUILD_NO_CREATE_EXPORTS environment
variable. This is useful in the unexpected case that the script
is broken.
Or, if you just want to use a different, non-generated version-script.
Or, if you want to save 0.4 seconds build-time.
2016-11-10 18:30:38 +01:00
Thomas Haller
aa3e44984a build: don't change directory in tools/create-exports-NetworkManager.sh
We shall call it from the makefile, thus the current directory is
$(top_builddir), which is just what we need.
2016-11-10 18:30:38 +01:00
Thomas Haller
f71d1dfffb build: improve tools/create-exports-NetworkManager.sh script
- include symbols from the "B" section.
- improve the script, to use libNetworkManager.a instead
  of the NetworkManager binary. The former is before stripping
  symbols.
2016-11-10 18:30:38 +01:00
Lubomir Rintel
1cc4ff3716 tools: fix the create-exports script on 32-bit 2016-11-06 15:36:24 +01:00
Thomas Haller
b171fbc9ca build: explicitly whitelist symbols in NetworkManager binary
- this allows the linker to drop unused symbols via link-time optimization
  or with --gc-sections:

    git clean -fdx
    ./autogen.sh --enable-ld-gc --enable-ifcfg-rh --enable-ifupdown \
        --enable-ifnet --enable-ibft --enable-teamdctl --enable-wifi \
        --with-modem-manager-1 --with-ofono --with-more-asserts \
        --with-more-logging
    make -j20
    strip ./src/NetworkManager

  gives 2822840 vs. 2625960 bytes (-7%).

- this also gives more control over the symbols that are used by the
  plugins. Yes, it means if you modify a plugin to use a new symbols,
  you have to extend NetworkManager.ver file.
  You can run the script to create the version file:

    $ ./tools/create-exports-NetworkManager.sh update

  but be sure that your current configuration enables all plugins
  and debugging options to actually use all symbols that are in use.

- If you compile with certain plugins enabled, you could theoretically
  re-compile NetworkManager to expose less symbols. Try:

    $ ./tools/create-exports-NetworkManager.sh build

- note that we have `make check` tests to ensure that all used
  symbols of the plugins can be found. So, it should not be possible
  to accidentally forget to expose a symbol.
2016-10-13 21:33:33 +02:00