|
| 1 | +From 323b296e0087c079aa36115a678e0aa89cd34587 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Kumar Gala < [email protected]> |
| 3 | +Date: Wed, 13 May 2020 12:13:48 -0500 |
| 4 | +Subject: [PATCH 1/2] gdb: make gdb cross build its own function |
| 5 | + |
| 6 | +Make a function out of the cross build so we can call it more than once. |
| 7 | + |
| 8 | +Signed-off-by: Kumar Gala < [email protected]> |
| 9 | +--- |
| 10 | + scripts/build/debug/300-gdb.sh | 137 +++++++++++++++++---------------- |
| 11 | + 1 file changed, 71 insertions(+), 66 deletions(-) |
| 12 | + |
| 13 | +diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh |
| 14 | +index 91393317..98d415cb 100644 |
| 15 | +--- a/scripts/build/debug/300-gdb.sh |
| 16 | ++++ b/scripts/build/debug/300-gdb.sh |
| 17 | +@@ -15,82 +15,87 @@ do_debug_gdb_extract() |
| 18 | + chmod a+x "${CT_SRC_DIR}/gdb/gdb/gdbserver/configure" |
| 19 | + } |
| 20 | + |
| 21 | +-do_debug_gdb_build() |
| 22 | ++do_debug_gdb_build_cross() |
| 23 | + { |
| 24 | +- if [ "${CT_GDB_CROSS}" = "y" ]; then |
| 25 | +- local gcc_version p _p |
| 26 | +- local -a cross_extra_config |
| 27 | +- |
| 28 | +- CT_DoStep INFO "Installing cross-gdb" |
| 29 | +- CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-cross" |
| 30 | +- |
| 31 | +- cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" ) |
| 32 | +- if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then |
| 33 | +- if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then |
| 34 | +- if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then |
| 35 | +- CT_Abort "For canadian build, Python wrapper runnable on the build machine must be provided. Set CT_GDB_CROSS_PYTHON_BINARY." |
| 36 | +- elif [ "${CT_CONFIGURE_has_python}" = "y" ]; then |
| 37 | +- cross_extra_config+=("--with-python=${python}") |
| 38 | +- else |
| 39 | +- CT_Abort "Python support requested in GDB, but Python not found. Set CT_GDB_CROSS_PYTHON_BINARY." |
| 40 | +- fi |
| 41 | ++ local gcc_version p _p |
| 42 | ++ local -a cross_extra_config |
| 43 | ++ |
| 44 | ++ CT_DoStep INFO "Installing cross-gdb" |
| 45 | ++ CT_mkdir_pushd "${CT_BUILD_DIR}/build-gdb-cross" |
| 46 | ++ |
| 47 | ++ cross_extra_config=( "${CT_GDB_CROSS_EXTRA_CONFIG_ARRAY[@]}" ) |
| 48 | ++ if [ "${CT_GDB_CROSS_PYTHON}" = "y" ]; then |
| 49 | ++ if [ -z "${CT_GDB_CROSS_PYTHON_BINARY}" ]; then |
| 50 | ++ if [ "${CT_CANADIAN}" = "y" -o "${CT_CROSS_NATIVE}" = "y" ]; then |
| 51 | ++ CT_Abort "For canadian build, Python wrapper runnable on the build machine must be provided. Set CT_GDB_CROSS_PYTHON_BINARY." |
| 52 | ++ elif [ "${CT_CONFIGURE_has_python}" = "y" ]; then |
| 53 | ++ cross_extra_config+=("--with-python=${python}") |
| 54 | + else |
| 55 | +- cross_extra_config+=("--with-python=${CT_GDB_CROSS_PYTHON_BINARY}") |
| 56 | ++ CT_Abort "Python support requested in GDB, but Python not found. Set CT_GDB_CROSS_PYTHON_BINARY." |
| 57 | + fi |
| 58 | + else |
| 59 | +- cross_extra_config+=("--with-python=no") |
| 60 | ++ cross_extra_config+=("--with-python=${CT_GDB_CROSS_PYTHON_BINARY}") |
| 61 | + fi |
| 62 | ++ else |
| 63 | ++ cross_extra_config+=("--with-python=no") |
| 64 | ++ fi |
| 65 | + |
| 66 | +- if [ "${CT_GDB_CROSS_SIM}" = "y" ]; then |
| 67 | +- cross_extra_config+=("--enable-sim") |
| 68 | +- else |
| 69 | +- cross_extra_config+=("--disable-sim") |
| 70 | +- fi |
| 71 | ++ if [ "${CT_GDB_CROSS_SIM}" = "y" ]; then |
| 72 | ++ cross_extra_config+=("--enable-sim") |
| 73 | ++ else |
| 74 | ++ cross_extra_config+=("--disable-sim") |
| 75 | ++ fi |
| 76 | + |
| 77 | +- if ${CT_HOST}-gcc --version 2>&1 | grep clang; then |
| 78 | +- # clang detects the line from gettext's _ macro as format string |
| 79 | +- # not being a string literal and produces a lot of warnings - which |
| 80 | +- # ct-ng's logger faithfully relays to user if this happens in the |
| 81 | +- # error() function. Suppress them. |
| 82 | +- cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security") |
| 83 | +- fi |
| 84 | ++ if ${CT_HOST}-gcc --version 2>&1 | grep clang; then |
| 85 | ++ # clang detects the line from gettext's _ macro as format string |
| 86 | ++ # not being a string literal and produces a lot of warnings - which |
| 87 | ++ # ct-ng's logger faithfully relays to user if this happens in the |
| 88 | ++ # error() function. Suppress them. |
| 89 | ++ cross_extra_config+=("--enable-build-warnings=,-Wno-format-nonliteral,-Wno-format-security") |
| 90 | ++ fi |
| 91 | + |
| 92 | +- do_gdb_backend \ |
| 93 | +- buildtype=cross \ |
| 94 | +- host="${CT_HOST}" \ |
| 95 | +- cflags="${CT_CFLAGS_FOR_HOST}" \ |
| 96 | +- ldflags="${CT_LDFLAGS_FOR_HOST}" \ |
| 97 | +- prefix="${CT_PREFIX_DIR}" \ |
| 98 | +- static="${CT_GDB_CROSS_STATIC}" \ |
| 99 | +- --with-sysroot="${CT_SYSROOT_DIR}" \ |
| 100 | +- "${cross_extra_config[@]}" |
| 101 | +- |
| 102 | +- if [ "${CT_BUILD_MANUALS}" = "y" ]; then |
| 103 | +- CT_DoLog EXTRA "Building and installing the cross-GDB manuals" |
| 104 | +- CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html |
| 105 | +- CT_DoExecLog ALL make install-{pdf,html}-gdb |
| 106 | +- fi |
| 107 | ++ do_gdb_backend \ |
| 108 | ++ buildtype=cross \ |
| 109 | ++ host="${CT_HOST}" \ |
| 110 | ++ cflags="${CT_CFLAGS_FOR_HOST}" \ |
| 111 | ++ ldflags="${CT_LDFLAGS_FOR_HOST}" \ |
| 112 | ++ prefix="${CT_PREFIX_DIR}" \ |
| 113 | ++ static="${CT_GDB_CROSS_STATIC}" \ |
| 114 | ++ --with-sysroot="${CT_SYSROOT_DIR}" \ |
| 115 | ++ "${cross_extra_config[@]}" |
| 116 | ++ |
| 117 | ++ if [ "${CT_BUILD_MANUALS}" = "y" ]; then |
| 118 | ++ CT_DoLog EXTRA "Building and installing the cross-GDB manuals" |
| 119 | ++ CT_DoExecLog ALL make ${CT_JOBSFLAGS} pdf html |
| 120 | ++ CT_DoExecLog ALL make install-{pdf,html}-gdb |
| 121 | ++ fi |
| 122 | + |
| 123 | +- if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then |
| 124 | +- CT_DoLog EXTRA "Installing '.gdbinit' template" |
| 125 | +- # See in scripts/build/internals.sh for why we do this |
| 126 | +- # TBD GCC 3.x and older not supported |
| 127 | +- if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then |
| 128 | +- gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER") |
| 129 | +- else |
| 130 | +- gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ |
| 131 | +- "${CT_SRC_DIR}/gcc/gcc/version.c" \ |
| 132 | +- ) |
| 133 | +- fi |
| 134 | +- sed -r \ |
| 135 | +- -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \ |
| 136 | +- -e "s:@@VERSION@@:${gcc_version}:;" \ |
| 137 | +- "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \ |
| 138 | +- >"${CT_PREFIX_DIR}/share/gdb/gdbinit" |
| 139 | +- fi # Install gdbinit sample |
| 140 | ++ if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then |
| 141 | ++ CT_DoLog EXTRA "Installing '.gdbinit' template" |
| 142 | ++ # See in scripts/build/internals.sh for why we do this |
| 143 | ++ # TBD GCC 3.x and older not supported |
| 144 | ++ if [ -f "${CT_SRC_DIR}/gcc/gcc/BASE-VER" ]; then |
| 145 | ++ gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER") |
| 146 | ++ else |
| 147 | ++ gcc_version=$(sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \ |
| 148 | ++ "${CT_SRC_DIR}/gcc/gcc/version.c" \ |
| 149 | ++ ) |
| 150 | ++ fi |
| 151 | ++ sed -r \ |
| 152 | ++ -e "s:@@PREFIX@@:${CT_PREFIX_DIR}:;" \ |
| 153 | ++ -e "s:@@VERSION@@:${gcc_version}:;" \ |
| 154 | ++ "${CT_LIB_DIR}/scripts/build/debug/gdbinit.in" \ |
| 155 | ++ >"${CT_PREFIX_DIR}/share/gdb/gdbinit" |
| 156 | ++ fi # Install gdbinit sample |
| 157 | ++ |
| 158 | ++ CT_Popd |
| 159 | ++ CT_EndStep |
| 160 | ++} |
| 161 | + |
| 162 | +- CT_Popd |
| 163 | +- CT_EndStep |
| 164 | ++do_debug_gdb_build() |
| 165 | ++{ |
| 166 | ++ if [ "${CT_GDB_CROSS}" = "y" ]; then |
| 167 | ++ do_debug_gdb_build_cross |
| 168 | + fi |
| 169 | + |
| 170 | + if [ "${CT_GDB_NATIVE}" = "y" -o "${CT_GDB_GDBSERVER}" = "y" ]; then |
| 171 | +-- |
| 172 | +2.25.4 |
| 173 | + |
0 commit comments