8000 Added support for flang by aivazis · Pull Request #42 · aivazis/mm · GitHub
[go: up one dir, main page]

Skip to content

Added support for flang - #42

Merged
aivazis merged 8 commits into
mainfrom
flang
Jun 8, 2026
Merged

aivazis merged 8 commits into
mainfrom
flang

Conversation

@aivazis
@aivazis aivazis commented Jun 8, 2026 •
Copy link
Copy Markdown
Owner

Summary

Make the LLVM flang Fortran compiler usable under mm and prove it end-to-end by building
the hello example (mixed C/C++/Fortran) on a real linux64 box.

flang compiler support (make/compilers/clang/flang.mm)

  • Drop -pipe from flang.compile.base — flang does not accept it.
  • Point flang.mixed.libraries at flang_rt.runtime (libflang_rt.runtime.so), the
    LLVM Flang-RT runtime, replacing the stale FortranRuntime name. This is what supplies
    symbols like _FortranAAssign when a non-Fortran compiler drives the link of a target
    that contains Fortran objects.

Installing flang from conda-forge

To get a functioning flang toolchain, install:

  • flang — the compiler. Provides the plain flang driver on PATH (bin/flang),
    the compiler libraries, headers, and libFortranDecimal. This package is
    compiler-only — it does not include the runtime.
  • libflang-rt — the LLVM Flang-RT runtime (libflang_rt.runtime.so), which defines the
    _FortranA* symbol namespace (e.g. _FortranAAssign). Required to link any program with
    Fortran objects; without it the link fails with unresolved _FortranA* symbols.
dependencies:
  - clang
  - clangxx
  - flang
  - libflang-rt

Notes:

  • conda-forge ships flang for linux-64 and win-64 only — there is no osx/aarch64 build.
  • Do not rely on flang_linux-64 for mm. That is the autotools/cmake activation
    metapackage (gcc_linux-64 analogue): it sets FC/sysroot env, ships an empty bin/, and
    drags in clangdev + compiler-rt_linux-64. mm invokes the plain flang driver directly
    (flang.driver := flang) and ignores conda's activation, so flang + libflang-rt is the
    correct, minimal set.

linux64 test harness (examples/hello/etc/docker/questing-clang/)

A docker image, modeled on qef/etc/docker and trimmed to hello, for building and testing
the example on linux64 at will:

  • ubuntu:questing + micromamba env with the clang/flang toolchain (per above) and hello's deps.
  • mm.yaml leans on the new support: mode: conda (no prefix/bldroot/pycPrefix) and
    pkgdb: conda (no external package database); config.mm is therefore empty.
  • Wired into mm via hello.docker-images := hello.questing-clang + include in hello.mm.
    Because hello lives inside the mm repo, the image mounts the whole repo (build tool +
    example); mounts.source uses deferred (=) expansion so it survives -warn-undefined.

hello example wiring

  • hello.lib.extern := pyre fortran — the fortran extern is mm's mixed-language seam; it
    injects flang.mixed.libraries into the clang++-driven link of the library carrying
    mat.f03, resolving the Fortran runtime symbols.

Validation

Builds and tests clean on a real linux64 machine.

Note: this branch also carries a few unrelated examples/hello repairs (package meta, a
registration typo, the plexus banner, a cli/package-name collision) that are incidental to
flang support.

aivazis added 8 commits June 8, 2026 12:38
…he example on linux64 with flang

Mirrors the docker support in qef/etc/docker, trimmed to hello's needs: a conda-forge env
with the clang/flang toolchain plus pyre/python/pybind11, and an mm.yaml that leans on the
new support (mode: conda, pkgdb: conda) so it needs no prefix/bldroot/pycPrefix or external
package database. config.mm is empty since conda resolves every external dependency. The
image mounts the whole mm repo so both the build tool and this example come along; building
it exercises mat.f03 through flang to validate make/compilers/clang/flang.mm on linux64.
…rt.runtime for mixed builds

flang has no {-pipe} option, so clear {flang.compile.base}. The LLVM Flang-RT runtime
library was renamed from {FortranRuntime} to {flang_rt.runtime} (libflang_rt.runtime.so);
point {flang.mixed.libraries} at it so a c/c++-driven link of a target with Fortran objects
resolves symbols like {_FortranAAssign}.
The {flang} conda package is compiler-only; add {libflang-rt} so the runtime
({libflang_rt.runtime.so}) is present. Declare {fortran} on {hello.lib.extern} so mm injects
{flang.mixed.libraries} into the c++-driven link of the library that carries {mat.f03}.
The mount source referenced $(hello.home) with := , which expands while the config file is
included — before docker-images.init sets the project home, so -warn-undefined flagged it.
Use = so hello.home is read when the mount is assembled instead.
@aivazis aivazis changed the title flang: Fortran support via clang/flang, validated on linux64 Added support for flang Jun 8, 2026
@aivazis
aivazis merged commit 3f3a755 into main Jun 8, 2026
@aivazis
aivazis deleted the flang branch June 8, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0