Skip to content

Meson build fixes for cross-platform conda-forge packaging #304

@HaoZeke

Description

@HaoZeke

Summary

While enabling Windows and cross-compiled ARM builds on conda-forge, several issues were found in the meson build system that required feedstock-level patches. These should be fixed upstream.

1. with_xtb unnecessarily requires Fortran compiler

File: client/meson.build (line 8)

if get_option('with_fortran') or get_option('with_xtb') or get_option(
    'with_cuh2',
)
    use_fortran = true
    add_languages('fortran', required: true)

with_xtb=True forces add_languages('fortran'), but xtb can be consumed as a pre-built C-API library (e.g. from conda-forge) without a Fortran compiler. Only with_fortran and with_cuh2 should gate Fortran. This blocks Windows MSVC builds where no Fortran compiler is available but xtb is provided as a package.

Fix: Remove get_option('with_xtb') from the Fortran condition.

2. xtb dependency fallback triggers unnecessary source builds

File: client/meson.build (line 329)

xtb_dep = dependency(
    'xtb',
    required: true,
    fallback: ['xtb', 'xtb_dep_static'],
)

When xtb is available as a system/conda package but pkg-config lookup fails (e.g. temporarily), meson falls back to cloning and building xtb from source via subprojects/xtb.wrap. This pulls in the full xtb build tree and requires a Fortran compiler, defeating the purpose of using a pre-built package.

Fix: Remove the fallback parameter, or gate it behind a build option. When xtb is a required system dependency, dependency('xtb', required: true) is sufficient.

3. VLA (variable-length array) in XTBPot.cpp incompatible with MSVC

File: client/potentials/XTBPot/XTBPot.cpp (line 35)

double R_bohr[3 * N];  // N is a runtime parameter

VLAs are a GCC/Clang extension (C99 feature, never standard C++). MSVC rejects this with error C2131: expression did not evaluate to a constant.

Fix: Use std::vector<double> R_bohr(3 * N); and pass R_bohr.data() to C API functions (xtb_newMolecule, xtb_updateMolecule) that expect const double*.

4. Torch library lookup unconditionally requires all libraries

File: client/meson.build (line 433-437)

lib_torch_list = ['c10', 'torch', 'torch_cpu', 'torch_global_deps']
tdeps = []
foreach lib_name : lib_torch_list
    tdeps += cppc.find_library(lib_name, dirs: [LIB_TORCH_LIB_PATH])
endforeach

On Windows, torch_global_deps has no .lib import library (only a .dll). The unconditional find_library fails. The CMake build handles this gracefully by making each lookup optional.

Fix: Use required: false and skip missing libraries:

foreach lib_name : lib_torch_list
    _lib = cppc.find_library(lib_name, dirs: [LIB_TORCH_LIB_PATH], required: false)
    if _lib.found()
        tdeps += _lib
    endif
endforeach

All four issues are currently worked around via patches in the conda-forge feedstock (PR #18). Fixing upstream would simplify packaging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions