llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.58k stars 11.81k forks source link

[OpenMP] openmp/plugins-nextgen fails to build with: `/build/source/llvm/include/llvm/IR/Attributes.h:89:14: fatal error: 'llvm/IR/Attributes.inc' file not found` #86446

Closed sylvestre closed 6 months ago

sylvestre commented 6 months ago

On Linux Debian/Ubuntu, started very recently:

FAILED: projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o 
/build/source/build-llvm/./bin/clang++ -DDEBUG_PREFIX=\"PluginInterface\" -DLIBOMPTARGET_JIT_AARCH64 -DLIBOMPTARGET_JIT_AMDGPU -DLIBOMPTARGET_JIT_ARM -DLIBOMPTARGET_JIT_AVR -DLIBOMPTARGET_JIT_BPF -DLIBOMPTARGET_JIT_HEXAGON -DLIBOMPTARGET_JIT_LANAI -DLIBOMPTARGET_JIT_LOONGARCH -DLIBOMPTARGET_JIT_M68K -DLIBOMPTARGET_JIT_MIPS -DLIBOMPTARGET_JIT_MSP430 -DLIBOMPTARGET_JIT_NVPTX -DLIBOMPTARGET_JIT_POWERPC -DLIBOMPTARGET_JIT_RISCV -DLIBOMPTARGET_JIT_SPARC -DLIBOMPTARGET_JIT_SYSTEMZ -DLIBOMPTARGET_JIT_VE -DLIBOMPTARGET_JIT_WEBASSEMBLY -DLIBOMPTARGET_JIT_X86 -DLIBOMPTARGET_JIT_XCORE -DLIBOMPTARGET_JIT_XTENSA -DOMPT_SUPPORT=1 -DTARGET_NAME=\"PluginInterface\" -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/openmp/libomptarget/plugins-nextgen/common -I/build/source/openmp/libomptarget/plugins-nextgen/common -Iinclude -I/build/source/llvm/include -Iprojects/openmp/runtime/src -I/build/source/openmp/libomptarget/plugins-nextgen/common/OMPT -I/build/source/openmp/libomptarget/plugins-nextgen/common/include -I/build/source/openmp/libomptarget/include -fstack-protector-strong -Wformat -Werror=format-security -Wno-unused-command-line-argument -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffile-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=../../../../ -ffile-prefix-map=/build/source/= -no-canonical-prefixes -Wall -fcolor-diagnostics -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -fno-semantic-interposition -fdata-sections -O2 -DNDEBUG -g1 -fPIC -fvisibility=protected -fno-exceptions -std=c++17 -MD -MT projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o -MF projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o.d -o projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o -c /build/source/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp:11:
In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h:29:
In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/include/JIT.h:19:
In file included from /build/source/llvm/include/llvm/Analysis/TargetLibraryInfo.h:14:
In file included from /build/source/llvm/include/llvm/IR/InstrTypes.h:24:
/build/source/llvm/include/llvm/IR/Attributes.h:89:14: fatal error: 'llvm/IR/Attributes.inc' file not found
   89 |     #include "llvm/IR/Attributes.inc"
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
llvmbot commented 6 months ago

@llvm/issue-subscribers-openmp

Author: Sylvestre Ledru (sylvestre)

On Linux Debian/Ubuntu, started very recently: ``` FAILED: projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o /build/source/build-llvm/./bin/clang++ -DDEBUG_PREFIX=\"PluginInterface\" -DLIBOMPTARGET_JIT_AARCH64 -DLIBOMPTARGET_JIT_AMDGPU -DLIBOMPTARGET_JIT_ARM -DLIBOMPTARGET_JIT_AVR -DLIBOMPTARGET_JIT_BPF -DLIBOMPTARGET_JIT_HEXAGON -DLIBOMPTARGET_JIT_LANAI -DLIBOMPTARGET_JIT_LOONGARCH -DLIBOMPTARGET_JIT_M68K -DLIBOMPTARGET_JIT_MIPS -DLIBOMPTARGET_JIT_MSP430 -DLIBOMPTARGET_JIT_NVPTX -DLIBOMPTARGET_JIT_POWERPC -DLIBOMPTARGET_JIT_RISCV -DLIBOMPTARGET_JIT_SPARC -DLIBOMPTARGET_JIT_SYSTEMZ -DLIBOMPTARGET_JIT_VE -DLIBOMPTARGET_JIT_WEBASSEMBLY -DLIBOMPTARGET_JIT_X86 -DLIBOMPTARGET_JIT_XCORE -DLIBOMPTARGET_JIT_XTENSA -DOMPT_SUPPORT=1 -DTARGET_NAME=\"PluginInterface\" -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/openmp/libomptarget/plugins-nextgen/common -I/build/source/openmp/libomptarget/plugins-nextgen/common -Iinclude -I/build/source/llvm/include -Iprojects/openmp/runtime/src -I/build/source/openmp/libomptarget/plugins-nextgen/common/OMPT -I/build/source/openmp/libomptarget/plugins-nextgen/common/include -I/build/source/openmp/libomptarget/include -fstack-protector-strong -Wformat -Werror=format-security -Wno-unused-command-line-argument -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffile-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=../../../../ -ffile-prefix-map=/build/source/= -no-canonical-prefixes -Wall -fcolor-diagnostics -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -fno-semantic-interposition -fdata-sections -O2 -DNDEBUG -g1 -fPIC -fvisibility=protected -fno-exceptions -std=c++17 -MD -MT projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o -MF projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o.d -o projects/openmp/libomptarget/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/PluginInterface.cpp.o -c /build/source/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp:11: In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h:29: In file included from /build/source/openmp/libomptarget/plugins-nextgen/common/include/JIT.h:19: In file included from /build/source/llvm/include/llvm/Analysis/TargetLibraryInfo.h:14: In file included from /build/source/llvm/include/llvm/IR/InstrTypes.h:24: /build/source/llvm/include/llvm/IR/Attributes.h:89:14: fatal error: 'llvm/IR/Attributes.inc' file not found 89 | #include "llvm/IR/Attributes.inc" | ^~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ```
sylvestre commented 6 months ago

Range: c3a41aac5f32..9632e1515c93

sylvestre commented 6 months ago

Log: https://llvm-jenkins.debian.net/job/llvm-toolchain-focal-binaries/architecture=amd64,distribution=focal,label=amd64/860/consoleFull

jhuber6 commented 6 months ago

We probably dropped LLVM_INCLUDE_DIR from somewhere when moving the headers around. it should likely be on the PUBLIC include directories interface.

jhuber6 commented 6 months ago

Hm, should be covered by the global include here https://github.com/llvm/llvm-project/blob/main/openmp/libomptarget/CMakeLists.txt#L44. Don't know why this would be different given the change.

jhuber6 commented 6 months ago

Tried to copy the builder and it didn't reproduce. The logs contain -- Using LLVM include directories: /build/source/llvm/include;/build/source/build-llvm/include which should normally include llvm/IR/Attributes.inc. This is applied as a global include in the CMake and should be a target of include_directories. However when I look at the compiler output I do not see -I/build/source/build-llvm/include included for some reason.

Maybe applying it directly to that library helps?

diff --git a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
index 0420d0e6f1f8..b84f3d7b137c 100644
--- a/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/common/CMakeLists.txt
@@ -60,6 +60,7 @@ target_link_options(PluginCommon PUBLIC ${offload_link_flags})

 target_include_directories(PluginCommon PUBLIC 
   ${CMAKE_CURRENT_SOURCE_DIR}/include
+  ${LIBOMPTARGET_LLVM_INCLUDE_DIRS}
   ${LIBOMPTARGET_INCLUDE_DIR}
 )

I don't get this locally so it's difficult for me to triage.

vzakhari commented 6 months ago

I do not know if it will help you, but here is another buildbot failing with the same error: https://lab.llvm.org/buildbot/#/builders/270/builds/11899

jhuber6 commented 6 months ago

I do not know if it will help you, but here is another buildbot failing with the same error: https://lab.llvm.org/buildbot/#/builders/270/builds/11899

Okay, I think this is due to some lack of dependencies on an LLVM thing. For some reason Attributes.def isn't being created before we try to compile libomptarget. I'm pretty sure if you keep mashing install it will eventually work since whatever target makes that file gets run. Will need to look into how to fix it.

My guess is that something was accidentally making this depend on tablegen. This goes away if you use LLVM_ENABLE_RUNTIMES=openmp, (which is probably going to be the only supported option when this is moved to offload). But it's definitely not ideal and this should depend on LLVM tablegen.

shiltian commented 6 months ago

We probably want to disable libomptarget in project build because 99% project build users only care about libomp.

jhuber6 commented 6 months ago

I have absolutely no clue how this wasn't failing before. The problem is that we can't just make it depend on intrinsics_gen because that might not even exist as a target yet.

jhuber6 commented 6 months ago

Okay adding the dependency seems to work even if it's not a registered target yet, another mystery of CMake. The flang bot is green now. If this passes on your bot we can close this issue.

vzakhari commented 6 months ago

Thanks! https://lab.llvm.org/buildbot/#/builders/270 is green now.