eal/arm: fix clang build of native target
PATCH 1/1 eal/arm: fix clang build of native target
When doing Clang build with '-mcpu=native' on N1 platform, build failed with:../lib/librte_eal/arm/include/rte_atomic_64.h:76:39:
error: instruction requires: lse__ATOMIC128_CAS_OP(__cas_128_release, "caspl")
This is because native detection for Neoverse N1 was added in Clang-11. Prior version of Clang's assembler doesn't know LSE support on hardware. Fixed this for Clang earlier than version 11 by specifying architecture for assembler.
Referred to [1] for this fix.
--- lib/librte_eal/arm/include/rte_atomic_64.h | 4 ++++ 1 file changed, 4 insertions(+)
lib/librte_eal/arm/include/rte_atomic_64.h +4 -0
@@ -46,6 +46,8 @@ rte_atomic_thread_fence(int memorder)/*------------------------ 128 bit atomic operations -------------------------*/ #if defined(__ARM_FEATURE_ATOMICS) || defined(RTE_ARM_FEATURE_ATOMICS ) +#define __LSE_PREAMBLE ".arch armv8-a+lse\n" +#define __ATOMIC128_CAS_OP (cas_op_name, op_string) \ static __rte_noinline rte_int128_t \ cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated) \
@@ -59,6 +61,7 @@ cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated) \ register uint64_t x2 __asm("x2") = (uint64_t)updated.val[0]; \ register uint64_t x3 __asm("x3") = (uint64_t)updated.val[1]; \ asmvolatile ( \ + __LSE_PREAMBLE \ op_string " %[old0], %[old1], %[upd0], %[upd1], [%[dst]]" \ : [old0]"+r" (x0), \ [old1] "+r" (x1) \
@@ -76,6 +79,7 @@ __ATOMIC128_CAS_OP(__cas_128_acquire, "caspa") __ATOMIC128_CAS_OP(__cas_128_release, "caspl") __ATOMIC128_CAS_OP(__cas_128_acq_rel, "caspal") +#undef __LSE_PREAMBLE#undef __ATOMIC128_CAS_OP#endif
Signature · 1 line
2.20.1
Quoted 13 lines · Ruifeng Wang
When doing Clang build with '-mcpu=native' on N1 platform, build failed with:
../lib/librte_eal/arm/include/rte_atomic_64.h:76:39:
error: instruction requires: lse__ATOMIC128_CAS_OP(__cas_128_release, "caspl")This is because native detection for Neoverse N1 was added in Clang-11. Prior version of Clang's assembler doesn't know LSE support on hardware. Fixed this for Clang earlier than version 11 by specifying architecture for assembler.
Referred to [1] for this fix.
Quoted 6 lines
Fixes 7e2c3e17fe2c ("eal/arm64: add 128-bit atomic compare exchange")Signed-off-by Ruifeng Wang <[email protected]>
Quoted 36 lines
--- lib/librte_eal/arm/include/rte_atomic_64.h | 4 ++++ 1 file changed, 4 insertions(+)lib/librte_eal/arm/include/rte_atomic_64.h +4
-1@@ -46,6 +46,8 @@ rte_atomic_thread_fence(int memorder)/*------------------------ 128 bit atomic operations -------------------------*/ #if defined(__ARM_FEATURE_ATOMICS) || defined(RTE_ARM_FEATURE_ATOMICS ) +#define __LSE_PREAMBLE ".arch armv8-a+lse\n" +#define __ATOMIC128_CAS_OP (cas_op_name, op_string) \ static __rte_noinline rte_int128_t \ cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated) \@@ -59,6 +61,7 @@ cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated) \ register uint64_t x2 __asm("x2") = (uint64_t)updated.val[0]; \ register uint64_t x3 __asm("x3") = (uint64_t)updated.val[1]; \ asmvolatile ( \ + __LSE_PREAMBLE \ op_string " %[old0], %[old1], %[upd0], %[upd1], [%[dst]]" \ : [old0]"+r" (x0), \ [old1] "+r" (x1) \@@ -76,6 +79,7 @@ __ATOMIC128_CAS_OP(__cas_128_acquire, "caspa") __ATOMIC128_CAS_OP(__cas_128_release, "caspl") __ATOMIC128_CAS_OP(__cas_128_acq_rel, "caspal") +#undef __LSE_PREAMBLE#undef __ATOMIC128_CAS_OP#endif --2.20.1
<snip>
Quoted 13 lines
When doing Clang build with '-mcpu=native' on N1 platform, build failed with:
../lib/librte_eal/arm/include/rte_atomic_64.h:76:39:
error: instruction requires: lse__ATOMIC128_CAS_OP(__cas_128_release, "caspl")This is because native detection for Neoverse N1 was added in Clang-11. Prior version of Clang's assembler doesn't know LSE support on hardware. Fixed this for Clang earlier than version 11 by specifying architecture for assembler.
Referred to [1] for this fix.
Quoted 8 lines
Fixes 7e2c3e17fe2c ("eal/arm64: add 128-bit atomic compare exchange")[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i
d=e0d5896bd356cd577f9710a02d7a474cdf58426bSigned-off-by Ruifeng Wang <[email protected]>
Quoted 40 lines
--- lib/librte_eal/arm/include/rte_atomic_64.h | 4 ++++ 1 file changed, 4 insertions(+)lib/librte_eal/arm/include/rte_atomic_64.h +2
-0@@ -46,6 +46,8 @@ rte_atomic_thread_fence(int memorder)/*------------------------ 128 bit atomic operations -------------------------*/ #if defined(__ARM_FEATURE_ATOMICS) || defined(RTE_ARM_FEATURE_ATOMICS ) +#define __LSE_PREAMBLE ".arch armv8-a+lse\n" +#define __ATOMIC128_CAS_OP (cas_op_name, op_string) \ static __rte_noinline rte_int128_t \
cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated)
\lib/librte_eal/arm/include/rte_atomic_64.h +1
-0@@ -59,6 +61,7 @@ cas_op_name(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated) \ register uint64_t x2 __asm("x2") = (uint64_t)updated.val[0]; \ register uint64_t x3 __asm("x3") = (uint64_t)updated.val[1]; \ asmvolatile ( \ + __LSE_PREAMBLE \ op_string " %[old0], %[old1], %[upd0], %[upd1], [%[dst]]" \lib/librte_eal/arm/include/rte_atomic_64.h +1
-1: [old0] "+r" (x0), \ [old1] "+r" (x1) \@@ -76,6 +79,7 @@ __ATOMIC128_CAS_OP(__cas_128_acquire, "caspa") __ATOMIC128_CAS_OP(__cas_128_release, "caspl") __ATOMIC128_CAS_OP(__cas_128_acq_rel, "caspal") +#undef __LSE_PREAMBLE#undef __ATOMIC128_CAS_OP#endif --2.20.1
Thomas Monjalon
AppliedQuoted 15 lines
Quoted 15 lines
When doing Clang build with '-mcpu=native' on N1 platform, build failed with:
../lib/librte_eal/arm/include/rte_atomic_64.h:76:39:
error: instruction requires: lse__ATOMIC128_CAS_OP(__cas_128_release, "caspl")This is because native detection for Neoverse N1 was added in Clang-11. Prior version of Clang's assembler doesn't know LSE support on hardware. Fixed this for Clang earlier than version 11 by specifying architecture for assembler.
Referred to [1] for this fix.Fixes 7e2c3e17fe2c ("eal/arm64: add 128-bit atomic compare exchange")
Quoted 6 lines
Quoted 5 lines
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i
d=e0d5896bd356cd577f9710a02d7a474cdf58426bSigned-off-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>
Applied, thanks