Skip to content

ld.lld: error: undefined symbol: fts_open/fts_read/fts_close #514

@peppergrayxyz

Description

@peppergrayxyz

build on musl/llvm failes due to missing lib:

cc  -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -DHAVE_STRLCPY -DHAVE_REALLOCARRAY  -shared -o libselinux.so.1 avc.lo avc_internal.lo avc_sidtab.lo booleans.lo callbacks.lo canonicalize_context.lo checkAccess.lo check_context.lo checkreqprot.lo compute_av.lo compute_create.lo compute_member.lo compute_relabel.lo compute_user.lo context.lo deny_unknown.lo disable.lo enabled.lo fgetfilecon.lo freecon.lo freeconary.lo fsetfilecon.lo get_context_list.lo get_default_type.lo get_initial_context.lo getenforce.lo getfilecon.lo getpeercon.lo init.lo is_customizable_type.lo label.lo label_db.lo label_file.lo label_media.lo label_support.lo label_x.lo lgetfilecon.lo load_policy.lo lsetfilecon.lo mapping.lo matchmediacon.lo matchpathcon.lo policyvers.lo procattr.lo query_user_context.lo regex.lo reject_unknown.lo selinux_check_securetty_context.lo selinux_config.lo selinux_internal.lo selinux_restorecon.lo sestatus.lo setenforce.lo setexecfilecon.lo setfilecon.lo setrans_client.lo seusers.lo sha1.lo stringrep.lo validatetrans.lo -lpcre2-8  -ldl -Wl,-soname,libselinux.so.1,--version-script=libselinux.map,-z,defs,-z,relro
ld.lld: error: undefined symbol: fts_open
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_common)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)

ld.lld: error: undefined symbol: fts_read
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_common)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)
>>> referenced 1 more times

ld.lld: error: undefined symbol: fts_close
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_common)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)

ld.lld: error: undefined symbol: fts_set
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_xattr)
>>> referenced by selinux_restorecon.c
>>>               selinux_restorecon.lo:(selinux_restorecon_thread)
cc: error: linker command failed with exit code 1 (use -v to see invocation)

The idea is that the flag is passed manuall:

# override with -lfts when building on Musl libc to use fts-standalone
FTS_LDLIBS ?=

but it is poorly documented.

downstream bug: https://bugs.gentoo.org/972540

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions