diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e7f84077..3dedcad2ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Changes: Bugfixes: * Fixed libc version detection on FreeBSD without binutils installed, and on DragonFly BSD. (Libc, FreeBSD / DragonFly) +* 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 25f5cd6446..2f9adea622 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() @@ -1923,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) 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