llvmlite icon indicating copy to clipboard operation
llvmlite copied to clipboard

Missing LLVM assertions in Linux build breaks debug output

Open Olobir opened this issue 9 months ago • 2 comments

Reporting a bug

  • [x ] I have tried using the latest released version of llvmlite (most recent is visible in the change log (https://github.com/numba/llvmlite/blob/main/CHANGE_LOG).
  • [x ] I have included a self contained code sample to reproduce the problem. i.e. it's possible to run as 'python bug.py'.

According to the Numba documentation, observing LLVM diagnostics requires LLVM to be built with assertions enabled. The docs also mention that the build of llvmlite in the Numba channel should support this. It seems that support for LLVM assertions was removed from the Linux build script: In commit 98452e2, the line _cmake_config+=(-DLLVM_ENABLE_ASSERTIONS:BOOL=ON) was removed from conda-recipes/llvmdev/build.sh Meanwhile, -DLLVM_ENABLE_ASSERTIONS=ON ^ remains in conda-recipes/llvmdev/bld.bat, meaning Windows builds still have assertions enabled. This leads to a difference in behavior between Windows and Linux.

Here is the environment yaml-file

name: numbadev

channels:
  - defaults
  - numba

dependencies:
  - python>=3.12
  - numba::numba=0.61.2  # => llvmlite built against LLVM 15 disables debug info
  # - numba::numba=0.60  # => llvmlite built against LLVM 14 enables debug info
  - numba::llvmlite
  - intel-cmplr-lib-rt

Here is a script that demonstrates the issue:

import llvmlite.binding as llvm
llvm.set_option('', '--debug-only=loop-vectorize')

import numpy as np
from numba import jit

@jit(nopython=True, fastmath=True)
def test_func(a):
    result = 0.0
    for i in range(a.shape[0]):
        result += a[i] * 2.0
    return result

# Trigger compilation.
a = np.arange(1000, dtype=np.float64)
test_func(a)

When this script is run on Windows with llvmlite built against LLVM 15, output like LV:... is printed as expected. On Linux no debug output is shown, probably because LLVM was not built with assertions. Older versions built against LLVM 14 show debug outputs on Linux, too.

Was the removal of -DLLVM_ENABLE_ASSERTIONS:BOOL=ON from the Linux build intentional?

Thanks!

Olobir avatar Apr 14 '25 20:04 Olobir

Thank you for reporting and investigating into the problems. We were wondering why the debug-only stopped working. Since we will be bumping to a newer LLVM, we should make sure it is fixed there.

sklam avatar Apr 15 '25 15:04 sklam

@sklam thank you for taking the time to investigate that issue.

Olobir avatar Apr 15 '25 20:04 Olobir

This was fixed as part of https://github.com/numba/llvmlite/pull/1226/files

esc avatar Aug 26 '25 09:08 esc