On May 19, 2020, Alexandre Oliva <[email protected]> wrote:
> - fix a build problem when targeting platforms with an executable suffix
aux and dump revamp: fix target exec suffix handling
HAVE_TARGET_EXECUTABLE_SUFFIX is defined only in gcc.c, and in a way
that requires testing whether it's defined, rather than for nonzero.
Fixed the new use in gcc.c, copied the fix and the definition to
lto-wrapper.c.
for gcc/ChangeLog
* lto-wrapper.c (HAVE_TARGET_EXECUTABLE_SUFFIX): Define if...
(TARGET_EXECUTABLE_SUFFIX): ... is defined; define this to the
empty string otherwise.
(run_gcc): Test for HAVE_TARGET_EXECUTABLE_SUFFIX with defined.
* gcc.c (process_command): Likewise.
---
gcc/gcc.c | 2 +-
gcc/lto-wrapper.c | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 1e4ac9d..8c851d7 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4966,7 +4966,7 @@ process_command (unsigned int decoded_options_count,
: ((temp = strrchr (obase + 1, '.'))
&& (xlen = strlen (temp))
&& (strcmp (temp, ".exe") == 0
-#if HAVE_TARGET_EXECUTABLE_SUFFIX
+#if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
|| strcmp (temp, TARGET_EXECUTABLE_SUFFIX) == 0
#endif
|| strcmp (obase, "a.out") == 0)))
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 026c419..d565b08 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -53,6 +53,13 @@ along with GCC; see the file COPYING3. If not see
driver to lto-wrapper. */
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
+/* By default there is no special suffix for target executables. */
+#ifdef TARGET_EXECUTABLE_SUFFIX
+#define HAVE_TARGET_EXECUTABLE_SUFFIX
+#else
+#define TARGET_EXECUTABLE_SUFFIX ""
+#endif
+
enum lto_mode_d {
LTO_MODE_NONE, /* Not doing LTO. */
LTO_MODE_LTO, /* Normal LTO. */
@@ -1509,7 +1516,7 @@ run_gcc (unsigned argc, char *argv[])
if ((temp = strrchr (obase + 1, '.'))
&& (xlen = strlen (temp))
&& (strcmp (temp, ".exe") == 0
-#if HAVE_TARGET_EXECUTABLE_SUFFIX
+#if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
|| strcmp (temp, TARGET_EXECUTABLE_SUFFIX) == 0
#endif
|| strcmp (obase, "a.out") == 0))
--
Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo/
Free Software Evangelist Stallman was right, but he's left :(
GNU Toolchain Engineer Live long and free, and prosper ethically