Skip to content

Commit a468ff0

Browse files
committed
Improve lib name workaround for Rust *-pc-windows-gnu targets
Commit e310e36 introduced a workaround for Rust *-pc-windows-gnu targets which no longer seems necessary when Rust 1.44 is released, see: rust-lang/rust#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 8cea2b3 and simplified it into a file that is generated and used during the build process.
1 parent 4b42512 commit a468ff0

File tree

4 files changed

+15
-34
lines changed

4 files changed

+15
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ librsvg-2.0.vapi
7878
librsvg-*.tar.xz
7979
librsvg-*.tar.bz2
8080
rust/target
81+
_rsvg_dummy.c

Makefile.am

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ NULL =
55
lib_LTLIBRARIES = librsvg-@[email protected]
66
noinst_LTLIBRARIES = librsvg_c_api.la
77

8+
# Some systems, reportedly OpenBSD and Mac OS X, refuse
9+
# to create libraries without any object files. Compiling
10+
# this file, and adding its object file to the library,
11+
# will prevent the library from being empty.
12+
BUILT_SOURCES = _rsvg_dummy.c
13+
_rsvg_dummy.c:
14+
echo "static int __attribute__((unused)) __rsvg_dummy;" > _rsvg_dummy.c
15+
816
# Automake wants to have a C sources list for LTLIBRARIES.
917
# See LIBRSVG_INTERNALS_SRC below for the real list of Rust
1018
# sources.
11-
librsvg_c_api_la_SOURCES = librsvg/dummy.c
19+
librsvg_c_api_la_SOURCES = _rsvg_dummy.c
1220

1321
bin_PROGRAMS = rsvg-convert
1422

@@ -151,8 +159,9 @@ cargo_verbose_1 = --verbose
151159
LIBRSVG_BUILD_DIR=@abs_top_builddir@
152160
CARGO_TARGET_DIR=$(LIBRSVG_BUILD_DIR)/target
153161

154-
if PLATFORM_WIN32
155-
# https://github.com/rust-lang/rust/issues/43749
162+
if LIB_NAME_WORKAROUND
163+
# Workaround for https://github.com/rust-lang/rust/issues/69904
164+
# can be removed when our minimum Rust version is at least 1.44.
156165
RUST_LIB=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)/rsvg_c_api.lib
157166
else
158167
RUST_LIB=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)/librsvg_c_api.a
@@ -316,7 +325,7 @@ nodist_gir_DATA = $(INTROSPECTION_GIRS)
316325
typelibsdir = $(libdir)/girepository-1.0
317326
nodist_typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
318327

319-
CLEANFILES = $(nodist_gir_DATA) $(nodist_typelibs_DATA)
328+
CLEANFILES = $(BUILT_SOURCES) $(nodist_gir_DATA) $(nodist_typelibs_DATA)
320329

321330
if ENABLE_VAPIGEN
322331
include $(VAPIGEN_MAKEFILE)

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ case "$host" in
140140
esac
141141
AC_MSG_RESULT([$platform_win32])
142142
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
143+
AM_CONDITIONAL(LIB_NAME_WORKAROUND, test "$platform_win32" = "yes" -a \( "$major" -lt 1 -o "$minor" -lt 44 \))
143144

144145
AC_MSG_CHECKING([for native Win32])
145146
case "$host" in

librsvg/dummy.c

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)