https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126707

            Bug ID: 126707
           Summary: .debug_loclist not reproducible with PCH
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Keywords: compare-debug-failure
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-*-*

I've tested this on:
* 16-core x86_64 machine with 32G of RAM
   kernel: Linux 6.12.95+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian
6.12.95-1 (2026-07-04) x86_64 GNU/Linux
* 8-core x86_64 machine with 16G of RAM
   kernel: Linux 7.1.5 #1-NixOS SMP PREEMPT_DYNAMIC Fri Jul 24 14:21:27
UTC 2026 x86_64 GNU/Linux

I've run the following commands:
podman run -it --rm --network host --workdir /src -v .:/src
debian:sid-20260803
apt update && apt install g++ git #installs gcc (Debian 16.1.0-3) 16.1.0
git clone https://github.com/KhronosGroup/glslang.git
cd glslang && git checkout vulkan-sdk-1.4.350.1

cat <<EOF >/src/glslang/glslang/build_info.h
#ifndef GLSLANG_BUILD_INFO
#define GLSLANG_BUILD_INFO

#define GLSLANG_VERSION_MAJOR 16
#define GLSLANG_VERSION_MINOR 3
#define GLSLANG_VERSION_PATCH 0
#define GLSLANG_VERSION_FLAVOR ""

#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
     ((GLSLANG_VERSION_MAJOR) > (major) || ((major) ==
GLSLANG_VERSION_MAJOR && \
     ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) ==
GLSLANG_VERSION_MINOR && \
      (GLSLANG_VERSION_PATCH) > (patch)))))

#define GLSLANG_VERSION_GREATER_OR_EQUAL_TO(major, minor, patch) \
     ((GLSLANG_VERSION_MAJOR) > (major) || ((major) ==
GLSLANG_VERSION_MAJOR && \
     ((GLSLANG_VERSION_MINOR) > (minor) || ((minor) ==
GLSLANG_VERSION_MINOR && \
      (GLSLANG_VERSION_PATCH >= (patch))))))

#define GLSLANG_VERSION_LESS_THAN(major, minor, patch) \
     ((GLSLANG_VERSION_MAJOR) < (major) || ((major) ==
GLSLANG_VERSION_MAJOR && \
     ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) ==
GLSLANG_VERSION_MINOR && \
      (GLSLANG_VERSION_PATCH) < (patch)))))

#define GLSLANG_VERSION_LESS_OR_EQUAL_TO(major, minor, patch) \
     ((GLSLANG_VERSION_MAJOR) < (major) || ((major) ==
GLSLANG_VERSION_MAJOR && \
     ((GLSLANG_VERSION_MINOR) < (minor) || ((minor) ==
GLSLANG_VERSION_MINOR && \
      (GLSLANG_VERSION_PATCH <= (patch))))))

#endif // GLSLANG_BUILD_INFO
EOF
mkdir -p /src/glslang/_builddir/glslang/CMakeFiles/glslang.dir
cat <<EOF
 >/src/glslang/_builddir/glslang/CMakeFiles/glslang.dir/cmake_pch.hxx
/* generated by CMake */

#pragma GCC system_header
#ifdef __cplusplus
#include "/src/glslang/glslang/MachineIndependent/pch.h"
#endif // __cplusplus
EOF
cat <<EOF
 >/src/glslang/_builddir/glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.cxx
/* generated by CMake */
EOF
cd _builddir
cat <<EOF >compile.sh
#!/usr/bin/env bash
set -eux
c++ -DENABLE_HLSL -DENABLE_OPT=0 -DENABLE_SPIRV
-DGLSLANG_IS_SHARED_LIBRARY=1 -DGLSLANG_OSINCLUDE_UNIX
-DGLSLANG_TEST_BUILD -Dglslang_EXPORTS -I/src/glslang/glslang/..
-I/src/glslang/_builddir/include -O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=3
-Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong
-grecord-gcc-switches -fasynchronous-unwind-tables
-fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer -fdump-rtl-vartrack-details -DNDEBUG
-std=c++17 -fPIC -fvisibility=hidden -Wall -Wmaybe-uninitialized
-Wuninitialized -Wunused -Wunused-local-typedefs -Wimplicit-fallthrough
-Wunused-parameter -Wunused-value -Wunused-variable
-Wunused-but-set-parameter -Wunused-but-set-variable -fno-rtti
-fno-exceptions -Werror=deprecated-copy -Winvalid-pch -x c++-header
-include
/src/glslang/_builddir/glslang/CMakeFiles/glslang.dir/cmake_pch.hxx -o
glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.gch -c
/src/glslang/_builddir/glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.cxx
c++ -DENABLE_HLSL -DENABLE_OPT=0 -DENABLE_SPIRV
-DGLSLANG_IS_SHARED_LIBRARY=1 -DGLSLANG_OSINCLUDE_UNIX
-DGLSLANG_TEST_BUILD -Dglslang_EXPORTS -I/src/glslang -O2 -pipe -g
-Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-fdump-rtl-vartrack-details -DNDEBUG -std=c++17 -fPIC
-fvisibility=hidden -Wall -Wmaybe-uninitialized -Wuninitialized -Wunused
-Wunused-local-typedefs -Wimplicit-fallthrough -Wunused-parameter
-Wunused-value -Wunused-variable -Wunused-but-set-parameter
-Wunused-but-set-variable -fno-rtti -fno-exceptions
-Werror=deprecated-copy -Winvalid-pch -include
/src/glslang/_builddir/glslang/CMakeFiles/glslang.dir/cmake_pch.hxx -o
/src/glslang/glslang/MachineIndependent/ShaderLang.cpp.o -c
/src/glslang/glslang/MachineIndependent/ShaderLang.cpp

EOF
chmod +x compile.sh
cat <<EOF >clean.sh
#!/usr/bin/env bash
set -eux
rm -f glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.gch
rm -f /src/glslang/glslang/MachineIndependent/ShaderLang.cpp.*
EOF
chmod +x clean.sh

./clean.sh
./compile.sh
mkdir build_reference
sha256sum /src/glslang/glslang/MachineIndependent/ShaderLang.cpp.o >
build_reference/sha256.txt
mv glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.gch
/src/glslang/glslang/MachineIndependent/ShaderLang.cpp.*
build_reference/

for x in $(seq 1 1000); do ./clean.sh; ./compile.sh; sha256sum
/src/glslang/glslang/MachineIndependent/ShaderLang.cpp.o >
build_result_$x.txt; if [ "$(cat build_result_$x.txt)" != "$(cat
build_reference/sha256.txt)" ]; then mkdir checkout_$x; mv
glslang/CMakeFiles/glslang.dir/cmake_pch.hxx.gch
/src/glslang/glslang/MachineIndependent/ShaderLang.cpp.* checkout_$x/;
fi; done

After about 15-20 minutes I reliably get a checkout_* directory with a
different
build result.

My guess is that it's related to the interaction between pre-compiled
headers and
variable tracking pass. I've worked around that by disabling
pre-compiled headers
in glslang build for now, but the bug is still there in gcc I think.

Reply via email to