|
1 | 1 | dnl #
|
2 |
| -dnl # If -latomic exists, it's needed for __atomic intrinsics. |
3 |
| -dnl # |
4 |
| -dnl # Some systems (like FreeBSD 13) don't have a libatomic at all because |
5 |
| -dnl # their toolchain doesn't ship it – they obviously don't need it. |
6 |
| -dnl # |
7 |
| -dnl # Others (like sufficiently ancient CentOS) have one, |
8 |
| -dnl # but terminally broken or unlinkable (e.g. it's a dangling symlink, |
9 |
| -dnl # or a linker script that points to a nonexistent file) – |
10 |
| -dnl # most arches affected by this don't actually need -latomic (and if they do, |
11 |
| -dnl # then they should have libatomic that actually exists and links, |
12 |
| -dnl # so don't fall into this category). |
13 |
| -dnl # |
14 |
| -dnl # Technically, we could check if the platform *actually* needs -latomic, |
15 |
| -dnl # or if it has native support for all the intrinsics we use, |
16 |
| -dnl # but it /really/ doesn't matter, and C11 recommends to always link it. |
| 2 | +dnl # If -latomic exists and atomic.c doesn't link without it, |
| 3 | +dnl # it's needed for __atomic intrinsics. |
17 | 4 | dnl #
|
18 | 5 | AC_DEFUN([ZFS_AC_CONFIG_USER_LIBATOMIC], [
|
19 |
| - AC_MSG_CHECKING([whether -latomic is present]) |
| 6 | + AC_MSG_CHECKING([whether -latomic is required]) |
20 | 7 |
|
21 | 8 | saved_libs="$LIBS"
|
22 | 9 | LIBS="$LIBS -latomic"
|
| 10 | + LIBATOMIC_LIBS="" |
23 | 11 |
|
24 | 12 | AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
|
25 |
| - LIBATOMIC_LIBS="-latomic" |
| 13 | + LIBS="$saved_libs" |
| 14 | + saved_cflags="$CFLAGS" |
| 15 | + CFLAGS="$CFLAGS -isystem lib/libspl/include" |
| 16 | + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "lib/libspl/atomic.c"], [])], [], [LIBATOMIC_LIBS="-latomic"]) |
| 17 | + CFLAGS="$saved_cflags" |
| 18 | + ]) |
| 19 | +
|
| 20 | + if test -n "$LIBATOMIC_LIBS"; then |
26 | 21 | AC_MSG_RESULT([yes])
|
27 |
| - ], [ |
28 |
| - LIBATOMIC_LIBS="" |
| 22 | + else |
29 | 23 | AC_MSG_RESULT([no])
|
30 |
| - ]) |
| 24 | + fi |
31 | 25 |
|
32 | 26 | LIBS="$saved_libs"
|
33 | 27 | AC_SUBST([LIBATOMIC_LIBS])
|
|
0 commit comments