Great! Glad I could be of help!
It just so happens that I also can chip in a little when it comes to the
"infinite compilation" issue. That is, I can confirm that I've also
encountered it around two years ago. Sadly, I've never found a simple
reproducer, so I never reported it, and looking at the issues now I'm
guessing no one else has found a sensible reproducer too - or maybe it's
a completely avoidable issue that I just didn't know how to solve :)
What I did find about it was the following (from memory and whatever
little chatlogs I have found atm):
1. This does not appear to be an infinite loop, because, when I added
debug output to it, it didn't look looped, but rather like just a
very complex algorithm that just grew inifnitely large on the input
code. Although it could be that the looping part itself was just so
large that I just couldn't possibly see the repeating structure
2. I tried profiling the compiler (I won't remember with what tools now)
to see where it was spending the most time in - it pointed me to the
function bool checkedOrIn(const TypeTree&, bool, bool) - apparently,
the compiler spent 67% (I'm not kidding, two years ago this meme
didn't even exist) of the long time I left it running for in it.
IIRC it also did some kind of recursive execution during the analysis
with either no caching or with the inputs juts different enough to not
allow caching - but at this point I already bit off more than I could
chew at the moment and I don't think I really returned to it
afterwards and focused on trying to gradually roll out my own code to
avoid falling in that pit like I did with an external library I was
using.
That's about all I can remember about this issuesoff the top of my head,
I maybe will look more in my private repos with Enzyme experiments or on
my PC with some projects I've never uploaded anywhere when I return to
it in a week or so.
On Fri Jul 17, 2026 at 2:05 AM MSK, Mark Abate wrote:
> Hi Greg,
>
> Thanks for the response! Adding the extern keyword fixed the build for that
> example. I guess without extern the variable name is not propagated
> correctly to LLDEnzyme. The linker flags we're using should agree with what
> Enzyme sets through cmake (link
> <
https://github.com/EnzymeAD/Enzyme/blob/3c65e661f643c1594e293e1e796e577beb18dd32/enzyme/Enzyme/CMakeLists.txt#L216-L220>),
> but we will try to hook into the cmake configuration in the future.
>
> We're running into another slightly different problem now, but I thought I
> would continue the conversation here to see if anyone had any ideas.
>
> We're ultimately trying to differentiate functions that use constructs from
> the AMReX <
https://github.com/AMReX-Codes/amrex> library for adaptive mesh
> refinement (many physical simulation codes at Berkeley Lab are built on top
> of this framework).
>
> I've been trying to build this
> <
https://github.com/BLAST-WarpX/gradient-harness/blob/97e1b8b9a499fe95450eb15d23f4e41826de53f1/src/amrex_heat_equation/main.cpp#L136>
> AMReX
> example with Enzyme. This is adapted from their heat equation example
> <
https://github.com/AMReX-Codes/amrex-tutorials/blob/main/ExampleCodes/Basic/HeatEquation_EX0_C/Source/main.cpp#L18>,
> but I've pared down the logic so the function run_simulation just creates
> an MFIter object and then returns. When we try to build this, Enzyme's type
> analysis seems to enter an infinite loop (runs for > 4 hours). Another
> thing we tried was adding __attribute__((enzyme_inactive)) in different
> locations (e.g. to the MFIter constructor/destructor), but that didn't seem
> to help.
>
> Here's our build flags and the output:
> LLVM_VERSION = 21
> ENZYME_CXXFLAGS = -flto
> -fplugin=/global/homes/m/mabate/src/Enzyme/build/Enzyme/ClangEnzyme-21.so
> -mllvm -enzyme-enable=0
> ENZYME_LDFLAGS = -fuse-ld=lld -flto
> -Wl,-mllvm,-load=/global/homes/m/mabate/src/Enzyme/build/Enzyme/LLDEnzyme-21.so
> -Wl,--load-pass-plugin=/global/homes/m/mabate/src/Enzyme/build/Enzyme/LLDEnzyme-21.so
> -Wl,--lto-O1 -Wl,-mllvm,-enzyme-print=1 -Wl,-mllvm,-enzyme-print-activity=1
> -Wl,-mllvm,-enzyme-print-type=1
> -Wl,-mllvm,-enzyme-globals-default-inactive=1
>
> Function we are differentiating
> <
https://github.com/BLAST-WarpX/gradient-harness/blob/97e1b8b9a499fe95450eb15d23f4e41826de53f1/src/amrex_heat_equation/main.cpp#L136>
>
> Build output (no enzyme_inactive attributes set)
> <
https://gitlab.com/-/snippets/6010801>
> Build output (enzyme_inactive set on m_TheTileArrayCache)
> <
https://gitlab.com/-/snippets/6010802>
> Build output (enzyme_inactive set on MFIter constructor/destructor)
> <
https://gitlab.com/-/snippets/6010803>