Skip to content

Commit 711f0f6

Browse files
committed
a
1 parent de2e002 commit 711f0f6

2 files changed

Lines changed: 144 additions & 0 deletions

File tree

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ if ! [ -f "${gcc_tarball}" ]; then
646646
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0005-libiberty-hide-sys_nsig-from-system-headers-in-strsignal.patch"
647647
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0006-gcc-drop-unused-sys-dir.h-include-from-protoize.patch"
648648
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0007-gcc-also-set-POSIX-xm_defines-for-Android-hosts.patch"
649+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0008-gcc-teach-the-driver-and-cpp-to-recognize-MF-MT-MQ-MP.patch"
649650
fi
650651

651652
if (( gcc_major == 11 )); then
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
From 8c0c2e9d69361e9f7858942fb6233516ed494962 Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sun, 9 Aug 2026 19:52:03 +0000
4+
Subject: [PATCH] gcc: teach the driver and cpp to recognize -MF/-MT/-MQ/-MP
5+
6+
---
7+
gcc/cccp.c | 21 +++++++++++++++++++++
8+
gcc/cppinit.c | 18 ++++++++++++++++++
9+
gcc/gcc.c | 15 ++++++++-------
10+
3 files changed, 47 insertions(+), 7 deletions(-)
11+
12+
diff --git a/gcc/cccp.c b/gcc/cccp.c
13+
index 843866c..5061b46 100644
14+
--- a/gcc/cccp.c
15+
+++ b/gcc/cccp.c
16+
@@ -1557,6 +1557,27 @@ main (argc, argv)
17+
print_deps_missing_files = 1;
18+
break;
19+
}
20+
+ if (!strcmp (argv[i], "-MP"))
21+
+ {
22+
+ break;
23+
+ }
24+
+ if (!strcmp (argv[i], "-MF"))
25+
+ {
26+
+ if (i + 1 == argc)
27+
+ fatal ("Filename missing after %s option", argv[i]);
28+
+ i++;
29+
+ deps_file = argv[i];
30+
+ deps_mode = "w";
31+
+ break;
32+
+ }
33+
+ if (!strcmp (argv[i], "-MT") || !strcmp (argv[i], "-MQ"))
34+
+ {
35+
+ if (i + 1 == argc)
36+
+ fatal ("Filename missing after %s option", argv[i]);
37+
+ i++;
38+
+ deps_target = argv[i];
39+
+ break;
40+
+ }
41+
if (!strcmp (argv[i], "-M"))
42+
print_deps = 2;
43+
else if (!strcmp (argv[i], "-MM"))
44+
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
45+
index 453cc58..5fa9fd5 100644
46+
--- a/gcc/cppinit.c
47+
+++ b/gcc/cppinit.c
48+
@@ -1457,6 +1457,24 @@ cpp_handle_option (pfile, argc, argv)
49+
opts->print_deps_missing_files = 1;
50+
break;
51+
}
52+
+ if (!strcmp (argv[i], "-MP"))
53+
+ {
54+
+ break;
55+
+ }
56+
+ if (!strcmp (argv[i], "-MF"))
57+
+ {
58+
+ if (i+1 == argc)
59+
+ goto missing_filename;
60+
+ opts->deps_file = argv[++i];
61+
+ break;
62+
+ }
63+
+ if (!strcmp (argv[i], "-MT") || !strcmp (argv[i], "-MQ"))
64+
+ {
65+
+ if (i+1 == argc)
66+
+ goto missing_filename;
67+
+ opts->deps_target = argv[++i];
68+
+ break;
69+
+ }
70+
if (!strcmp (argv[i], "-M"))
71+
opts->print_deps = 2;
72+
else if (!strcmp (argv[i], "-MM"))
73+
diff --git a/gcc/gcc.c b/gcc/gcc.c
74+
index 5c9e73d..8f85efa 100644
75+
--- a/gcc/gcc.c
76+
+++ b/gcc/gcc.c
77+
@@ -538,7 +538,8 @@ static struct user_specs *user_specs_head, *user_specs_tail;
78+
|| !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
79+
|| !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
80+
|| !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
81+
- || !strcmp (STR, "isystem") || !strcmp (STR, "specs"))
82+
+ || !strcmp (STR, "isystem") || !strcmp (STR, "specs") \
83+
+ || !strcmp (STR, "MF") || !strcmp (STR, "MT") || !strcmp (STR, "MQ"))
84+
85+
#ifndef WORD_SWITCH_TAKES_ARG
86+
#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
87+
@@ -605,7 +606,7 @@ static struct compiler default_compilers[] =
88+
"%{E|M|MM:cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\
89+
%{C} %{v} %{A*} %{I*} %{P} %{$} %I\
90+
%{C:%{!E:%eGNU C does not support -C without using -E}}\
91+
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
92+
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*}\
93+
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
94+
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
95+
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
96+
@@ -619,7 +620,7 @@ static struct compiler default_compilers[] =
97+
%{!E:%{!M:%{!MM:cc1 %i %1 \
98+
%{std*} %{nostdinc*} %{A*} %{I*} %I\
99+
%{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
100+
- %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
101+
+ %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*}\
102+
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
103+
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
104+
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
105+
@@ -641,7 +642,7 @@ static struct compiler default_compilers[] =
106+
"cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\
107+
%{C} %{v} %{A*} %{I*} %{P} %{$} %I\
108+
%{C:%{!E:%eGNU C does not support -C without using -E}}\
109+
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
110+
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*}\
111+
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
112+
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
113+
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
114+
@@ -669,7 +670,7 @@ static struct compiler default_compilers[] =
115+
{"%{E:cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\
116+
%{C} %{v} %{A*} %{I*} %{P} %{$} %I\
117+
%{C:%{!E:%eGNU C does not support -C without using -E}}\
118+
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
119+
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*}\
120+
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
121+
%{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
122+
%{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
123+
@@ -686,7 +687,7 @@ static struct compiler default_compilers[] =
124+
{"%{!E:%eCompilation of header file requested} \
125+
cpp0 %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %{$} %I\
126+
%{C:%{!E:%eGNU C does not support -C without using -E}}\
127+
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
128+
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*}\
129+
%{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
130+
%{std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
131+
%{!undef:%{!std=*:%p}%{std=gnu*:%p} %P} %{trigraphs}\
132+
@@ -717,7 +718,7 @@ static struct compiler default_compilers[] =
133+
{"@assembler-with-cpp",
134+
{"cpp0 -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %{$} %I\
135+
%{C:%{!E:%eGNU C does not support -C without using -E}}\
136+
- %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\
137+
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{MP} %{MF*} %{MQ*} %{MT*} %{trigraphs}\
138+
-$ %{!undef:%p %P} -D__ASSEMBLER__ \
139+
%c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
140+
%{ffast-math:-D__FAST_MATH__}\
141+
--
142+
2.54.0
143+

0 commit comments

Comments
 (0)