Skip to content

[BUG] cuVS Java API may fail to build on some systems #2123

@imotov

Description

@imotov

Describe the bug
The build might fail on certain systems depending on the version of CUDA Toolkit, jextract, etc., with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (compile-java-22) on project cuvs-java: Compilation failure
[ERROR] /home/igor/Projects/rapidsai/cuvs/java/cuvs-java/src/main/java22/com/nvidia/cuvs/spi/JDKProvider.java:[10,1] cannot find symbol
[ERROR]   symbol:   static cudaStreamSynchronize
[ERROR]   location: class com.nvidia.cuvs.internal.panama.headers_h_1

Steps/Code to reproduce bug
The reproducibility of this issue depends on several factors, but after successful installation of prerequisites (CMake 3.26.4+, GCC 9.3+ (11.4+ recommended), CUDA Toolkit 12.2+, maven 3.9.6 or above Conda and JDK 22) it might be possible to reproduce the issue by executing the following steps:

git clone git@github.com:rapidsai/cuvs.git
cd cuvs
conda env create --name cuvs-env -f conda/environments/all_cuda-132_arch-$(uname -m).yaml
conda activate cuvs-env
./build.sh libcuvs java

Expected behavior
The build should succeed as long as minimal prerequisite requirements are satisfied.

Environment details (please complete the following information):

  • Environment location: Bare-metal
  • Method of cuVS install: from source
  • Versions of Java and NVIDIA CUDA Toolkit:
openjdk 22.0.2 2024-07-16
OpenJDK Runtime Environment (build 22.0.2+9-70)
OpenJDK 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Thu_Mar_19_11:12:51_PM_PDT_2026
Cuda compilation tools, release 13.2, V13.2.78
Build cuda_13.2.r13.2/compiler.37668154_0

Additional context

The issue is caused by the presence of the following line:

import static com.nvidia.cuvs.internal.panama.headers_h_1.cudaStreamSynchronize;

When jextract processes more than 1000 declarations, it splits the generated output across multiple classes (headers_h, headers_h_1, headers_h_2, etc.). Which class a given symbol ends up in depends on how many declarations precede it, so the placement of cudaStreamSynchronize is not stable, it can shift between headers_h and headers_h_1 across different jextract versions or as the set of processed headers changes, as it happened in my case.

The explicit import is also unnecessary: headers_h extends headers_h_1, so a wildcard static import of headers_h on the previous line already covers all static members of headers_h_1 through inheritance. Therefore, the line 10 can be simply removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions