Work around clang hang compiling interp.c with -O1 and higher#5
Merged
guillerodriguez merged 1 commit intomasterfrom Feb 5, 2026
Merged
Work around clang hang compiling interp.c with -O1 and higher#5guillerodriguez merged 1 commit intomasterfrom
guillerodriguez merged 1 commit intomasterfrom
Conversation
Clang's LLVM backend hangs indefinitely when compiling src/interp/engine/interp.c with optimization level -O1 or higher. The hang is caused by LLVM's TailDuplication pass encountering exponential time complexity with the computed goto dispatch pattern used in the interpreter. The problem can be reproduced on Linux and macOS, and the actual cause was confirmed via profiling. Work around by adding -mllvm -tail-dup-limit=0 to the interp CFLAGS when compiling with clang. This disables the problematic pass (for interp.c only) while keeping all other LLVM optimizations intact. Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>
Contributor
Author
|
Quick instructions to reproduce the problem using Docker: docker run --rm -it -e DEBIAN_FRONTEND=noninteractive ubuntu:24.04 bash Inside container: apt-get update
apt-get install -y clang-14 make automake autoconf libtool zlib1g-dev zip \
gettext texinfo openjdk-8-jdk-headless git
cd /tmp
git clone --depth 1 -q https://github.com/ingelabs/classpath.git
cd classpath && ./autogen.sh
./configure JAVAC=javac --disable-gconf-peer \
--enable-default-preferences-peer=file --disable-gtk-peer \
--disable-qt-peer --disable-alsa --disable-dssi --disable-plugin \
--disable-examples --disable-tools --disable-gjdoc
make -j4 && make install
cd /tmp && git clone -q https://github.com/ingelabs/jamvm.git
cd jamvm
NOCONFIGURE=1 ./autogen.sh
./configure CC=clang JAVAC=javac
make # Hangs without the fix |
Contributor
Author
|
Profiling results, using macOS
|
avazquezdev
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clang's LLVM backend hangs indefinitely when compiling src/interp/engine/interp.c with optimization level -O1 or higher. The hang is caused by LLVM's TailDuplication pass encountering exponential time complexity with the computed goto dispatch pattern used in the interpreter. The problem can be reproduced on Linux and macOS, and the actual cause was confirmed via profiling.
Work around by adding -mllvm -tail-dup-limit=0 to the interp CFLAGS when compiling with clang. This disables the problematic pass (for interp.c only) while keeping all other LLVM optimizations intact.