Source: erlang-p1-cache-tab Version: 1.0.9-1 Severity: serious Tags: sid buster patch
Hi, erlang-p1-cache-tab FTBFS on mips, mipsel and powerpc with this error while running the testsuite: > Failed to load NIF /<<PKGBUILDDIR>>/priv/lib/ets_cache: Failed to load NIF > library: '/<<PKGBUILDDIR>>/priv/lib/ets_cache.so: undefined symbol: > __sync_add_and_fetch_8' (load_failed) This happens because these architectures do not implement 64-bit atomics natively. The fix is to use libatomic (part of GCC) which provides helper routines for these missing atomics, implemented using locks. The attached patch does this by: - Linking against libatomic - Switching from __sync_add_and_fetch to __atomic_add_fetch One side effect of this is that libatomic is pulled in on every architecture. If you don't like this, you can use -Wl,--as-needed. Thanks, James
--- a/c_src/ets_cache.c +++ b/c_src/ets_cache.c @@ -100,7 +100,7 @@ static ERL_NIF_TERM incr_counter(ErlNifE if (enif_get_uint(env, argv[0], &counter)) if (counter < max_counters) { if (counters[counter] != MAX_UINT64) - return enif_make_uint64(env, __sync_add_and_fetch(counters + counter, 1)); + return enif_make_uint64(env, __atomic_add_fetch(counters + counter, 1, __ATOMIC_SEQ_CST)); } return enif_make_badarg(env); --- a/rebar.config +++ b/rebar.config @@ -24,7 +24,7 @@ {port_specs, [{"priv/lib/ets_cache.so", ["c_src/ets_cache.c"]}]}. -{port_env, [{"CFLAGS", "$CFLAGS -g -O2 -Wall"}]}. +{port_env, [{"CFLAGS", "$CFLAGS -g -O2 -Wall"}, {"LDFLAGS", "$LDFLAGS -latomic"}]}. {cover_enabled, true}. {cover_export_enabled, true}.
signature.asc
Description: OpenPGP digital signature