Vulkan-Tools icon indicating copy to clipboard operation
Vulkan-Tools copied to clipboard

vulkaninfo: suppress -isystem being passed

Open stsquad opened this issue 10 months ago • 13 comments

During the process of updating vulkan-tools in buildroot I ran into the following build failure:

[ 50%] Building CXX object vulkaninfo/CMakeFiles/vulkaninfo.dir/vulkaninfo.cpp.o In file included from /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/include/c++/14.2.0/bits/stl_algo.h:71, from /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/include/c++/14.2.0/algorithm:61, from /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.4.307/vulkaninfo/./vulkaninfo.h:31, from /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.4.307/vulkaninfo/generated/vulkaninfo.hpp:28, from /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.4.307/vulkaninfo/vulkaninfo.cpp:34: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/include/c++/14.2.0/cstdlib:79:15: fatal error: stdlib.h: No such file or directory 79 | #include_next <stdlib.h> | ^~~~~~~~~~ compilation terminated. make[2]: *** [vulkaninfo/CMakeFiles/vulkaninfo.dir/build.make:76: vulkaninfo/CMakeFiles/vulkaninfo.dir/vulkaninfo.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:116: vulkaninfo/CMakeFiles/vulkaninfo.dir/all] Error 2 make: *** [Makefile:136: all] Error 2

The underlying reason was -isystem being passed to the build which I think resets the include path for system includes. This might be a bug in cmake but from looking at the CMake source I found some examples that set: NO_SYSTEM_FROM_IMPORTED 1 as a target property which seems to do the job.

This doesn't seem to affect the normal non-cross build although I wouldn't expect you need to pass -isystem anyway.

stsquad avatar Feb 14 '25 10:02 stsquad

Author stsquad not on autobuild list. Waiting for curator authorization before starting CI build.

ci-tester-lunarg avatar Feb 14 '25 10:02 ci-tester-lunarg

Author stsquad not on autobuild list. Waiting for curator authorization before starting CI build.

ci-tester-lunarg avatar Feb 14 '25 10:02 ci-tester-lunarg

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 14 '25 10:02 CLAassistant

CI Vulkan-Tools build queued with queue ID 372256.

ci-tester-lunarg avatar Feb 15 '25 01:02 ci-tester-lunarg

CI Vulkan-Tools build # 1620 running.

ci-tester-lunarg avatar Feb 15 '25 01:02 ci-tester-lunarg

CI Vulkan-Tools build # 1620 passed.

ci-tester-lunarg avatar Feb 15 '25 01:02 ci-tester-lunarg

Usually cross platform builds do not need such a change. Can you post your toolchain file, or at least the main bits of it? Not being able to find the standard library makes me think the C compiler is being used instead of the C++.

charles-lunarg avatar Feb 18 '25 09:02 charles-lunarg

The build configure steps are:

vulkan-tools-1.3.262.tar.gz: OK (sha256: 8c77d02694d0516ae2ba3f3718745647e87e788ef93faabb2e3674ff32608010)
>>> vulkan-tools 1.3.262 Extracting
gzip -d -c /home/alex/lsrc/tests/buildroot.git/dl/vulkan-tools/vulkan-tools-1.3.262.tar.gz | /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/bin/tar --strip-components=1 -C /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.3.262   -xf -
>>> vulkan-tools 1.3.262 Patching
>>> vulkan-tools 1.3.262 Configuring
(mkdir -p /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.3.262/ && cd /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.3.262/ && rm -f CMakeCache.txt && PATH="/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/bin:/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/sbin:/home/alex/src/emacs/install/bin:/usr/lib/ccache:/home/alex/.cargo/bin:/home/alex/.local/bin:/home/alex/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"  /usr/bin/cmake /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.3.262/ -G"Unix Makefiles" -DCMAKE_MAKE_PROGRAM="/usr/bin/make" -DCMAKE_TOOLCHAIN_FILE="/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/share/buildroot/toolchainfile.cmake" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_INSTALL_RUNSTATEDIR="/run" -DCMAKE_COLOR_MAKEFILE=OFF -DBUILD_DOC=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TEST=OFF -DBUILD_TESTS=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON  -DBUILD_CUBE=OFF -DBUILD_ICD=OFF -DBUILD_VULKANINFO=ON -DINSTALL_ICD=OFF -DBUILD_WSI_DIRECTFB_SUPPORT=OFF -DBUILD_WSI_XCB_SUPPORT=ON -DBUILD_WSI_XLIB_SUPPORT=ON -DBUILD_WSI_WAYLAND_SUPPORT=ON )
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/bin/aarch64-buildroot-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/bin/aarch64-buildroot-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/bin/pkg-config (found version "2.3.0") 
-- Found WAYLAND_CLIENT: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-client.so  
-- Found WAYLAND_SERVER: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-server.so  
-- Found WAYLAND_EGL: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-egl.so  
-- Found WAYLAND_CURSOR: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-cursor.so  
-- Found WAYLAND: /home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-client.so;/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-server.so;/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-egl.so;/home/alex/lsrc/tests/buildroot.git/builds/arm64/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libwayland-cursor.so  
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_DOC
    BUILD_DOCS
    BUILD_EXAMPLE
    BUILD_EXAMPLES
    BUILD_TEST
    BUILD_TESTING


-- Build files have been written to: /home/alex/lsrc/tests/buildroot.git/builds/arm64/build/vulkan-tools-1.3.262

The toolchain.cmake contains:

#
# Automatically generated file; DO NOT EDIT.
# CMake toolchain file for Buildroot
#

# In order to allow the toolchain to be relocated, we calculate the
# HOST_DIR based on this file's location: $(HOST_DIR)/share/buildroot
# and store it in RELOCATED_HOST_DIR.
# All the other variables that need to refer to HOST_DIR will use the
# RELOCATED_HOST_DIR variable.
string(REPLACE "/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST_DIR})

# Point cmake to the location where we have our custom modules,
# so that it can find our custom platform description.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

if(NOT DEFINED CMAKE_SYSTEM_NAME)
  set(CMAKE_SYSTEM_NAME Buildroot)
endif()
if(NOT DEFINED CMAKE_SYSTEM_VERSION)
  set(CMAKE_SYSTEM_VERSION 1)
endif()
if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
  set(CMAKE_SYSTEM_PROCESSOR aarch64)
endif()

# Set the {C,CXX}FLAGS appended by CMake depending on the build type
# defined by Buildroot. CMake defaults these variables with -g and/or
# -O options, and they are appended at the end of the argument list,
# so the Buildroot options are overridden. Therefore these variables
# have to be cleared, so that the options passed in CMAKE_C_FLAGS do
# apply.
#
# Note:
#   if the project forces some of these flag variables, Buildroot is
#   screwed up and there is nothing Buildroot can do about that :(
if(NOT DEFINED CMAKE_C_FLAGS_DEBUG)
  set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Debug CFLAGS")
endif()
if(NOT DEFINED CMAKE_C_FLAGS_RELEASE)
  set(CMAKE_C_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CFLAGS")
endif()

# Build type from the Buildroot configuration
if(NOT DEFINED CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release CACHE STRING "Buildroot build configuration")
endif()

# Buildroot defaults flags.
# If you are using this toolchainfile.cmake file outside of Buildroot and
# want to customize the compiler/linker flags, then:
# * set them all on the cmake command line, e.g.:
#     cmake -DCMAKE_C_FLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Og -g3 -D_FORTIFY_SOURCE=1 -Dsome_custom_flag" ...
# * and make sure the project's CMake code extends them like this if needed:
#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dsome_definitions")
if(NOT DEFINED CMAKE_C_FLAGS)
  set(CMAKE_C_FLAGS "-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Og -g3 -D_FORTIFY_SOURCE=1" CACHE STRING "Buildroot CFLAGS")
endif()
if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS)
  set(CMAKE_EXE_LINKER_FLAGS "" CACHE STRING "Buildroot LDFLAGS for executables")
endif()
if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS)
  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "Buildroot LDFLAGS for shared libraries")
endif()
if(NOT DEFINED CMAKE_MODULE_LINKER_FLAGS)
  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "Buildroot LDFLAGS for module libraries")
endif()

if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
  set(CMAKE_INSTALL_SO_NO_EXE 0)
endif()

if(NOT DEFINED CMAKE_PROGRAM_PATH)
  set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/bin")
endif()
if(NOT DEFINED CMAKE_SYSROOT)
  set(CMAKE_SYSROOT "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")
endif()
if(NOT DEFINED CMAKE_FIND_ROOT_PATH)
  set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")
endif()
if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif()
if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()
if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
endif()
if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/aarch64-buildroot-linux-gnu/sysroot")

# This toolchain file can be used both inside and outside Buildroot.
if(NOT DEFINED CMAKE_C_COMPILER)
  set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/bin/aarch64-buildroot-linux-gnu-gcc")
endif()
if(1)
  if(NOT DEFINED CMAKE_CXX_FLAGS_DEBUG)
    set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
  endif()
  if(NOT DEFINED CMAKE_CXX_FLAGS_RELEASE)
    set(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CXXFLAGS")
  endif()
  if(NOT DEFINED CMAKE_CXX_FLAGS)
    set(CMAKE_CXX_FLAGS "-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Og -g3 -D_FORTIFY_SOURCE=1" CACHE STRING "Buildroot CXXFLAGS")
  endif()
  if(NOT DEFINED CMAKE_CXX_COMPILER)
    set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/bin/aarch64-buildroot-linux-gnu-g++")
  endif()
endif()
if(0)
  if(NOT DEFINED CMAKE_Fortran_FLAGS_DEBUG)
    set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
  endif()
  if(NOT DEFINED CMAKE_Fortran_FLAGS_RELEASE)
    set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")
  endif()
  if(NOT DEFINED CMAKE_Fortran_FLAGS)
    set(CMAKE_Fortran_FLAGS "-Og -g3" CACHE STRING "Buildroot FCFLAGS")
  endif()
  if(NOT DEFINED CMAKE_Fortran_COMPILER)
    set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/bin/aarch64-buildroot-linux-gnu-gfortran")
  endif()
endif()

# For Qt6
if(NOT DEFINED QT_HOST_PATH)
  set(QT_HOST_PATH "${RELOCATED_HOST_DIR}")
endif()

if(NOT DEFINED QT_HOST_PATH_CMAKE_DIR)
  set(QT_HOST_PATH_CMAKE_DIR "${RELOCATED_HOST_DIR}/lib/cmake")
endif()

stsquad avatar Feb 18 '25 17:02 stsquad

@charles-lunarg was the toolchain as you expected?

stsquad avatar Feb 27 '25 14:02 stsquad

Unfortunately, I cannot recreate the build as I don't have all the setup steps required to get the buildroot folder in the way that the compiler/project expects. Cross compilation is not my forte and I'm not able to invest hours in figuring out the exact build setup used. I am very suspicious of not being able to find the C standard libraries meaning something about the toolchain or system setup is running afoul.

Side note, you are using the 1.3.262 header version, which is over a year old (thus possibly has had some issues already fixed) and also not an SDK version (where LunarG does additional verification) of the components. It may be worth using a newer version for that reason.

I also will say that I have very little interest in merging the requested change. This looks like a workaround for a build/packaging/cmake issue rather than something that is integral for building vulkaninfo. -isystem is primarily to tell the compiler to ignore warnings/errors coming from the header file, rather than directing anything about where system headers are located.

charles-lunarg avatar Mar 09 '25 15:03 charles-lunarg

I'll try with the latest SDK. You don't have to merge but best practice for buildroot is to submit upstream and track just in case a better solution is suggested.

stsquad avatar Mar 09 '25 19:03 stsquad

Still fails with 1.4.310 - I note that Yocto doesn't seem to need to do this: https://git.yoctoproject.org/poky/plain/meta/recipes-graphics/vulkan/vulkan-tools_1.3.296.0.bb but they haven't moved past 1.3.296 (buildroot was previously on 1.3.262).

stsquad avatar Mar 12 '25 13:03 stsquad

You don't have to merge but best practice for buildroot is to submit upstream and track just in case a better solution is suggested.

I see. That makes a lot more sense now - happy to let this PR live while the issue is still present.

charles-lunarg avatar Mar 27 '25 15:03 charles-lunarg