Undefined reference to __atomic_store_8
Gleb Popov
arrowd at freebsd.org
Wed Aug 12 05:44:55 UTC 2020
On Wed, Aug 12, 2020 at 9:21 AM Gleb Popov <arrowd at freebsd.org> wrote:
> Indeed, this looks like a culprit! When compiling using first command line
> (the long one) I get following warnings:
>
> /wrkdirs/usr/ports/lang/ghc/work/ghc-8.10.1/libraries/ghc-prim/cbits/atomic.c:369:10:
> warning: misaligned atomic operation may incur significant performance
> penalty [-Watomic-alignment]
> return __atomic_load_n((StgWord64 *) x, __ATOMIC_SEQ_CST);
> ^
> /wrkdirs/usr/ports/lang/ghc/work/ghc-8.10.1/libraries/ghc-prim/cbits/atomic.c:417:3:
> warning: misaligned atomic operation may incur significant performance
> penalty [-Watomic-alignment]
> __atomic_store_n((StgWord64 *) x, (StgWord64) val, __ATOMIC_SEQ_CST);
> ^
> 2 warnings generated.
>
> I guess this basically means "I'm emitting a call there". So, what's the
> correct fix in this case?
>
I just noticed that Clang emits these warnings (and the call instruction)
only for functions handling StgWord64 type. For the same code with
StgWord32, like
StgWord
hs_atomicread32(StgWord x)
{
#if HAVE_C11_ATOMICS
return __atomic_load_n((StgWord32 *) x, __ATOMIC_SEQ_CST);
#else
return __sync_add_and_fetch((StgWord32 *) x, 0);
#endif
}
no warning is emitted as well as no call.
How does clang infer alignment in these cases? What's so special about
StgWord64?
More information about the freebsd-toolchain
mailing list