Skip to content

Build fails when targeting arch without native support for 64-bit atomics #2110

Description

@jpalus

nnn 5.2 started to use optimized lockless implementation using atomic operations on 64-bit unsigned long long int (introduced in 7ce4913). This however causes build failure on architectures without such support (ie ARMv6 or lower):

/usr/bin/ld: /home/users/builder/tmp/cck52Np2.o: in function `du_walk_dir.constprop.0':
nnn.c:(.text+0x2148): undefined reference to `__atomic_fetch_or_8'
/usr/bin/ld: /home/users/builder/tmp/cck52Np2.o: in function `dentfill.constprop.0':
nnn.c:(.text+0xb1ac): undefined reference to `__atomic_fetch_or_8'
/usr/bin/ld: nnn.c:(.text+0xb414): undefined reference to `__atomic_fetch_or_8'

Linking libatomic fixes the issue. Some possibilities to fix it:

  1. User sets LDLIBS=-latomic env var before running make
  2. New option O_LIBATOMIC? for adding -latomic which user would have to set
  3. Trying to detect automatically if atomics work:
ifneq ($(shell echo "int main(){unsigned long long t;__atomic_fetch_or(&t, 0, __ATOMIC_RELAXED);}"|$(CC) -x c - -o /dev/null 2> /dev/null && echo 1),1)
        LDLIBS += -latomic
endif

I'm fine with either solution including first one, which does not require any action from nnn and in such case feel free to close the ticket.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions