NAME

Alien::ggml - Find or build the ggml tensor library

VERSION

Version 0.06

SYNOPSIS

use Alien::ggml;
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => 'MyXSModule',
    VERSION_FROM => 'lib/MyXSModule.pm',
    CONFIGURE_REQUIRES => {
        'Alien::ggml' => 0,
    },
    LIBS => [ Alien::ggml->libs ],
    INC  => Alien::ggml->cflags,
);

Or with Alien::Base::Wrapper:

use Alien::Base::Wrapper qw( Alien::ggml !export );
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => 'MyXSModule',
    Alien::Base::Wrapper->mm_args,
);

DESCRIPTION

Alien::ggml finds or builds the ggml tensor library, which is the foundation of llama.cpp and other LLM inference engines. ggml provides efficient tensor operations with support for various backends:

  • CPU with SIMD optimizations (SSE, AVX, NEON)

  • Apple Metal (macOS/iOS GPU)

  • NVIDIA CUDA

  • Vulkan

  • OpenCL

This Alien module will first check if ggml is installed on your system. If not found, it will download and build ggml from source.

METHODS

All methods are inherited from Alien::Base.

cflags

my $cflags = Alien::ggml->cflags;

Returns the compiler flags needed to compile against ggml. Typically includes -I/path/to/ggml/include.

libs

my $libs = Alien::ggml->libs;

Returns the linker flags needed to link against ggml. Typically includes -L/path/to/lib -lggml -lggml-base -lggml-cpu.

dynamic_libs

my @libs = Alien::ggml->dynamic_libs;

Returns a list of dynamic library paths for ggml.

install_type

my $type = Alien::ggml->install_type;

Returns either system if using a system-installed ggml, or share if ggml was built from source.

BUILDING FROM SOURCE

When no system ggml is found, Alien::ggml will download and build ggml from source. This requires:

  • C compiler (gcc, clang)

  • CMake 3.14+

  • Make or Ninja

Platform-specific optimizations are enabled automatically:

  • macOS: Metal GPU support, Accelerate BLAS

  • Linux: OpenBLAS (if available)

ENVIRONMENT VARIABLES

ALIEN_GGML_SHARE

Force building from source even if system ggml is found:

ALIEN_GGML_SHARE=1 cpanm Alien::ggml

SEE ALSO

Alien::Base - Base class for Alien modules

Lugh - LLM inference engine using ggml

https://github.com/ggerganov/ggml - ggml source code

https://github.com/ggerganov/llama.cpp - llama.cpp (uses ggml)

AUTHOR

LNATION <email@lnation.org>

BUGS

Please report any bugs or feature requests to bug-alien-ggml at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Alien-ggml.

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)