Skip to contentSkip to conversation

package/erlang: fix detection of libatomic_ops

PATCH New Yann E. MORIN 2 participants 2 messages Jan 4, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/erlang: fix detection of libatomic_ops

For some platforms, hardware-assisted compare-and-swap may not be available, so libatomic will not provide it.

However, libatomic_ops can provide a puerly software CASE emulation, but must be instructed to do so. erlang just forgot to tell libatomic_ops that it does require CAS.

Fix that by defining AO_REQUIRE_CAS before including atmoic_ops.h, like is done in libunwind, as pointed out by Thomas.

Also, erlang has a convoluted, mind-alterating set on aclocal.m4 macros, that just forgets to link against -latomic_ops when checking CAS is available, so that even if CAS is available, configure chokes.

Since I would like to keep the little sanity I still have, just force linking with -latomic_ops. This is useless when the check is natrally sucessful (i.e. on platforms where CAS is available in HW), but we would eventually link with -latomic_ops there, too; it's just redundant.

Overall, just consider that erlang requires libatomic_ops, so forcibly depend on it, it is easier than trying to disable it. We can revisit that whenever someone wants to run erlang on a platform for which there is no libatomic_ops support.

Fixes a slew of autobuild ARM failures:

    http://autobuild.buildroot.org/results/e7b/e7bfc4893dea6b133f0794ef44d50ad89bcb6662/
    http://autobuild.buildroot.org/results/3e9/3e9c307f1ec6536482641019dcaa94677f7267a3/
    http://autobuild.buildroot.org/results/a85/a85ca414e5b67af46510abd7b610eb5ae8661de4/
    [...]
Cc Thomas Petazzoni <[email protected]>
Cc Frank Hunleth <[email protected]>
---
 ...erlang-build-fix.patch => 0001-build-fix.patch} |  0
 ...d-instruct-libatomic_ops-we-do-require-CA.patch | 70 ++++++++++++++++++++++
 package/erlang/Config.in                           |  2 +
 package/erlang/erlang.mk                           |  7 ++-
 4 files changed, 76 insertions(+), 3 deletions(-)
 rename package/erlang/{erlang-build-fix.patch => 0001-build-fix.patch} (100%)
 create mode 100644 package/erlang/0002-erts-ethread-instruct-libatomic_ops-we-do-require-CA.patch
package/erlang/0001-build-fix.patch renamed from package/erlang/erlang-build-fix.patch +0 -0
similarity index 100%
rename from package/erlang/erlang-build-fix.patch
rename to package/erlang/0001-build-fix.patch
package/erlang/0002-erts-ethread-instruct-libatomic_ops-we-do-require-CA.patch new file +70 -0

70 lines not on this page · raw message

package/erlang/Config.in +2 -0
index 56830da..2eb9eba 100644
@@ -6,6 +6,8 @@ config BR2_PACKAGE_ERLANG
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on !BR2_STATIC_LIBS
+	depends on BR2_PACKAGE_LIBATOMIC_ARCH_SUPPORTS
+	select BR2_PACKAGE_LIBATOMIC_OPS
 	help
 	  Erlang is a programming language used to build massively scalable
 	  soft real-time systems with requirements on high availability.
package/erlang/erlang.mk +4 -3
index 0b8619e..81ac436 100644
@@ -13,6 +13,9 @@ ERLANG_LICENSE = EPL
 ERLANG_LICENSE_FILES = EPLICENCE
 ERLANG_INSTALL_STAGING = YES
 
+# Touching erts/configure.in
+ERLANG_AUTORECONF = YES
+
 # The configure checks for these functions fail incorrectly
 ERLANG_CONF_ENV = ac_cv_func_isnan=yes ac_cv_func_isinf=yes
 
@@ -22,10 +25,8 @@ ERLANG_CONF_ENV += erl_xcomp_sysroot=$(STAGING_DIR)
 
 ERLANG_CONF_OPTS = --without-javac
 
-ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y)
 ERLANG_DEPENDENCIES += libatomic_ops
-ERLANG_CONF_OPTS += --with-libatomic_ops=$(STAGING_DIR)/usr
-endif
+ERLANG_CONF_OPTS += --with-libatomic_ops=$(STAGING_DIR)/usr LIBS=-latomic_ops
 
 # erlang uses openssl for all things crypto. Since the host tools (such as
 # rebar) uses crypto, we need to build host-erlang with support for openssl.
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/erlang: fix detection of libatomic_ops

Yann, Frank,

Quoted 4 lines · Yann E. MORIN

For some platforms, hardware-assisted compare-and-swap may not be available, so libatomic will not provide it.

However, libatomic_ops can provide a puerly software CASE emulation, but

puerly -> purely
CASE -> CAS

package/erlang/Config.in config BR2_PACKAGE_ERLANG · line 9

Quoted 9 lines
package/erlang/Config.in +1 -0
index 56830da..2eb9eba 100644
@@ -6,6 +6,8 @@ config BR2_PACKAGE_ERLANG
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on !BR2_STATIC_LIBS
+	depends on BR2_PACKAGE_LIBATOMIC_ARCH_SUPPORTS

-> new dependency that must be propagated to the comment.

I've committed your patch with those two issues fixed, and I've added a follow-up commit to further fix the dependencies of the comment, which were already wrong.

Frank, do not hesitate to report about your testing after this patch. It would be interesting if you could provide some simple test cases to test the Erlang stuff, so that padawans like me can easily do a simple testing of whether it still works or not.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com