Skip to content

[BUG] Build failed on musl #279

Backlog
Backlog

Description

@Coolllyn

What happened?

Build failed on musl libc

How can we reproduce it?

  1. Build luciole on musl libc

Luciole version

0.1.0 (27412b3)

Last working version

No response

System details

Distribution: Void Linux
Compiler: GCC 14

Logs or screenshots

[157/376] Compiling C++ object libluciole-fs.a.p/src_fs_folder_totals_walk.cpp.o
FAILED: [code=1] libluciole-fs.a.p/src_fs_folder_totals_walk.cpp.o 
aarch64-linux-musl-c++ -Ilibluciole-fs.a.p -I. -I.. -I../src -Ilib -I../lib -I/usr/aarch64-linux-musl/usr/include -I/usr/aarch64-linux-musl/usr/include/glib-2.0 -I/usr/aarch64-linux-musl/usr/lib64/glib-2.0/include -I/usr/aarch64-linux-musl/usr/include/libmount -I/usr/aarch64-linux-musl/usr/include/blkid -I/usr/aarch64-linux-musl/usr/include/gio-unix-2.0 -I/usr/aarch64-linux-musl/usr/include/libxml2 -I/usr/aarch64-linux-musl/usr/include/freetype2 -I/usr/aarch64-linux-musl/usr/include/libpng16 -I/usr/aarch64-linux-musl/usr/include/cairo -I/usr/aarch64-linux-musl/usr/include/pixman-1 -I/usr/aarch64-linux-musl/usr/include/pango-1.0 -I/usr/aarch64-linux-musl/usr/include/harfbuzz -I/usr/aarch64-linux-musl/usr/include/fribidi -flto=auto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=c++23 -isystem /usr/aarch64-linux-musl/usr/include/glib-2.0 -D_GLIBCXX_ASSERTIONS -fstack-clash-protection -D_FORTIFY_SOURCE=2 -O2 -pipe -march=armv8-a -Wno-error=expansion-to-defined -ffile-prefix-map=/builddir/luciole-git-0.1.0.2026121/build=. -fPIC -pthread -MD -MQ libluciole-fs.a.p/src_fs_folder_totals_walk.cpp.o -MF libluciole-fs.a.p/src_fs_folder_totals_walk.cpp.o.d -o libluciole-fs.a.p/src_fs_folder_totals_walk.cpp.o -c ../src/fs/folder_totals_walk.cpp
../src/fs/folder_totals_walk.cpp: In member function 'void {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)':
../src/fs/folder_totals_walk.cpp:424:31: error: '::getdents64' has not been declared; did you mean 'getdents'?
  424 |         const auto filled = ::getdents64(folder->get(), buffer, kListingBufferBytes);
      |                               ^~~~~~~~~~
      |                               getdents
../src/fs/folder_totals_walk.cpp:433:25: error: invalid use of incomplete type 'const struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  433 |           offset += item->d_reclen;
      |                         ^~
../src/fs/folder_totals_walk.cpp:432:60: note: forward declaration of 'struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  432 |           const auto* item = reinterpret_cast<const struct dirent64*>(buffer + offset);
      |                                                            ^~~~~~~~
../src/fs/folder_totals_walk.cpp:434:48: error: invalid use of incomplete type 'const struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  434 |           const std::string_view childName(item->d_name);
      |                                                ^~
../src/fs/folder_totals_walk.cpp:432:60: note: forward declaration of 'struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  432 |           const auto* item = reinterpret_cast<const struct dirent64*>(buffer + offset);
      |                                                            ^~~~~~~~
../src/fs/folder_totals_walk.cpp:439:44: error: invalid use of incomplete type 'const struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  439 |           if (::fstatat(folder->get(), item->d_name, &value, AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT) != 0) {
      |                                            ^~
../src/fs/folder_totals_walk.cpp:432:60: note: forward declaration of 'struct {anonymous}::Walker::listChildren({anonymous}::Worker&, const {anonymous}::FolderTask&)::dirent64'
  432 |           const auto* item = reinterpret_cast<const struct dirent64*>(buffer + offset);
      |                                                            ^~~~~~~~

Activity

  1. added
    bug
    on Dec 1, 2026
  2. alexaandru commented on Dec 1, 2026

    @alexaandru

    FWIW, this patch works on my end:

    --- a/src/fs/parallel_tree_walk.cpp
    +++ b/src/fs/parallel_tree_walk.cpp
    @@ -1,3 +1,11 @@
    +// musl exposes getdents64/dirent64 only as LFS64 aliases under _LARGEFILE64_SOURCE
    +// (glibc enables that automatically with _GNU_SOURCE). Define it before any
    +// system headers so the aliases exist, then pass a typed buffer because musl's
    +// getdents() takes struct dirent* rather than void*.
    +#ifndef _LARGEFILE64_SOURCE
    +#define _LARGEFILE64_SOURCE
    +#endif
    +
     #include "fs/parallel_tree_walk.h"
    
     #include <algorithm>
    @@ -176,7 +184,7 @@
         ~LevelGuard() { --level; }
       } guard{thread.m_level};
       while (!interrupted()) {
    -    const auto filled = ::getdents64(folder->get(), buffer, kListingBufferBytes);
    +    const auto filled = getdents64(folder->get(), reinterpret_cast<struct dirent64*>(buffer), kListingBufferBytes);
         if (filled <= 0) {
           if (filled < 0) {
             m_visitor.failed(thread, &task, errnoError(errno));
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions