Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions mingw-w64-gcc/0012-Escape-special-characters-in-spec-functions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
From 3b1c3f7d8ba4d8ee4690e8e109ee3bdbf0cef9cb Mon Sep 17 00:00:00 2001
From: Wang Jinghao <zheng.xianyuwang@gmail.com>
Date: Wed, 27 May 2026 23:00:33 +0800
Subject: [PATCH] driver: Escape special characters in spec functions [PR90692]

do_spec_1() treats whitespace characters (' ' and '\t') as argument
terminators, causing splitting to occur. Therefore, we need to wrap
all spec functions whose return values should not be split
(e.g. file path) with the quote_spec() function. For example,
"dir with space/something.o" will be split into
"dir" "with" and "space/something.o".

pass_through_libs_spec_func() is somewhat special because the
multiple arguments it returns are expected to be split by ' ', but
each individual argument should not be split. Therefore, each
individual argument must be quoted first and then concatenated.

PR driver/90692

gcc/ChangeLog:

* gcc.cc (if_exists_spec_function): Escape special characters.
(if_exists_else_spec_function): Likewise.
(if_exists_then_else_spec_function): Likewise.
(version_compare_spec_function): Likewise.
(find_file_spec_function): Likewise.
(find_plugindir_spec_function): Likewise.
(pass_through_libs_spec_func): Likewise.
(find_fortran_preinclude_file): Likewise.

Signed-off-by: Wang Jinghao <zheng.xianyuwang@gmail.com>
---
gcc/gcc.cc | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 43b0158ee02..82f1e23b500 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -10532,7 +10532,7 @@ if_exists_spec_function (int argc, const char **argv)
{
/* Must have only one argument. */
if (argc == 1 && IS_ABSOLUTE_PATH (argv[0]) && ! access (argv[0], R_OK))
- return argv[0];
+ return quote_spec (xstrdup (argv[0]));

return NULL;
}
@@ -10550,9 +10550,9 @@ if_exists_else_spec_function (int argc, const char **argv)
return NULL;

if (IS_ABSOLUTE_PATH (argv[0]) && ! access (argv[0], R_OK))
- return argv[0];
+ return quote_spec (xstrdup (argv[0]));

- return argv[1];
+ return quote_spec (xstrdup (argv[1]));
}

/* if-exists-then-else built-in spec function.
@@ -10570,10 +10570,10 @@ if_exists_then_else_spec_function (int argc, const char **argv)
return NULL;

if (IS_ABSOLUTE_PATH (argv[0]) && ! access (argv[0], R_OK))
- return argv[1];
+ return quote_spec (xstrdup (argv[1]));

if (argc == 3)
- return argv[2];
+ return quote_spec (xstrdup (argv[2]));

return NULL;
}
@@ -10771,7 +10771,7 @@ version_compare_spec_function (int argc, const char **argv)
if (! result)
return NULL;

- return argv[nargs + 2];
+ return quote_spec (xstrdup (argv[nargs + 2]));
}

/* %:include builtin spec function. This differs from %include in that it
@@ -10805,7 +10805,7 @@ find_file_spec_function (int argc, const char **argv)
abort ();

file = find_file (argv[0]);
- return file;
+ return quote_spec (xstrdup (file));
}


@@ -10815,13 +10815,13 @@ find_file_spec_function (int argc, const char **argv)
static const char *
find_plugindir_spec_function (int argc, const char **argv ATTRIBUTE_UNUSED)
{
- const char *option;
+ char *option;

if (argc != 0)
abort ();

option = concat ("-iplugindir=", find_file ("plugin"), NULL);
- return option;
+ return quote_spec (option);
}


@@ -10999,13 +10999,17 @@ pass_through_libs_spec_func (int argc, const char **argv)
break;
else if (!*lopt)
lopt = argv[n];
- prepended = concat (prepended, "-plugin-opt=-pass-through=-l",
- lopt, " ", NULL);
+ char *arg = concat ("-plugin-opt=-pass-through=-l", lopt, NULL);
+ arg = quote_spec (arg);
+ prepended = concat (prepended, arg, " ", NULL);
+ free (arg);
}
else if (!strcmp (".a", argv[n] + strlen (argv[n]) - 2))
{
- prepended = concat (prepended, "-plugin-opt=-pass-through=",
- argv[n], " ", NULL);
+ char *arg = concat ("-plugin-opt=-pass-through=", argv[n], NULL);
+ arg = quote_spec (arg);
+ prepended = concat (prepended, arg, " ", NULL);
+ free (arg);
}
if (prepended != old)
free (old);
@@ -11235,6 +11239,8 @@ find_fortran_preinclude_file (int argc, const char **argv)
}

path_prefix_reset (&prefixes);
+ if (result)
+ result = quote_spec (result);
return result;
}

--
2.52.0

This file was deleted.

8 changes: 4 additions & 4 deletions mingw-w64-gcc/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ else
_url=https://gcc.gnu.org/pub/gcc/snapshots/${_version}-${_snapshot}
fi
_libdir=lib/gcc/${CHOST}/${pkgver}
pkgrel=5
pkgrel=6
pkgdesc="GCC for the MinGW-w64"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
Expand Down Expand Up @@ -89,7 +89,7 @@ source=(${_url}/${_sourcedir}.tar.xz{,.sig}
0007-Build-EXTRA_GNATTOOLS-for-Ada.patch
0008-Prettify-linking-no-undefined.patch
0011-Enable-shared-gnat-implib.patch
0012-Handle-spaces-in-path-for-default-manifest.patch
0012-Escape-special-characters-in-spec-functions.patch
0014-gcc-9-branch-clone_function_name_1-Retain-any-stdcall-suffix.patch
0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch
0022-unset-native-system-header-dir.patch
Expand All @@ -105,7 +105,7 @@ sha256sums=('50efb4d94c3397aff3b0d61a5abd748b4dd31d9d3f2ab7be05b171d36a510f79'
'90d5cb570083f9dea4ac0f0f87e3e8d2230f5052e6f9b946061a20a224a9d195'
'8d2d53ae26b777d90189240494de1b895c5efa1ebdcdfbf5774f29fc742499d9'
'5ef4148acc4a2b7ed648d4fe75fab5545e84b4b93a12d6ba4e4ea6061dd635fa'
'e98805ead7d78ee2a92f237894c4b2b7ddc1688e1b517d8c04f28d440202e40f'
'd1bf7b3ffbb221efe5edae7e9cbf1147393b0920eb62d5f379f3dfa53bdd6e38'
'fd9bdecb2bbc4796bbc9f00b708dac42ef9e3464a06d6d27e5475cee117de5be'
'ad1f7b5e7afaaec008b7cbd14feea13a10989fa91bda7003af72d457619bb199'
'd8b9b979dc1742f63d23dfca92bc05944612bd196a31fb882b8a616baba84383'
Expand Down Expand Up @@ -146,7 +146,7 @@ prepare() {
0007-Build-EXTRA_GNATTOOLS-for-Ada.patch \
0008-Prettify-linking-no-undefined.patch \
0011-Enable-shared-gnat-implib.patch \
0012-Handle-spaces-in-path-for-default-manifest.patch \
0012-Escape-special-characters-in-spec-functions.patch \
0014-gcc-9-branch-clone_function_name_1-Retain-any-stdcall-suffix.patch \
0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch \
0022-unset-native-system-header-dir.patch
Expand Down
Loading