intel / intel-graphics-compiler

Other
596 stars 155 forks source link

incorrect #include "../../foo.h" paths #260

Closed anbe42 closed 1 year ago

anbe42 commented 1 year ago

While analyzing a CI failure in the Debian package of igc (https://salsa.debian.org/opencl-team/intel-graphics-compiler/-/jobs/3346488/raw), I found that some #include "../../foo.h do not point to actual files but need to be looked up via the -I search paths. That lead to the inclusion of a header from two different locations, causing weird duplicate definition errors. (The CI seems to have another unpacked source tree further up in the path and one copy was found there via ../../.. and some -I$sourceroot) The actual culprit was IGC/AdaptorOCL/OCL/sp/sp_g8.cpp which has #include "../../../visa/include/visaBuilder_interface.h" that is missing a ../ to actually find the file.

A quick check with this script (as ../check-relative-includes):

#!/bin/sh

# find . -type f \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -exec ../check-relative-includes '{}' \;

f=$1
test -f "$f" || exit 1

d=$(dirname $f)

for rincl in $(sed -r -n 's/^.*#\s*include\s+[<"](.*\.\..*)[>"].*$/\1/p' $f)
do
        test -f "$d/$rincl" || echo "$f $rincl"
done

found a few more possibly wrong include paths:

./3d/common/iStdLib/utility.h ../../inc/common/secure_mem.h
./3d/common/iStdLib/utility.h ../../inc/common/secure_string.h
./3d/common/iStdLib/FastMask.h ..\..\d3d\ibdw\d3ddebug.h
./IGC/AdaptorCommon/API/igc.h ../IGC/Compiler/CodeGenPublicEnums.h
./IGC/AdaptorCommon/RayTracing/RTCompileOptions.h ../../IGC/AdaptorCommon/RayTracing/ADT/Optional.h
./IGC/AdaptorOCL/OCL/Patch/patch_parser.cpp ../../3d/common/iStdLib/iStdLib.h
./IGC/AdaptorOCL/OCL/Platform/cmd_parser_g8.h ../inc/common/igfxfmid.h
./IGC/AdaptorOCL/OCL/Platform/cmd_parser_g8.cpp ../inc/common/igfxfmid.h
./IGC/AdaptorOCL/OCL/sp/sp_g8.h ../../inc/common/igfxfmid.h
./IGC/AdaptorOCL/OCL/sp/sp_g8.cpp ../../../visa/include/visaBuilder_interface.h
./IGC/AdaptorOCL/SPIRV/SPIRVInternal.h ../../inc/common/UFO/portable_compiler.h
./IGC/Compiler/CISACodeGen/CISACodeGen.h ../../inc/common/UFO/portable_compiler.h
./IGC/Compiler/CodeGenPublicEnums.h ../IGC/common/EmUtils.h
./IGC/Compiler/CustomSafeOptPass.cpp ../inc/common/secure_mem.h
./IGC/LLVM3DBuilder/BuiltinsFrontend.hpp ../../../skuwa/iacm_g10_rev_id.h
./IGC/LLVM3DBuilder/BuiltinsFrontend.hpp ../../../skuwa/iacm_g11_rev_id.h
./IGC/LLVM3DBuilder/BuiltinsFrontend.hpp ../../../skuwa/iacm_g12_rev_id.h
./IGC/common/ShaderOverride.cpp ../../../visa/iga/IGALibrary/api/igad.h
./visa/FC_linker/PatchInfoDumper.cpp ../PatchInfo.h
./visa/FC_linker/PatchInfoReader.cpp ../PatchInfo.h
./visa/FC_linker/PatchInfoRecord.h ../PatchInfo.h

(please check intel-compute-runtime, too)

pszymich commented 1 year ago

Hi, can you check if 982d253e0a2bb24130f42fd7ad27b257bed183c3 helps? Thanks @Quetzonarch for the patch!

mnaczk commented 1 year ago

Closed as resolved. Please reopen if there is still a need for fixes.