Skip to content

Commit

Permalink
Improve lib name workaround for Rust *-pc-windows-gnu targets
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kleisauke committed Apr 14, 2020
1 parent 4b42512 commit a468ff0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ librsvg-2.0.vapi
librsvg-*.tar.xz
librsvg-*.tar.bz2
rust/target
_rsvg_dummy.c
17 changes: 13 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 0 additions & 30 deletions librsvg/dummy.c

This file was deleted.

0 comments on commit a468ff0

Please sign in to comment.