Skip to content

[Offload] Fix missing dependencies in Offload API generation #142776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

callumfare
Copy link
Contributor

Thanks to @RossBrunton for spotting this.

We attempt to clang-format the generated Offload header files, but if clang-format isn't available we just copy the generated files instead. That fallback path was missing the correct dependencies.

Fixes #142756

@llvmbot llvmbot added the offload label Jun 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

@llvm/pr-subscribers-offload

Author: Callum Fare (callumfare)

Changes

Thanks to @RossBrunton for spotting this.

We attempt to clang-format the generated Offload header files, but if clang-format isn't available we just copy the generated files instead. That fallback path was missing the correct dependencies.

Fixes #142756


Full diff: https://github.com/llvm/llvm-project/pull/142776.diff

1 Files Affected:

  • (modified) offload/liboffload/API/CMakeLists.txt (+2)
diff --git a/offload/liboffload/API/CMakeLists.txt b/offload/liboffload/API/CMakeLists.txt
index cf6e132aa57a9..216710faa84f6 100644
--- a/offload/liboffload/API/CMakeLists.txt
+++ b/offload/liboffload/API/CMakeLists.txt
@@ -42,5 +42,7 @@ else()
             COMMAND ${CMAKE_COMMAND} -E copy_if_different generated/${file}.gen ${CMAKE_CURRENT_BINARY_DIR}/${file}
             DEPENDS generated/${file}.gen
         )
+        add_custom_target(OffloadAPI.${file} DEPENDS ${file})
+        add_dependencies(OffloadAPI OffloadAPI.${file})
     endforeach()
 endif()

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't my original patch have that? Guess I didn't notice it missing.

@jhuber6 jhuber6 merged commit 817af2d into llvm:main Jun 4, 2025
8 of 11 checks passed
@kparzysz
Copy link
Contributor

kparzysz commented Jun 4, 2025

The generation fails if the "generated" and "include" subdirectories are missing.

runtimes/runtimes-bins/offload/plugins-nextgen/common/include
runtimes/runtimes-bins/offload/liboffload/API/generated

@callumfare
Copy link
Contributor Author

@kparzysz I don't see any failures when building with a completely clean build directory. Could you share the build log where you're getting those failures?

@kparzysz
Copy link
Contributor

kparzysz commented Jun 4, 2025

Here's the error

[ 62%] Building include/OffloadErrcodes.inc...
[ 62%] Linking CXX static library /work/kparzysz/git/llvm.org/b/x86/lib/amdgcn-amd-amdhsa/libompdevice.a
[ 62%] Built target RTScudoCUnitTest.x86_64
[ 62%] Building CXX object openmp/runtime/src/CMakeFiles/omp.dir/kmp_alloc.cpp.o/work/kparzysz/git/llvm.org/b/x86/bin/offload-tblgen: error opening /work/kparzysz/git/llvm.org/b/x86/runtimes/runtimes-bins/offload/plugins-nextgen/common/include/OffloadErrcodes.inc: No such file or directory
make[5]: *** [offload/plugins-nextgen/common/CMakeFiles/PluginErrcodes.dir/build.make:121: offload/plugins-nextgen/common/include/OffloadErrcodes.inc] Error 1
make[5]: Leaving directory '/work2/kparzysz/git/llvm.org/b/x86/runtimes/runtimes-bins'
make[4]: *** [CMakeFiles/Makefile2:26763: offload/plugins-nextgen/common/CMakeFiles/PluginErrcodes.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....

My cmake command was

cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_LIT_ARGS='-sv -j64' -DCMAKE_INSTALL_PREFIX=/work/kparzysz/c/org -DCMAKE_BUILD_TYPE=Release -DCLANG_DEFAULT_LINKER=lld -DLLVM_BUILD_TESTS=ON -DLLVM_INCLUDE_TESTS=ON -DCLANG_INCLUDE_TESTS=ON -DLLVM_TARGETS_TO_BUILD=all -DLLVM_ENABLE_RUNTIMES='openmp;offload;compiler-rt;libcxx;libcxxabi;libunwind' -DLLVM_ENABLE_PROJECTS='bolt;clang;clang-tools-extra;flang;lld;lldb;mlir;polly;pstl' -DBUILD_SHARED_LIBS=ON -DLIBOMPTARGET_PLUGINS_TO_BUILD='amdgpu;host' -DCLANG_DEFAULT_PIE_ON_LINUX=OFF -DLIBOMP_OMPT_SUPPORT=OFF -DLLVM_OMIT_DAGISEL_COMMENTS=OFF ../../llvm

@kparzysz
Copy link
Contributor

kparzysz commented Jun 4, 2025

Manually creating the two directories fixes the problem: make all install completes successfully.

@callumfare
Copy link
Contributor Author

Thanks, it could be a difference between Ninja and Makefile, I'll investigate

@kparzysz
Copy link
Contributor

kparzysz commented Jun 4, 2025

This happens when I start with an empty directory as the build tree. Once it's populated with make files and subdirectories (with these two created by hand), everything works in all subsequent builds.

@callumfare
Copy link
Contributor Author

@kparzysz I was able to reproduce this failure, it should be fixed by this PR #142817

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

offload fatal error: 'OffloadAPI.h' file not found - on linux
4 participants