From bfdb2262b20ed41c6b8fbff661ecd0e35c3ee8e6 Mon Sep 17 00:00:00 2001 From: William Brown Date: Aug 26 2019 22:31:08 +0000 Subject: Ticket 50564 - Fix rust libraries by default and improve docker Bug Description: Rust libraries were not installed properly due to quirks of autotools and cargo. Containers as a result couldn't start in some cases. Fix Description: Fix this by building rust libraries as static libs and linking them into existing .so files instead. https://pagure.io/389-ds-base/pull-request/50564 Author: William Brown Review by: ??? --- diff --git a/Makefile.am b/Makefile.am index b301ae7..5fe0069 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1183,32 +1183,36 @@ libsds_la_LDFLAGS = $(AM_LDFLAGS) $(SDS_LDFLAGS) if RUST_ENABLE +noinst_LTLIBRARIES = librsds.la + ### Why does this exist? # -# Both cargo and autotools are really opinionated. You can't generate the correct -# outputs from cargo/rust for automake to use. But by the same token, you can't -# convince automake to use the outputs we *do* have. So instead, we manually -# create and install the .so instead. +# Both cargo and autotools are really opinionated. It's really hard to make this work. :( # -# This acts like .PHONY for some reason ... +# https://people.gnome.org/~federico/blog/librsvg-build-infrastructure.html +# https://gitlab.gnome.org/GNOME/librsvg/blob/master/Makefile.am + +RSDS_LIB = @abs_top_builddir@/rs/@rust_target_dir@/librsds.a + +libsds_la_LIBADD = $(RSDS_LIB) + +librsds_la_SOURCES = \ + src/libsds/Cargo.toml \ + src/libsds/sds/lib.rs \ + src/libsds/sds/tqueue.rs + +librsds_la_EXTRA = src/libsds/Cargo.lock + +@abs_top_builddir@/rs/@rust_target_dir@/librsds.a: $(librsds_la_SOURCES) + CARGO_TARGET_DIR=$(abs_top_builddir)/rs RUSTC_BOOTSTRAP=1 \ + cargo rustc --manifest-path=$(srcdir)/src/libsds/Cargo.toml --locked \ + $(CARGO_FLAGS) --verbose -- $(RUSTC_FLAGS) -libsds_la_LDFLAGS += -L$(abs_builddir)/.libs -lrsds -libsds_la_DEPENDENCIES = librsds.so +EXTRA_DIST = $(librsds_la_SOURCES) $(librsds_la_EXTRA) -librsds.so: src/libsds/Cargo.toml src/libsds/sds/lib.rs src/libsds/sds/tqueue.rs +check-local: CARGO_TARGET_DIR=$(abs_top_builddir)/rs RUSTC_BOOTSTRAP=1 \ - cargo rustc $(CARGO_FLAGS) --verbose --manifest-path=$(srcdir)/src/libsds/Cargo.toml \ - -- $(RUSTC_FLAGS) - mkdir -p $(abs_builddir)/.libs - cp $(abs_top_builddir)/rs/@rust_target_dir@/librsds.so $(abs_builddir)/.libs/librsds.so - -dist_noinst_DATA += $(srcdir)/src/libsds/Cargo.toml \ - $(srcdir)/src/libsds/sds/*.rs - -# echo $(serverdir) -install-data-local: - $(MKDIR_P) $(DESTDIR)$(serverdir) - $(INSTALL) -c -m 755 $(abs_builddir)/.libs/librsds.so $(DESTDIR)$(serverdir)/librsds.so + cargo test --manifest-path=$(srcdir)/src/libsds/Cargo.toml --locked else # Just build the tqueue in C. diff --git a/docker/389-ds-suse/Dockerfile b/docker/389-ds-suse/Dockerfile index 2e0b5f4..9db8b2d 100644 --- a/docker/389-ds-suse/Dockerfile +++ b/docker/389-ds-suse/Dockerfile @@ -12,8 +12,7 @@ RUN zypper ar http://download.opensuse.org/update/leap/15.1/oss/ u && \ zypper --gpg-auto-import-keys ref RUN zypper --non-interactive si --build-deps-only 389-ds && \ - zypper in -y 389-ds rust cargo rust-std libevent && \ - zypper rm -y 389-ds + zypper in -y acl cargo cyrus-sasl cyrus-sasl-plain db48-utils krb5-client libLLVM7 libedit0 libgit2-26 libhttp_parser2_7_1 libssh2-1 mozilla-nss-tools rust # Install build dependencies # RUN zypper in -C -y autoconf automake cracklib-devel cyrus-sasl-devel db-devel doxygen gcc-c++ \ diff --git a/src/libsds/Cargo.toml b/src/libsds/Cargo.toml index 2c57e66..6c035ae 100644 --- a/src/libsds/Cargo.toml +++ b/src/libsds/Cargo.toml @@ -8,9 +8,9 @@ authors = ["William Brown "] [lib] path = "sds/lib.rs" name = "rsds" -crate-type = ["cdylib"] +crate-type = ["staticlib", "lib"] [profile.release] panic = "abort" -# lto = true +lto = true