Skip to content

Commit

Permalink
Ensure that the __clzsi2 symbol is present
Browse files Browse the repository at this point in the history
e310e36 solved static linking and the MinGW-w64 builds but included a
workaround for Rust 1.34 and 1.35 that didn't work for Rust 1.36.

The main problem with Rust 1.34 and 1.35 is that it included its own version
of the `__clzsi2` intrinsic instead of the C version. This caused duplicate
symbols during linking and required a workaround by removing the duplicated
symbol, see:
rust-lang/rust#58277

Fortunately, this is solved within rustc 1.36, see:
rust-lang/compiler-builtins@752e35a

The workaround, however, did not ensure that `__clzsi2` intrinsic is only
removed when it is duplicated (it could also remove the optimized C version).

This commit ensures that the `__clzsi2` intrinsic is present only once. Note
that the entire workaround can be removed when the minimum Rust version is
bumped to 1.36.

Closes: https://gitlab.gnome.org/GNOME/librsvg/issues/485
  • Loading branch information
kleisauke committed Jul 16, 2019
1 parent f304e84 commit 449fdcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ cargo_verbose_ = $(cargo_verbose_$(AM_DEFAULT_VERBOSITY))
cargo_verbose_0 =
cargo_verbose_1 = --verbose

RUST_LIB=@abs_top_builddir@/.libs/librsvg_internals.a
CARGO_TARGET_DIR=@abs_top_builddir@/target

LIBRSVG_BUILD_DIR=@abs_top_builddir@
LIBRSVG_TARGET_DIR=@abs_top_builddir@/target/@RUST_TARGET_SUBDIR@
CARGO_TARGET_DIR=$(LIBRSVG_BUILD_DIR)/target
LIBRSVG_TARGET_DIR=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)

RUST_LIB=$(LIBRSVG_BUILD_DIR)/.libs/librsvg_internals.a

check-local:
cd $(srcdir) && \
Expand Down Expand Up @@ -177,7 +177,9 @@ librsvg_internals.la: $(librsvg_internals_la_SOURCES)
LIBRSVG_BUILD_DIR=$(LIBRSVG_BUILD_DIR) \
LIBRSVG_TARGET_DIR=$(LIBRSVG_TARGET_DIR) \
$(CARGO) --locked build $(CARGO_VERBOSE) $(CARGO_TARGET_ARGS) $(CARGO_RELEASE_ARGS) --features "c-library" \
&& $(AR) d $(RUST_LIB) clzsi2.o # HACK: https://github.com/rust-lang/rust/issues/58277
&& if [[ $$($(NM) -g $(RUST_LIB) | grep "T __clzsi2" -c) -gt 1 ]] ; then \
$(AR) d $(RUST_LIB) clzsi2.o; \
fi

librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
-I$(top_srcdir) \
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ AS_IF(test x$RUSTC = xno,
AC_MSG_ERROR([rustc is required. Please install the Rust toolchain from https://www.rust-lang.org/])
)
AC_CHECK_PROGS(AR, ar)
AC_CHECK_PROGS(NM, nm)

dnl Minimum version of rustc that we support
dnl If you change this, please update COMPILING.md
Expand Down
2 changes: 1 addition & 1 deletion rsvg_internals/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::Path;
use std::os::unix::fs::symlink;

#[cfg(all(windows, not(target_env = "msvc")))]
use std::os::windows::fs::symlink_file;
use std::os::windows::fs::symlink_file as symlink;

#[cfg(not(target_env = "msvc"))]
use std::fs;
Expand Down

0 comments on commit 449fdcc

Please sign in to comment.