[systemd-devel] [PATCH 1/2] build-sys: merge libsystemd-login into libsystemd

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Jan 19 05:51:52 PST 2014


So, I prepared a test patch. This all doesn't seem to be too ugly generally,
although the warning generation in patch 2 is a bit.

Comments?

A compatibility libsystemd-login library is created which uses
.symver and ifunc magic proposed by Lennart to make programs linked
to the old library name continue to work seamlessly.

Unfortunately the bfd linker crashes:
  https://sourceware.org/bugzilla/show_bug.cgi?id=16467
As a work-around, gold can be used:
  LDFLAGS=-Wl,-fuse-ld=gold

This also doesn't work with LLVM:
  http://llvm.org/bugs/show_bug.cgi?id=11897
---

 .gitignore                     |   1 +
 Makefile.am                    | 125 +++++++++++++++++++----------------------
 src/libsystemd/libsystemd.sym  |  61 ++++++++++++++++++++
 src/login/libsystemd-login.sym |   7 ---
 4 files changed, 120 insertions(+), 74 deletions(-)

diff --git a/.gitignore b/.gitignore
index 115ec52..de49d2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@
 /hostnamectl
 /install-tree
 /journalctl
+/libsystemd-login.c
 /libtool
 /localectl
 /loginctl
diff --git a/Makefile.am b/Makefile.am
index b989fdd..9929e24 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@ LIBGUDEV_REVISION=3
 LIBGUDEV_AGE=1
 
 LIBSYSTEMD_LOGIN_CURRENT=9
-LIBSYSTEMD_LOGIN_REVISION=1
+LIBSYSTEMD_LOGIN_REVISION=2
 LIBSYSTEMD_LOGIN_AGE=9
 
 LIBSYSTEMD_DAEMON_CURRENT=0
@@ -1802,14 +1802,7 @@ systemctl_LDADD = \
 	libsystemd-units.la \
 	libsystemd-label.la \
 	libsystemd-internal.la \
-	libsystemd-logs.la
-
-if ENABLE_LOGIND
-systemctl_LDADD += \
-	libsystemd-login-internal.la
-endif
-
-systemctl_LDADD += \
+	libsystemd-logs.la \
 	libsystemd-journal-internal.la \
 	libsystemd-id128-internal.la \
 	libsystemd-daemon-internal.la \
@@ -2036,7 +2029,11 @@ libsystemd_la_SOURCES = \
 	src/libsystemd/rtnl-util.h \
 	src/libsystemd/rtnl-util.c \
 	src/libsystemd/sd-resolve.c \
-	src/libsystemd/resolve-util.h
+	src/libsystemd/resolve-util.h \
+	src/login/sd-login.c \
+	src/systemd/sd-login.h \
+	src/login/login-shared.c \
+	src/login/login-shared.h
 
 nodist_libsystemd_la_SOURCES = \
 	src/libsystemd/bus-error-mapping.c
@@ -3267,11 +3264,6 @@ libsystemd_journal_core_la_LIBADD = \
 	libsystemd-id128-internal.la \
 	libsystemd-shared.la
 
-if ENABLE_LOGIND
-libsystemd_journal_core_la_LIBADD += \
-	libsystemd-login-internal.la
-endif
-
 if HAVE_ACL
 libsystemd_journal_core_la_LIBADD += \
 	libsystemd-acl.la
@@ -3469,12 +3461,8 @@ systemd_coredump_SOURCES = \
 systemd_coredump_LDADD = \
 	libsystemd-journal-internal.la \
 	libsystemd-label.la \
-	libsystemd-shared.la
-
-if ENABLE_LOGIND
-systemd_coredump_LDADD += \
-	libsystemd-login-internal.la
-endif
+	libsystemd-shared.la \
+	libsystemd-internal.la
 
 rootlibexec_PROGRAMS += \
 	systemd-coredump
@@ -4235,14 +4223,14 @@ test_login_SOURCES = \
 	src/login/test-login.c
 
 test_login_LDADD = \
-	libsystemd-login-internal.la \
+	libsystemd-internal.la \
 	libsystemd-shared.la
 
 test_login_shared_SOURCES = \
 	src/login/test-login-shared.c
 
 test_login_shared_LDADD = \
-	libsystemd-login-internal.la \
+	libsystemd-internal.la \
 	libsystemd-shared.la
 
 test_inhibit_SOURCES = \
@@ -4268,29 +4256,6 @@ tests += \
 	test-login-tables \
 	test-login-shared
 
-libsystemd_login_la_SOURCES = \
-	src/login/libsystemd-login.sym \
-	src/login/sd-login.c \
-	src/systemd/sd-login.h \
-	src/login/login-shared.c \
-	src/login/login-shared.h
-
-libsystemd_login_la_CFLAGS = \
-	$(AM_CFLAGS) \
-	-fvisibility=hidden
-
-libsystemd_login_la_LDFLAGS = \
-	$(AM_LDFLAGS) \
-	-version-info $(LIBSYSTEMD_LOGIN_CURRENT):$(LIBSYSTEMD_LOGIN_REVISION):$(LIBSYSTEMD_LOGIN_AGE) \
-	-Wl,--version-script=$(top_srcdir)/src/login/libsystemd-login.sym
-
-libsystemd_login_la_LIBADD = \
-	libsystemd-daemon-internal.la \
-	libsystemd-shared.la
-
-libsystemd_login_internal_la_SOURCES = \
-	$(libsystemd_login_la_SOURCES)
-
 if HAVE_PAM
 pam_systemd_la_SOURCES = \
 	src/login/pam-module.c
@@ -4323,16 +4288,6 @@ dist_pamconf_DATA = \
 	src/login/systemd-user
 endif
 
-# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
-libsystemd-login-install-hook:
-	libname=libsystemd-login.so && $(move-to-rootlibdir)
-
-libsystemd-login-uninstall-hook:
-	rm -f $(DESTDIR)$(rootlibdir)/libsystemd-login.so*
-
-INSTALL_EXEC_HOOKS += libsystemd-login-install-hook
-UNINSTALL_EXEC_HOOKS += libsystemd-login-uninstall-hook
-
 nodist_systemunit_DATA += \
 	units/systemd-logind.service \
 	units/systemd-user-sessions.service
@@ -4353,15 +4308,6 @@ dist_pkgsysconf_DATA += \
 pkginclude_HEADERS += \
 	src/systemd/sd-login.h
 
-lib_LTLIBRARIES += \
-	libsystemd-login.la
-
-noinst_LTLIBRARIES += \
-	libsystemd-login-internal.la
-
-pkgconfiglib_DATA += \
-	src/login/libsystemd-login.pc
-
 polkitpolicy_files += \
 	src/login/org.freedesktop.login1.policy
 
@@ -4529,7 +4475,7 @@ login_la_LDFLAGS = \
 login_la_LIBADD = \
 	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-journal.la \
-	libsystemd-login.la \
+	libsystemd.la \
 	libsystemd-daemon-internal.la \
 	libsystemd-shared.la
 
@@ -4574,6 +4520,50 @@ clean-python:
 	-rm -f _daemon.la id128.la _journal.la login.la _reader.la
 
 # ------------------------------------------------------------------------------
+define generate-fake-lib
+	$(AM_V_at)$(MKDIR_P) $(dir $@)
+	$(AM_V_GEN)sed -r -n 's/^ +(sd_.*);/void new_\1(void);\n__asm__(".symver new_\1,\1 at LIBSYSTEMD_209");\nstatic void (*resolve_\1(void)) (void) {\n\treturn new_\1;\n}\nvoid \1(void) __attribute__((ifunc("resolve_\1")));\n/p' <$< >$@
+endef
+
+libsystemd_login_la_SOURCES = \
+	libsystemd-login.c \
+	src/login/libsystemd-login.sym
+
+libsystemd_login_la_CFLAGS = \
+	$(AM_CFLAGS) \
+	-fvisibility=default
+
+libsystemd_login_la_LDFLAGS = \
+	$(AM_LDFLAGS) \
+	-version-info $(LIBSYSTEMD_LOGIN_CURRENT):$(LIBSYSTEMD_LOGIN_REVISION):$(LIBSYSTEMD_LOGIN_AGE) \
+	-Wl,--version-script=$(top_srcdir)/src/login/libsystemd-login.sym
+
+libsystemd_login_la_LIBADD = \
+	libsystemd.la
+
+BUILT_SOURCES += \
+	libsystemd-login.c
+
+libsystemd-login.c: src/login/libsystemd-login.sym
+	$(generate-fake-lib)
+
+lib_LTLIBRARIES += \
+	libsystemd-login.la
+
+pkgconfiglib_DATA += \
+	src/login/libsystemd-login.pc
+
+# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
+libsystemd-login-install-hook:
+	libname=libsystemd-login.so && $(move-to-rootlibdir)
+
+libsystemd-login-uninstall-hook:
+	rm -f $(DESTDIR)$(rootlibdir)/libsystemd-login.so*
+
+INSTALL_EXEC_HOOKS += libsystemd-login-install-hook
+UNINSTALL_EXEC_HOOKS += libsystemd-login-uninstall-hook
+
+# ------------------------------------------------------------------------------
 substitutions = \
        '|rootlibexecdir=$(rootlibexecdir)|' \
        '|rootbindir=$(rootbindir)|' \
@@ -4989,7 +4979,8 @@ endef
 test-libsystemd-sym.c: \
 	src/libsystemd/libsystemd.sym \
 	src/systemd/sd-bus.h \
-	src/systemd/sd-utf8.h
+	src/systemd/sd-utf8.h \
+	src/systemd/sd-login.h
 	$(generate-sym-test)
 
 test-libsystemd-daemon-sym.c: \
diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index cda10ea..9bbe9bc 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -9,6 +9,67 @@
 
 LIBSYSTEMD_209 {
 global:
+
+        /* originally LIBSYSTEMD_LOGIN_31 */
+        sd_get_seats;
+        sd_get_sessions;
+        sd_get_uids;
+        sd_login_monitor_flush;
+        sd_login_monitor_get_fd;
+        sd_login_monitor_new;
+        sd_login_monitor_unref;
+        sd_pid_get_owner_uid;
+        sd_pid_get_session;
+        sd_seat_can_multi_session;
+        sd_seat_get_active;
+        sd_seat_get_sessions;
+        sd_session_get_seat;
+        sd_session_get_uid;
+        sd_session_is_active;
+        sd_uid_get_seats;
+        sd_uid_get_sessions;
+        sd_uid_get_state;
+        sd_uid_is_on_seat;
+
+        /* originally LIBSYSTEMD_LOGIN_38 */
+        sd_pid_get_unit;
+        sd_session_get_service;
+
+        /* originally LIBSYSTEMD_LOGIN_43 */
+        sd_session_get_type;
+        sd_session_get_class;
+        sd_session_get_display;
+
+        /* originally LIBSYSTEMD_LOGIN_186 */
+        sd_session_get_state;
+        sd_seat_can_tty;
+        sd_seat_can_graphical;
+
+        /* originally LIBSYSTEMD_LOGIN_198 */
+        sd_session_get_tty;
+
+        /* originally LIBSYSTEMD_LOGIN_201 */
+        sd_login_monitor_get_events;
+        sd_login_monitor_get_timeout;
+
+        /* originally LIBSYSTEMD_LOGIN_202 */
+        sd_pid_get_user_unit;
+        sd_pid_get_machine_name;
+
+        /* originally LIBSYSTEMD_LOGIN_203 */
+        sd_get_machine_names;
+
+        /* originally LIBSYSTEMD_LOGIN_205 */
+        sd_pid_get_slice;
+
+        /* originally LIBSYSTEMD_LOGIN_207 */
+        sd_session_get_vt;
+
+        /* new in LIBSYSTEMD_LOGIN_209 */
+        sd_session_is_remote;
+        sd_session_get_remote_user;
+        sd_session_get_remote_host;
+
         /* Same order as in sd-bus.h should be used */
 
         /* Connections */
diff --git a/src/login/libsystemd-login.sym b/src/login/libsystemd-login.sym
index 1d33982..54aa91c 100644
--- a/src/login/libsystemd-login.sym
+++ b/src/login/libsystemd-login.sym
@@ -85,10 +85,3 @@ LIBSYSTEMD_LOGIN_207 {
 global:
         sd_session_get_vt;
 } LIBSYSTEMD_LOGIN_205;
-
-LIBSYSTEMD_LOGIN_209 {
-global:
-        sd_session_is_remote;
-        sd_session_get_remote_user;
-        sd_session_get_remote_host;
-} LIBSYSTEMD_LOGIN_207;
-- 
1.8.1.rc0.194.gaf2e3a9



More information about the systemd-devel mailing list