Compile bug: FreeBSD ggml vulkan compilation issue

Open Beginner friendly
#31,541 2 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
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

The build fails at ggml/src/ggml-vulkan/ggml-vulkan-comm.cpp line 370, where fcntl(fd, F_DUPFD_CLOEXEC, 0) is called on FreeBSD and the constant is undeclared. Check which headers that file includes, and whether F_DUPFD_CLOEXEC is available under the platform guards used elsewhere in the file. Done when the file compiles on FreeBSD without changing behaviour on Linux or macOS. The issue names PR #25051 as the source of the change.

Written by the indexing model from the issue text.

Description

bug-unconfirmed
Git commit

cd8427d018c07eefab6c110f7f115c31ec4c6157

Operating systems

Other? (Please let us know in description)

GGML backends

Vulkan

Problem description & steps to reproduce

Can not compile
/zfast/github/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan-comm.cpp:370:69: error: use of undeclared identifier 'F_DUPFD_CLOEXEC' 370 | const int imp_fd = fd < 0 || i == last ? fd : fcntl(fd, F_DUPFD_CLOEXEC, 0); | ^~~~~~~~~~~~~~~ 1 error generated.

OS uname -a:
reeBSD devmach 16.0-CURRENT FreeBSD 16.0-CURRENT #0 main-n290301-c7523e8cfbd0: Thu Oct 22 17:23:36 CEST 2026 root@jrepo-cur-znver4:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64

PR #25051
@pwilkin could you take a look ?

First Bad Commit

dcbb0916772195bee457d23751edf8c1cbdc707e

Compile command
#!/bin/tcsh

setenv MY_BUILD_DIR "build-${1}"
echo "MY_BUILD_DIR: $MY_BUILD_DIR"

rm -rf $MY_BUILD_DIR

# -march=native -mtune=native -O3 -Ofast -ffast-math -funroll-loops -fno-math-errno -fno-trapping-math \
# -funsafe-math-optimizations -fassociative-math -fno-signed-zeros -fomit-frame-pointer -flto=auto -DNDEBUG

# broken:
# -ffast-math

# may broke code:
# -fno-semantic-interposition
# -funsafe-math-optimizations

setenv CFLAGS "-march=native -mtune=native -O3 -DNDEBUG -fno-strict-aliasing"

# -Ofast -fomit-frame-pointer -flto=auto -fno-signed-zeros \
# -funsafe-math-optimizations -fno-trapping-math -fno-math-errno \
# -fno-strict-aliasing

# cmake -B build \
#   -DCMAKE_C_COMPILER=clang18 \
#   -DCMAKE_CXX_COMPILER=clang++18 \
#   -DCMAKE_C_COMPILER_LAUNCHER=ccache \
#   -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
#   -DCMAKE_LINKER=ld.lld

setenv CC clang23
setenv CXX clang++23

cmake -B ${MY_BUILD_DIR} \
  -DCMAKE_C_FLAGS="${CFLAGS}" \
  -DCMAKE_CXX_FLAGS="${CFLAGS}" \
  -DCMAKE_C_COMPILER=${CC} \
  -DCMAKE_CXX_COMPILER=${CXX} \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_SHARED_LIBS=ON \
  -DGGML_LTO=ON \
  -DGGML_NATIVE=ON \
  -DGGML_AVX2=ON \
  -DGGML_AVX512=ON \
  -DGGML_AVX512_BF16=ON \
  -DGGML_AVX512_VBMI2=ON \
  -DGGML_AVX512_VBMI=ON \
  -DGGML_AVX512_VNNI=ON \
  -DGGML_SSE42=ON \
  -DGGML_FMA=ON \
  -DGGML_F16C=ON \
  -DGGML_BMI2=ON \
  -DGGML_OPENMP=ON \
  -DGGML_ACCELERATE=ON \
  -DGGML_CPU_ACCELERATE=ON \
  -DGGML_CPU=ON \
  -DGGML_CPU_REPACK=ON \
  -DGGML_VULKAN=ON \
  -DGGML_BUILD_TESTS=OFF \
  -DLLAMA_BUILD_TESTS=OFF

# -DGGML_CUDA_FA_ALL_QUANTS=ON

# -DLLAMA_BUILD_EXAMPLES=OFF

# -DGGML_BLAS=ON
# -DGGML_BLAS_VENDOR=OpenBLAS
# -DGGML_CPU_REPACK=ON
# -DGGML_AVX=OFF
# -DGGML_BLAS_VENDOR=Blis

cmake --build ${MY_BUILD_DIR} --config Release -j 32
Relevant log output
zfast/github/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan-comm.cpp:370:69: error: use of undeclared identifier 'F_DUPFD_CLOEXEC'
  370 |             const int imp_fd = fd < 0 || i == last ? fd : fcntl(fd, F_DUPFD_CLOEXEC, 0);
      |                                                                     ^~~~~~~~~~~~~~~
1 error generated.
Dominant language
C++
Stars
133k
Forks
25.1k
Avg merge
2d 8h
Merged PRs (30d)
495

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.