Compile bug: Fails on GNU/Hurd due to unconditional `PATH_MAX` usage

Open Beginner friendly
#32,289 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp
Domain
build-system

Research direction

The failing PATH_MAX uses are at src/llama-mmap.cpp line 1145 and tools/gguf-split/gguf-split.cpp lines 320, 431 and 433. Start by reading how llama_path_max() is defined and why the file does not include a header that provides PATH_MAX on Hurd. Done means the project builds on GNU/Hurd without changing behaviour on Linux, which you can check by building with the compile command in the issue.

Written by the indexing model from the issue text.

Description

bug-unconfirmed
Git commit

b1b770d90d94cad9e9ea5b993bdbc383a522fb28

Operating systems

Other? (Please let us know in description)

GGML backends

CPU

Problem description & steps to reproduce

When compiling llama.cpp on GNU/Hurd, several compile errors happen due to PATH_MAX not being defined on Hurd (it is not required according to POSIX). Read https://hurd.ion.nu/faq/foo_max for info about why PATH_MAX is dangerous and why it shouldn't be used often.

Uses of PATH_MAX that lead to compile errors:
https://github.com/ggml-org/llama.cpp/blob/b1b770d90d94cad9e9ea5b993bdbc383a522fb28/src/llama-mmap.cpp#L1145
https://github.com/ggml-org/llama.cpp/blob/b1b770d90d94cad9e9ea5b993bdbc383a522fb28/tools/gguf-split/gguf-split.cpp#L320
https://github.com/ggml-org/llama.cpp/blob/b1b770d90d94cad9e9ea5b993bdbc383a522fb28/tools/gguf-split/gguf-split.cpp#L431
https://github.com/ggml-org/llama.cpp/blob/b1b770d90d94cad9e9ea5b993bdbc383a522fb28/tools/gguf-split/gguf-split.cpp#L433

First Bad Commit

No response

Compile command
cmake -B build -DGGML_CCACHE=OFF -DGGML_CPU=ON -DGGML_OPENMP=ON
cmake --build build --config Release
Relevant log output
/home/nexussfan/Source_Code/llama.cpp-1.0.0/src/llama-mmap.cpp: In function 'size_t llama_path_max()':
/home/nexussfan/Source_Code/llama.cpp-1.0.0/src/llama-mmap.cpp:1145:12: error: 'PATH_MAX' was not declared in this scope
 1145 |     return PATH_MAX;
      |            ^~~~~~~~
gmake[2]: *** [src/CMakeFiles/llama.dir/build.make:569: src/CMakeFiles/llama.dir/llama-mmap.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:2587: src/CMakeFiles/llama.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
Dominant language
C++
Stars
134k
Forks
25.4k
Avg merge
2d 5h
Merged PRs (30d)
509

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ggml-org/llama.cpp

All issues in ggml-org/llama.cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.