|
1 | 1 | #
|
2 |
| -# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | +# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | #
|
5 | 5 | # This code is free software; you can redistribute it and/or modify it
|
@@ -117,6 +117,11 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
|
117 | 117 | FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${DEBUG_PREFIX_CFLAGS}],
|
118 | 118 | IF_FALSE: [
|
119 | 119 | DEBUG_PREFIX_CFLAGS=
|
| 120 | + ], |
| 121 | + IF_TRUE: [ |
| 122 | + # Add debug prefix map gcc system include paths, as they cause |
| 123 | + # non-deterministic debug paths depending on gcc path location. |
| 124 | + DEBUG_PREFIX_MAP_GCC_INCLUDE_PATHS |
120 | 125 | ]
|
121 | 126 | )
|
122 | 127 | fi
|
@@ -158,6 +163,55 @@ AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
|
158 | 163 | AC_SUBST(ASFLAGS_DEBUG_SYMBOLS)
|
159 | 164 | ])
|
160 | 165 |
|
| 166 | +# gcc will embed the full system include paths in the debug info |
| 167 | +# resulting in non-deterministic debug symbol files and thus |
| 168 | +# non-reproducible native libraries if gcc includes are located |
| 169 | +# in different paths. |
| 170 | +# Add -fdebug-prefix-map'ings for root and gcc include paths, |
| 171 | +# pointing to a common set of folders so that the binaries are deterministic: |
| 172 | +# root include : /usr/include |
| 173 | +# gcc include : /usr/local/gcc_include |
| 174 | +# g++ include : /usr/local/gxx_include |
| 175 | +AC_DEFUN([DEBUG_PREFIX_MAP_GCC_INCLUDE_PATHS], |
| 176 | +[ |
| 177 | + # Determine gcc system include paths. |
| 178 | + # Assume default roots to start with: |
| 179 | + GCC_ROOT_INCLUDE="/usr/include" |
| 180 | +
|
| 181 | + # Determine is sysroot or devkit specified? |
| 182 | + if test "x$SYSROOT" != "x"; then |
| 183 | + GCC_ROOT_INCLUDE="${SYSROOT%/}/usr/include" |
| 184 | + fi |
| 185 | +
|
| 186 | + # Add root include mapping => /usr/include |
| 187 | + GCC_INCLUDE_DEBUG_MAP_FLAGS="-fdebug-prefix-map=${GCC_ROOT_INCLUDE}/=/usr/include/" |
| 188 | +
|
| 189 | + # Add gcc system include mapping => /usr/local/gcc_include |
| 190 | + # Find location of stddef.h using build C compiler |
| 191 | + GCC_SYSTEM_INCLUDE=`$ECHO "#include <stddef.h>" | \ |
| 192 | + $CC $CFLAGS -v -E - 2>&1 | \ |
| 193 | + $GREP stddef | $TAIL -1 | $TR -s " " | $CUT -d'"' -f2` |
| 194 | + if test "x$GCC_SYSTEM_INCLUDE" != "x"; then |
| 195 | + GCC_SYSTEM_INCLUDE=`$DIRNAME $GCC_SYSTEM_INCLUDE` |
| 196 | + GCC_INCLUDE_DEBUG_MAP_FLAGS="$GCC_INCLUDE_DEBUG_MAP_FLAGS \ |
| 197 | + -fdebug-prefix-map=${GCC_SYSTEM_INCLUDE}/=/usr/local/gcc_include/" |
| 198 | + fi |
| 199 | +
|
| 200 | + # Add g++ system include mapping => /usr/local/gxx_include |
| 201 | + # Find location of cstddef using build C++ compiler |
| 202 | + GXX_SYSTEM_INCLUDE=`$ECHO "#include <cstddef>" | \ |
| 203 | + $CXX $CXXFLAGS -v -E -x c++ - 2>&1 | \ |
| 204 | + $GREP cstddef | $TAIL -1 | $TR -s " " | $CUT -d'"' -f2` |
| 205 | + if test "x$GXX_SYSTEM_INCLUDE" != "x"; then |
| 206 | + GXX_SYSTEM_INCLUDE=`$DIRNAME $GXX_SYSTEM_INCLUDE` |
| 207 | + GCC_INCLUDE_DEBUG_MAP_FLAGS="$GCC_INCLUDE_DEBUG_MAP_FLAGS \ |
| 208 | + -fdebug-prefix-map=${GXX_SYSTEM_INCLUDE}/=/usr/local/gxx_include/" |
| 209 | + fi |
| 210 | +
|
| 211 | + # Add to debug prefix cflags |
| 212 | + DEBUG_PREFIX_CFLAGS="$DEBUG_PREFIX_CFLAGS $GCC_INCLUDE_DEBUG_MAP_FLAGS" |
| 213 | +]) |
| 214 | + |
161 | 215 | AC_DEFUN([FLAGS_SETUP_WARNINGS],
|
162 | 216 | [
|
163 | 217 | # Set default value.
|
|
0 commit comments