Skip to content

Commit 449fdcc

Browse files
committed
Ensure that the __clzsi2 symbol is present
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
1 parent f304e84 commit 449fdcc

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Makefile.am

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ cargo_verbose_ = $(cargo_verbose_$(AM_DEFAULT_VERBOSITY))
136136
cargo_verbose_0 =
137137
cargo_verbose_1 = --verbose
138138

139-
RUST_LIB=@abs_top_builddir@/.libs/librsvg_internals.a
140-
CARGO_TARGET_DIR=@abs_top_builddir@/target
141-
142139
LIBRSVG_BUILD_DIR=@abs_top_builddir@
143-
LIBRSVG_TARGET_DIR=@abs_top_builddir@/target/@RUST_TARGET_SUBDIR@
140+
CARGO_TARGET_DIR=$(LIBRSVG_BUILD_DIR)/target
141+
LIBRSVG_TARGET_DIR=$(CARGO_TARGET_DIR)/$(RUST_TARGET_SUBDIR)
142+
143+
RUST_LIB=$(LIBRSVG_BUILD_DIR)/.libs/librsvg_internals.a
144144

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

182184
librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
183185
-I$(top_srcdir) \

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ AS_IF(test x$RUSTC = xno,
109109
AC_MSG_ERROR([rustc is required. Please install the Rust toolchain from https://www.rust-lang.org/])
110110
)
111111
AC_CHECK_PROGS(AR, ar)
112+
AC_CHECK_PROGS(NM, nm)
112113

113114
dnl Minimum version of rustc that we support
114115
dnl If you change this, please update COMPILING.md

rsvg_internals/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::Path;
77
use std::os::unix::fs::symlink;
88

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

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

0 commit comments

Comments
 (0)