From 994ca010e7392b358eced295c146b794d36daf60 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 11 Nov 2026 17:53:41 -0800 Subject: [PATCH 1/3] CMake: adds `--copy-dt-needed-entries` only if the linker supports it LLD does not implement --copy-dt-needed-entries. With BINARY_LINK_TYPE=dynamic the flag is added to CMAKE_EXE_LINKER_FLAGS before the configure checks run, so with LLD every check that links (utmpx.h, glob, wordexp, pthread_timedjoin_np, ...) fails and fastfetch is built with those features silently disabled. Check that the linker accepts the flag before adding it. Signed-off-by: Khem Raj --- CHANGELOG.md | 1 + CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e7f84077..483b28d42b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes: Bugfixes: * Fixed libc version detection on FreeBSD without binutils installed, and on DragonFly BSD. (Libc, FreeBSD / DragonFly) +* Fixed feature detection failing with `BINARY_LINK_TYPE=dynamic` when linking with LLD, which does not support `--copy-dt-needed-entries`. (CMake) # 2.71.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 25f5cd6446..ab0691773b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1733,7 +1733,11 @@ if(NOT BINARY_LINK_TYPE STREQUAL "dlopen") message(STATUS "Enabling custom link type: ${BINARY_LINK_TYPE}") target_compile_definitions(libfastfetch PUBLIC FF_DISABLE_DLOPEN=1) if(NOT WIN32) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--copy-dt-needed-entries") + include(CheckLinkerFlag) + check_linker_flag(C "-Wl,--copy-dt-needed-entries" HAVE_LINKER_COPY_DT_NEEDED_ENTRIES) + if(HAVE_LINKER_COPY_DT_NEEDED_ENTRIES) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--copy-dt-needed-entries") + endif() endif() endif() From 04eb2248d0f111f9be875dd48c5ce532c4355759 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 11 Nov 2026 17:53:41 -0800 Subject: [PATCH 2/3] Users (Linux): fixes build when utmpx.h is unavailable The utmp.h fallback maps setutxent and getutxent but not endutxent, which is called unconditionally, so the build fails with: error: use of undeclared identifier 'endutxent'; did you mean 'endutent'? Signed-off-by: Khem Raj --- CHANGELOG.md | 1 + src/detection/users/users_linux.c | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 483b28d42b..3042f09e2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes: Bugfixes: * Fixed libc version detection on FreeBSD without binutils installed, and on DragonFly BSD. (Libc, FreeBSD / DragonFly) * Fixed feature detection failing with `BINARY_LINK_TYPE=dynamic` when linking with LLD, which does not support `--copy-dt-needed-entries`. (CMake) +* Fixed building when `utmpx.h` is unavailable. (Users, Linux) # 2.71.0 diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index e304b29cb0..d39fb765fa 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -15,6 +15,7 @@ #define utmpx utmp #define setutxent setutent #define getutxent getutent + #define endutxent endutent #endif #if __linux__ || __GNU__ #include From d14639613e9bef8ce2f67462a17b3df6209bb169 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 11 Nov 2026 17:55:49 -0800 Subject: [PATCH 3/3] CMake: links libxcb and libX11 explicitly when not using dlopen fastfetch calls libxcb and libX11 functions directly, but only links xcb-randr and xrandr, whose pkg-config files list the core libraries in Requires.private. GNU ld resolves them through --copy-dt-needed-entries; LLD has no such option and fails with undefined symbols such as xcb_connect and XOpenDisplay. Link libxcb and libX11 explicitly in the dynamic and static link modes. Signed-off-by: Khem Raj --- CHANGELOG.md | 2 +- CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3042f09e2d..3dedcad2ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Changes: Bugfixes: * Fixed libc version detection on FreeBSD without binutils installed, and on DragonFly BSD. (Libc, FreeBSD / DragonFly) -* Fixed feature detection failing with `BINARY_LINK_TYPE=dynamic` when linking with LLD, which does not support `--copy-dt-needed-entries`. (CMake) +* Fixed feature detection and linking failing with `BINARY_LINK_TYPE=dynamic` when linking with LLD, which does not support `--copy-dt-needed-entries`. (CMake) * Fixed building when `utmpx.h` is unavailable. (Users, Linux) # 2.71.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index ab0691773b..2f9adea622 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1927,6 +1927,20 @@ ff_lib_enable(ELF "libelf" "libelf" ) +# xcb-randr and xrandr only list libxcb and libX11 in Requires.private, but +# fastfetch calls into them directly, so link them explicitly. +if(NOT BINARY_LINK_TYPE STREQUAL "dlopen" AND PKG_CONFIG_FOUND) + if(XCB_RANDR_FOUND) + pkg_check_modules(XCB QUIET xcb) + target_link_directories(libfastfetch PRIVATE ${XCB_LIBRARY_DIRS}) + target_link_libraries(libfastfetch PRIVATE ${XCB_LIBRARIES}) + endif() + if(XRANDR_FOUND OR GLX_FOUND OR VAX11_FOUND) + pkg_check_modules(X11 QUIET x11) + target_link_directories(libfastfetch PRIVATE ${X11_LIBRARY_DIRS}) + target_link_libraries(libfastfetch PRIVATE ${X11_LIBRARIES}) + endif() +endif() if(ENABLE_LUA) # Lua is a special case since its CMake config does not follow the usual pattern find_package(Lua QUIET)