[librsvg: 1/2] Improve lib name workaround for Rust *-pc-windows-gnu targets



commit a468ff0904285a5ec84369232c5d8719a6555cfb
Author: Kleis Auke Wolthuizen <github kleisauke nl>
Date:   Tue Apr 14 21:15:08 2020 +0200

    Improve lib name workaround for Rust *-pc-windows-gnu targets
    
    Commit e310e36b introduced a workaround for Rust *-pc-windows-gnu targets
    which no longer seems necessary when Rust 1.44 is released, see:
    https://github.com/rust-lang/rust/pull/70937
    
    This commit ensures that this workaround is only applied to Rust versions prior to
    1.44 assuming that the above pull request will not be reverted.
    
    I also removed the dummy.c file introduced in commit 8cea2b36 and simplified it
    into a file that is generated and used during the build process.

 .gitignore      |  1 +
 Makefile.am     | 17 +++++++++++++----
 configure.ac    |  1 +
 librsvg/dummy.c | 30 ------------------------------
 4 files changed, 15 insertions(+), 34 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 3dd4cae4..072ddc67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ librsvg-2.0.vapi
 librsvg-*.tar.xz
 librsvg-*.tar.bz2
 rust/target
+_rsvg_dummy.c
diff --git a/Makefile.am b/Makefile.am
index 98e4cbf2..8e8ed26f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,10 +5,18 @@ NULL =
 lib_LTLIBRARIES = librsvg-@RSVG_API_MAJOR_VERSION@.la
 noinst_LTLIBRARIES = librsvg_c_api.la
 
+# Some systems, reportedly OpenBSD and Mac OS X, refuse
+# to create libraries without any object files. Compiling
+# this file, and adding its object file to the library,
+# will prevent the library from being empty.
+BUILT_SOURCES = _rsvg_dummy.c
+_rsvg_dummy.c:
+       echo "static int __attribute__((unused)) __rsvg_dummy;" > _rsvg_dummy.c
+
 # Automake wants to have a C sources list for LTLIBRARIES.
 # See LIBRSVG_INTERNALS_SRC below for the real list of Rust
 # sources.
-librsvg_c_api_la_SOURCES = librsvg/dummy.c
+librsvg_c_api_la_SOURCES = _rsvg_dummy.c
 
 bin_PROGRAMS = rsvg-convert
 
@@ -151,8 +159,9 @@ cargo_verbose_1 = --verbose
 LIBRSVG_BUILD_DIR=@abs_top_builddir@
 CARGO_TARGET_DIR=$(LIBRSVG_BUILD_DIR)/target
 
-if PLATFORM_WIN32
-# https://github.com/rust-lang/rust/issues/43749
+if LIB_NAME_WORKAROUND
+# Workaround for https://github.com/rust-lang/rust/issues/69904
+# can be removed when our minimum Rust version is at least 1.44.
 RUST_LIB=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)/rsvg_c_api.lib
 else
 RUST_LIB=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)/librsvg_c_api.a
@@ -316,7 +325,7 @@ nodist_gir_DATA = $(INTROSPECTION_GIRS)
 typelibsdir = $(libdir)/girepository-1.0
 nodist_typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 
-CLEANFILES = $(nodist_gir_DATA) $(nodist_typelibs_DATA)
+CLEANFILES = $(BUILT_SOURCES) $(nodist_gir_DATA) $(nodist_typelibs_DATA)
 
 if ENABLE_VAPIGEN
 include $(VAPIGEN_MAKEFILE)
diff --git a/configure.ac b/configure.ac
index 9f88860f..64e07293 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,6 +140,7 @@ case "$host" in
 esac
 AC_MSG_RESULT([$platform_win32])
 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
+AM_CONDITIONAL(LIB_NAME_WORKAROUND, test "$platform_win32" = "yes" -a \( "$major" -lt 1 -o "$minor" -lt 44 
\))
 
 AC_MSG_CHECKING([for native Win32])
 case "$host" in


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]