Browse Source

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 <[email protected]>

Review by: ???
William Brown 6 years ago
parent
commit
bfdb2262b2
3 changed files with 27 additions and 24 deletions
  1. 24 20
      Makefile.am
  2. 1 2
      docker/389-ds-suse/Dockerfile
  3. 2 2
      src/libsds/Cargo.toml

+ 24 - 20
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.

+ 1 - 2
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++ \

+ 2 - 2
src/libsds/Cargo.toml

@@ -8,9 +8,9 @@ authors = ["William Brown <[email protected]>"]
 [lib]
 path = "sds/lib.rs"
 name = "rsds"
-crate-type = ["cdylib"]
+crate-type = ["staticlib", "lib"]
 
 [profile.release]
 panic = "abort"
-# lto = true
+lto = true