[PATCH v1 1/4] Add target compile definitions in libraries interacting with DWARF arch-extensions
Matthieu Longo
matthieu.longo@arm.com
Wed Dec 11 12:05:50 GMT 2024
DWARF 5 standard provides a space for vendor-specific DWARF directives.
Binutils currently defines GNU-specific DWARF directives and vendor-specific
ones for AArch64, SGI/MIPS, and Sparc architectures.
However, the current implementation does not provide a "switch mechanism"
to enable/disable those extensions depending on the selected target
except in gas via TC_<arch>.
This patch adds the boilerplate to add the TC_<arch> definition to all
modules of binutils interacting with architecture-specific DWARF
directives, i.e. bfd, binutils, gprofng, libbacktrace, libiberty.
CI-tag: skip
---
bfd/Makefile.am | 3 ++-
bfd/configure.ac | 9 ++++++++
bfd/configure.tgt | 42 ++++++++++++++++++++++++++++++++++++++
binutils/configure.ac | 12 +++++++++--
binutils/configure.tgt | 21 +++++++++++++++++--
gprofng/Makefile.am | 4 +++-
gprofng/configure.ac | 9 ++++++++
gprofng/configure.tgt | 42 ++++++++++++++++++++++++++++++++++++++
libbacktrace/Makefile.am | 3 +++
libbacktrace/configure.ac | 10 +++++++++
libbacktrace/configure.tgt | 42 ++++++++++++++++++++++++++++++++++++++
libiberty/Makefile.in | 3 +++
libiberty/configure.ac | 10 +++++++++
libiberty/configure.tgt | 42 ++++++++++++++++++++++++++++++++++++++
14 files changed, 246 insertions(+), 6 deletions(-)
create mode 100644 bfd/configure.tgt
create mode 100644 gprofng/configure.tgt
create mode 100644 libbacktrace/configure.tgt
create mode 100644 libiberty/configure.tgt
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index dadbd0f7882..f4f275bc000 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -662,7 +662,8 @@ OPTIONAL_BACKENDS_CFILES = \
CONFIG_STATUS_DEPENDENCIES = \
$(srcdir)/config.bfd \
$(srcdir)/configure.host \
- $(srcdir)/development.sh
+ $(srcdir)/development.sh \
+ $(srcdir)/configure.tgt
# These are defined by configure:
WORDSIZE = @wordsize@
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 465a7463d48..b00bde43be7 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -1032,6 +1032,15 @@ case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in
true+yes ) AC_DEFINE(USE_MMAP, 1, [Use mmap if it's available?]) ;;
esac
+targ=${target}
+. ${srcdir}/configure.tgt
+
+case ${cpu_type} in
+ aarch64*) AC_DEFINE(TC_AARCH64, 1, [Compile for AArch64 targets]) ;;
+ sparc*) AC_DEFINE(TC_SPARC, 1, [Compile for Sparc targets]) ;;
+ mips*) AC_DEFINE(TC_MIPS, 1, [Compile for MIPS targets]) ;;
+esac
+
AC_CONFIG_FILES([Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in])
dnl We need this duplication, even though we use AM_PO_SUBDIRS, because of
diff --git a/bfd/configure.tgt b/bfd/configure.tgt
new file mode 100644
index 00000000000..5bccdc94998
--- /dev/null
+++ b/bfd/configure.tgt
@@ -0,0 +1,42 @@
+# bfd target specific configuration file. This is a -*- sh -*- file.
+#
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+#
+
+# This is invoked by configure. Putting it in a separate shell file
+# lets us skip running autoconf when modifying target specific
+# information.
+
+# Input shell variables:
+# targ a configuration target name, such as i686-pc-linux-gnu.
+
+# Output shell variables:
+# cpu_type canonical gas cpu type; identifies the gas/config/tc-* files
+
+cpu_type=
+
+eval $(echo ${targ} | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/')
+
+# Check for architecture variants. Set cpu_type and, optionally,
+# endian and arch.
+# Note: This table is alpha-sorted, please try to keep it that way.
+case ${cpu} in
+ aarch64*) cpu_type=aarch64 ;;
+ mips*) cpu_type=mips ;;
+ sparc*) cpu_type=sparc ;;
+ *) cpu_type=${cpu} ;;
+esac
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 31fab69fd0f..86c4a13a286 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -546,9 +546,17 @@ fi
AC_DEFINE_UNQUOTED(TARGET_PREPENDS_UNDERSCORE, $UNDERSCORE,
[Define to 1 if user symbol names have a leading underscore, 0 if not.])
-# Emulation
-targ=$target
+targ=${target}
. ${srcdir}/configure.tgt
+
+# Target-specific definitions
+case ${cpu_type} in
+ aarch64*) AC_DEFINE(TC_AARCH64, 1, [Compile for AArch64 targets]) ;;
+ sparc*) AC_DEFINE(TC_SPARC, 1, [Compile for Sparc targets]) ;;
+ mips*) AC_DEFINE(TC_MIPS, 1, [Compile for MIPS targets]) ;;
+esac
+
+# Emulation
EMULATION=$targ_emul
EMULATION_VECTOR=$targ_emul_vector
diff --git a/binutils/configure.tgt b/binutils/configure.tgt
index 94e4e16c95d..f0a37019e6d 100644
--- a/binutils/configure.tgt
+++ b/binutils/configure.tgt
@@ -19,8 +19,11 @@
# along with this program; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-# This file switches on the shell variable ${targ}, and sets the
-# following shell variables:
+# Input shell variables:
+# targ a configuration target name, such as i686-pc-linux-gnu.
+
+# Output shell variables:
+# cpu_type canonical gas cpu type; identifies the gas/config/tc-* files
# targ_emul name of emulation to use
# targ_emul_vector name of vector to use
@@ -40,3 +43,17 @@ case "${targ}" in
targ_emul_vector=bin_vanilla_emulation
;;
esac
+
+cpu_type=
+
+eval $(echo ${targ} | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/')
+
+# Check for architecture variants. Set cpu_type and, optionally,
+# endian and arch.
+# Note: This table is alpha-sorted, please try to keep it that way.
+case ${cpu} in
+ aarch64*) cpu_type=aarch64 ;;
+ mips*) cpu_type=mips ;;
+ sparc*) cpu_type=sparc ;;
+ *) cpu_type=${cpu} ;;
+esac
diff --git a/gprofng/Makefile.am b/gprofng/Makefile.am
index a5ee9dd63f3..429ede7ec87 100644
--- a/gprofng/Makefile.am
+++ b/gprofng/Makefile.am
@@ -82,7 +82,9 @@ development.exp: $(BFDDIR)/development.sh
| $(AWK) -F= '{ print "set " $$1 " " $$2 }' > $@
# development.sh is used to determine -Werror default.
-CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
+CONFIG_STATUS_DEPENDENCIES = \
+ $(BFDDIR)/configure.tgt \
+ $(BFDDIR)/development.sh
EXTRA_DEJAGNU_SITE_CONFIG = development.exp
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 5a4013c6940..a723c81a92c 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -259,6 +259,15 @@ AC_SUBST(CLOCK_GETTIME_LINK)
AC_SUBST(BUILD_SUBDIRS)
+targ=${target}
+. ${srcdir}/configure.tgt
+
+case ${cpu_type} in
+ aarch64*) AC_DEFINE(TC_AARCH64, 1, [Compile for AArch64 targets]) ;;
+ sparc*) AC_DEFINE(TC_SPARC, 1, [Compile for Sparc targets]) ;;
+ mips*) AC_DEFINE(TC_MIPS, 1, [Compile for MIPS targets]) ;;
+esac
+
AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
AC_CONFIG_HEADERS([config.h:common/config.h.in])
diff --git a/gprofng/configure.tgt b/gprofng/configure.tgt
new file mode 100644
index 00000000000..5bccdc94998
--- /dev/null
+++ b/gprofng/configure.tgt
@@ -0,0 +1,42 @@
+# bfd target specific configuration file. This is a -*- sh -*- file.
+#
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+#
+
+# This is invoked by configure. Putting it in a separate shell file
+# lets us skip running autoconf when modifying target specific
+# information.
+
+# Input shell variables:
+# targ a configuration target name, such as i686-pc-linux-gnu.
+
+# Output shell variables:
+# cpu_type canonical gas cpu type; identifies the gas/config/tc-* files
+
+cpu_type=
+
+eval $(echo ${targ} | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/')
+
+# Check for architecture variants. Set cpu_type and, optionally,
+# endian and arch.
+# Note: This table is alpha-sorted, please try to keep it that way.
+case ${cpu} in
+ aarch64*) cpu_type=aarch64 ;;
+ mips*) cpu_type=mips ;;
+ sparc*) cpu_type=sparc ;;
+ *) cpu_type=${cpu} ;;
+esac
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 5677ecd8865..41b85c7ce32 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -664,3 +664,6 @@ xztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
ztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
include $(top_srcdir)/../multilib.am
+
+# Reconfigure if configure.tgt changes.
+CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.tgt
\ No newline at end of file
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 1d7aedc74b1..4fcc83ddf33 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -576,6 +576,16 @@ else
multilib_arg=
fi
+targ=${target}
+. ${srcdir}/configure.tgt
+
+# Target-specific definitions
+case ${cpu_type} in
+ aarch64*) AC_DEFINE(TC_AARCH64, 1, [Compile for AArch64 targets]) ;;
+ sparc*) AC_DEFINE(TC_SPARC, 1, [Compile for Sparc targets]) ;;
+ mips*) AC_DEFINE(TC_MIPS, 1, [Compile for MIPS targets]) ;;
+esac
+
AC_CONFIG_FILES(Makefile backtrace-supported.h)
AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
diff --git a/libbacktrace/configure.tgt b/libbacktrace/configure.tgt
new file mode 100644
index 00000000000..5bccdc94998
--- /dev/null
+++ b/libbacktrace/configure.tgt
@@ -0,0 +1,42 @@
+# bfd target specific configuration file. This is a -*- sh -*- file.
+#
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+#
+
+# This is invoked by configure. Putting it in a separate shell file
+# lets us skip running autoconf when modifying target specific
+# information.
+
+# Input shell variables:
+# targ a configuration target name, such as i686-pc-linux-gnu.
+
+# Output shell variables:
+# cpu_type canonical gas cpu type; identifies the gas/config/tc-* files
+
+cpu_type=
+
+eval $(echo ${targ} | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/')
+
+# Check for architecture variants. Set cpu_type and, optionally,
+# endian and arch.
+# Note: This table is alpha-sorted, please try to keep it that way.
+case ${cpu} in
+ aarch64*) cpu_type=aarch64 ;;
+ mips*) cpu_type=mips ;;
+ sparc*) cpu_type=sparc ;;
+ *) cpu_type=${cpu} ;;
+esac
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index b77a41c781c..f8c2082c135 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -500,6 +500,9 @@ stamp-h: $(srcdir)/config.in config.status Makefile
config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck
+CONFIG_STATUS_DEPENDENCIES = \
+ $(srcdir)/configure.tgt
+
AUTOCONF = autoconf
ACLOCAL = aclocal
ACLOCAL_AMFLAGS = -I ../config -I ..
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index c27e08e1428..8ce302b08e1 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -812,6 +812,16 @@ AC_SUBST(datarootdir)
AC_SUBST(docdir)
AC_SUBST(htmldir)
+targ=${target}
+. ${srcdir}/configure.tgt
+
+# Target-specific definitions
+case ${cpu_type} in
+ aarch64*) AC_DEFINE(TC_AARCH64, 1, [Compile for AArch64 targets]) ;;
+ sparc*) AC_DEFINE(TC_SPARC, 1, [Compile for Sparc targets]) ;;
+ mips*) AC_DEFINE(TC_MIPS, 1, [Compile for MIPS targets]) ;;
+esac
+
# We need multilib support, but only if configuring for the target.
AC_CONFIG_FILES([Makefile testsuite/Makefile])
AC_CONFIG_COMMANDS([default],
diff --git a/libiberty/configure.tgt b/libiberty/configure.tgt
new file mode 100644
index 00000000000..5bccdc94998
--- /dev/null
+++ b/libiberty/configure.tgt
@@ -0,0 +1,42 @@
+# bfd target specific configuration file. This is a -*- sh -*- file.
+#
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+#
+
+# This is invoked by configure. Putting it in a separate shell file
+# lets us skip running autoconf when modifying target specific
+# information.
+
+# Input shell variables:
+# targ a configuration target name, such as i686-pc-linux-gnu.
+
+# Output shell variables:
+# cpu_type canonical gas cpu type; identifies the gas/config/tc-* files
+
+cpu_type=
+
+eval $(echo ${targ} | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/')
+
+# Check for architecture variants. Set cpu_type and, optionally,
+# endian and arch.
+# Note: This table is alpha-sorted, please try to keep it that way.
+case ${cpu} in
+ aarch64*) cpu_type=aarch64 ;;
+ mips*) cpu_type=mips ;;
+ sparc*) cpu_type=sparc ;;
+ *) cpu_type=${cpu} ;;
+esac
--
2.47.1
More information about the Binutils
mailing list