diff options
50 files changed, 534 insertions, 5665 deletions
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc index d518bdd2ad..eaa8fed9b1 100644 --- a/meta/conf/distro/include/maintainers.inc +++ b/meta/conf/distro/include/maintainers.inc | |||
@@ -190,7 +190,7 @@ RECIPE_MAINTAINER:pn-gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Khem Raj <r | |||
190 | RECIPE_MAINTAINER:pn-gcc-crosssdk-${SDK_SYS} = "Khem Raj <raj.khem@gmail.com>" | 190 | RECIPE_MAINTAINER:pn-gcc-crosssdk-${SDK_SYS} = "Khem Raj <raj.khem@gmail.com>" |
191 | RECIPE_MAINTAINER:pn-gcc-runtime = "Khem Raj <raj.khem@gmail.com>" | 191 | RECIPE_MAINTAINER:pn-gcc-runtime = "Khem Raj <raj.khem@gmail.com>" |
192 | RECIPE_MAINTAINER:pn-gcc-sanitizers = "Khem Raj <raj.khem@gmail.com>" | 192 | RECIPE_MAINTAINER:pn-gcc-sanitizers = "Khem Raj <raj.khem@gmail.com>" |
193 | RECIPE_MAINTAINER:pn-gcc-source-11.3.0 = "Khem Raj <raj.khem@gmail.com>" | 193 | RECIPE_MAINTAINER:pn-gcc-source-12.1.0 = "Khem Raj <raj.khem@gmail.com>" |
194 | RECIPE_MAINTAINER:pn-gconf = "Ross Burton <ross.burton@arm.com>" | 194 | RECIPE_MAINTAINER:pn-gconf = "Ross Burton <ross.burton@arm.com>" |
195 | RECIPE_MAINTAINER:pn-gcr = "Alexander Kanavin <alex.kanavin@gmail.com>" | 195 | RECIPE_MAINTAINER:pn-gcr = "Alexander Kanavin <alex.kanavin@gmail.com>" |
196 | RECIPE_MAINTAINER:pn-gdb = "Khem Raj <raj.khem@gmail.com>" | 196 | RECIPE_MAINTAINER:pn-gdb = "Khem Raj <raj.khem@gmail.com>" |
diff --git a/meta/conf/distro/include/tcmode-default.inc b/meta/conf/distro/include/tcmode-default.inc index e8ea7cc546..9660f2804a 100644 --- a/meta/conf/distro/include/tcmode-default.inc +++ b/meta/conf/distro/include/tcmode-default.inc | |||
@@ -16,7 +16,7 @@ PREFERRED_PROVIDER_virtual/${SDK_PREFIX}compilerlibs = "nativesdk-gcc-runtime" | |||
16 | # Default libc config | 16 | # Default libc config |
17 | PREFERRED_PROVIDER_virtual/gettext ??= "gettext" | 17 | PREFERRED_PROVIDER_virtual/gettext ??= "gettext" |
18 | 18 | ||
19 | GCCVERSION ?= "11.%" | 19 | GCCVERSION ?= "12.%" |
20 | SDKGCCVERSION ?= "${GCCVERSION}" | 20 | SDKGCCVERSION ?= "${GCCVERSION}" |
21 | BINUVERSION ?= "2.38%" | 21 | BINUVERSION ?= "2.38%" |
22 | GDBVERSION ?= "11.%" | 22 | GDBVERSION ?= "11.%" |
diff --git a/meta/recipes-devtools/gcc/gcc-11.3.inc b/meta/recipes-devtools/gcc/gcc-12.1.inc index b1ef9d25af..c8c4ae93e1 100644 --- a/meta/recipes-devtools/gcc/gcc-11.3.inc +++ b/meta/recipes-devtools/gcc/gcc-12.1.inc | |||
@@ -2,11 +2,11 @@ require gcc-common.inc | |||
2 | 2 | ||
3 | # Third digit in PV should be incremented after a minor release | 3 | # Third digit in PV should be incremented after a minor release |
4 | 4 | ||
5 | PV = "11.3.0" | 5 | PV = "12.1.0" |
6 | 6 | ||
7 | # BINV should be incremented to a revision after a minor gcc release | 7 | # BINV should be incremented to a revision after a minor gcc release |
8 | 8 | ||
9 | BINV = "11.3.0" | 9 | BINV = "12.1.0" |
10 | 10 | ||
11 | FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:" | 11 | FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:" |
12 | 12 | ||
@@ -22,57 +22,52 @@ LIC_FILES_CHKSUM = "\ | |||
22 | file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \ | 22 | file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \ |
23 | file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \ | 23 | file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \ |
24 | " | 24 | " |
25 | 25 | # from git | |
26 | #RELEASE ?= "5b2ac9b40c325e9209c0bd55955db84aad4a0cc5" | 26 | #RELEASE ?= "7092b7aea122a91824d048aeb23834cf1d19b1a1" |
27 | #BASEURI ?= "https://github.com/gcc-mirror/gcc/archive/${RELEASE}.zip;downloadfilename=gcc-${PV}-${RELEASE}.zip" | 27 | #BASEURI ?= "https://repo.or.cz/official-gcc.git/snapshot/${RELEASE}.tar.gz;downloadfilename=gcc-${PV}-${RELEASE}.tar.gz" |
28 | 28 | #SOURCEDIR ?= "official-gcc-${@'${RELEASE}'[0:7]}" | |
29 | BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.xz \ | 29 | |
30 | " | 30 | # from snapshot |
31 | SRC_URI = "\ | 31 | #RELEASE ?= "12.1.0-RC-20220429" |
32 | ${BASEURI} \ | 32 | #SOURCEDIR ?= "gcc-${RELEASE}" |
33 | #BASEURI ?= "https://gcc.gnu.org/pub/gcc/snapshots/${RELEASE}/gcc-${RELEASE}.tar.xz" | ||
34 | |||
35 | # official release | ||
36 | RELEASE ?= "${PV}" | ||
37 | BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.xz" | ||
38 | SOURCEDIR ?= "gcc-${PV}" | ||
39 | |||
40 | SRC_URI = "${BASEURI} \ | ||
33 | file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ | 41 | file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \ |
34 | file://0002-gcc-poison-system-directories.patch \ | 42 | file://0002-gcc-poison-system-directories.patch \ |
35 | file://0003-64-bit-multilib-hack.patch \ | 43 | file://0003-64-bit-multilib-hack.patch \ |
36 | file://0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ | 44 | file://0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch \ |
37 | file://0005-cpp-honor-sysroot.patch \ | 45 | file://0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \ |
38 | file://0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ | 46 | file://0006-cpp-honor-sysroot.patch \ |
39 | file://0007-gcc-Fix-argument-list-too-long-error.patch \ | 47 | file://0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \ |
40 | file://0008-libtool.patch \ | 48 | file://0008-libtool.patch \ |
41 | file://0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \ | 49 | file://0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \ |
42 | file://0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch \ | 50 | file://0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch \ |
43 | file://0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \ | 51 | file://0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \ |
44 | file://0012-Ensure-target-gcc-headers-can-be-included.patch \ | 52 | file://0012-export-CPP.patch \ |
45 | file://0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch \ | 53 | file://0013-Ensure-target-gcc-headers-can-be-included.patch \ |
46 | file://0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ | 54 | file://0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch \ |
47 | file://0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch \ | 55 | file://0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ |
48 | file://0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch \ | 56 | file://0016-handle-sysroot-support-for-nativesdk-gcc.patch \ |
49 | file://0017-handle-sysroot-support-for-nativesdk-gcc.patch \ | 57 | file://0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ |
50 | file://0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch \ | 58 | file://0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ |
51 | file://0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch \ | 59 | file://0019-Re-introduce-spe-commandline-options.patch \ |
52 | file://0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \ | 60 | file://0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \ |
53 | file://0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \ | 61 | file://0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \ |
54 | file://0022-sync-gcc-stddef.h-with-musl.patch \ | 62 | file://0022-mingw32-Enable-operation_not_supported.patch \ |
55 | file://0023-Re-introduce-spe-commandline-options.patch \ | 63 | file://0023-libatomic-Do-not-enforce-march-on-aarch64.patch \ |
56 | file://0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \ | 64 | file://0024-Fix-install-path-of-linux64.h.patch \ |
57 | file://0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \ | 65 | file://0025-Move-sched.h-include-ahead-of-user-headers.patch \ |
58 | file://0026-mingw32-Enable-operation_not_supported.patch \ | ||
59 | file://0027-libatomic-Do-not-enforce-march-on-aarch64.patch \ | ||
60 | file://0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch \ | ||
61 | file://0029-Fix-install-path-of-linux64.h.patch \ | ||
62 | \ | ||
63 | file://0001-CVE-2021-42574.patch \ | ||
64 | file://0002-CVE-2021-42574.patch \ | ||
65 | file://0003-CVE-2021-42574.patch \ | ||
66 | file://0004-CVE-2021-42574.patch \ | ||
67 | file://0001-CVE-2021-46195.patch \ | ||
68 | " | 66 | " |
69 | SRC_URI[sha256sum] = "b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39" | 67 | SRC_URI[sha256sum] = "62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b" |
70 | |||
71 | S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}" | ||
72 | 68 | ||
73 | # For dev release snapshotting | 69 | S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}" |
74 | #S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}" | 70 | B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" |
75 | #B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" | ||
76 | 71 | ||
77 | # Language Overrides | 72 | # Language Overrides |
78 | FORTRAN = "" | 73 | FORTRAN = "" |
diff --git a/meta/recipes-devtools/gcc/gcc-cross-canadian_11.3.bb b/meta/recipes-devtools/gcc/gcc-cross-canadian_12.1.bb index bf53c5cd78..bf53c5cd78 100644 --- a/meta/recipes-devtools/gcc/gcc-cross-canadian_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-cross-canadian_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc-cross_11.3.bb b/meta/recipes-devtools/gcc/gcc-cross_12.1.bb index b43cca0c52..b43cca0c52 100644 --- a/meta/recipes-devtools/gcc/gcc-cross_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-cross_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc-crosssdk_11.3.bb b/meta/recipes-devtools/gcc/gcc-crosssdk_12.1.bb index 40a6c4feff..40a6c4feff 100644 --- a/meta/recipes-devtools/gcc/gcc-crosssdk_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-crosssdk_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc index e9f2cf16e8..c39a0caf8a 100644 --- a/meta/recipes-devtools/gcc/gcc-runtime.inc +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc | |||
@@ -2,7 +2,7 @@ require gcc-configure-common.inc | |||
2 | 2 | ||
3 | SUMMARY = "Runtime libraries from GCC" | 3 | SUMMARY = "Runtime libraries from GCC" |
4 | 4 | ||
5 | # Over-ride the LICENSE set by gcc-${PV}.inc to remove "& GPL-3.0-only" | 5 | # Over-ride the LICENSE set by gcc-${PV}.inc to remove "& GPLv3" |
6 | # All gcc-runtime packages are now covered by the runtime exception. | 6 | # All gcc-runtime packages are now covered by the runtime exception. |
7 | LICENSE = "GPL-3.0-with-GCC-exception" | 7 | LICENSE = "GPL-3.0-with-GCC-exception" |
8 | 8 | ||
diff --git a/meta/recipes-devtools/gcc/gcc-runtime_11.3.bb b/meta/recipes-devtools/gcc/gcc-runtime_12.1.bb index dd430b57eb..dd430b57eb 100644 --- a/meta/recipes-devtools/gcc/gcc-runtime_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-runtime_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers_11.3.bb b/meta/recipes-devtools/gcc/gcc-sanitizers_12.1.bb index 8bda2ccad6..8bda2ccad6 100644 --- a/meta/recipes-devtools/gcc/gcc-sanitizers_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-sanitizers_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc-source_11.3.bb b/meta/recipes-devtools/gcc/gcc-source_12.1.bb index b890fa33ea..b890fa33ea 100644 --- a/meta/recipes-devtools/gcc/gcc-source_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc-source_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-42574.patch b/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-42574.patch deleted file mode 100644 index 4d680ccc8f..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-42574.patch +++ /dev/null | |||
@@ -1,2282 +0,0 @@ | |||
1 | From bd5e882cf6e0def3dd1bc106075d59a303fe0d1e Mon Sep 17 00:00:00 2001 | ||
2 | From: David Malcolm <dmalcolm@redhat.com> | ||
3 | Date: Mon, 18 Oct 2021 18:55:31 -0400 | ||
4 | Subject: [PATCH] diagnostics: escape non-ASCII source bytes for certain | ||
5 | diagnostics | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=utf8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | This patch adds support to GCC's diagnostic subsystem for escaping certain | ||
11 | bytes and Unicode characters when quoting source code. | ||
12 | |||
13 | Specifically, this patch adds a new flag rich_location::m_escape_on_output | ||
14 | which is a hint from a diagnostic that non-ASCII bytes in the pertinent | ||
15 | lines of the user's source code should be escaped when printed. | ||
16 | |||
17 | The patch sets this for the following diagnostics: | ||
18 | - when complaining about stray bytes in the program (when these | ||
19 | are non-printable) | ||
20 | - when complaining about "null character(s) ignored"); | ||
21 | - for -Wnormalized= (and generate source ranges for such warnings) | ||
22 | |||
23 | The escaping is controlled by a new option: | ||
24 | -fdiagnostics-escape-format=[unicode|bytes] | ||
25 | |||
26 | For example, consider a diagnostic involing a source line containing the | ||
27 | string "before" followed by the Unicode character U+03C0 ("GREEK SMALL | ||
28 | LETTER PI", with UTF-8 encoding 0xCF 0x80) followed by the byte 0xBF | ||
29 | (a stray UTF-8 trailing byte), followed by the string "after", where the | ||
30 | diagnostic highlights the U+03C0 character. | ||
31 | |||
32 | By default, this line will be printed verbatim to the user when | ||
33 | reporting a diagnostic at it, as: | ||
34 | |||
35 | beforeÏXafter | ||
36 | ^ | ||
37 | |||
38 | (using X for the stray byte to avoid putting invalid UTF-8 in this | ||
39 | commit message) | ||
40 | |||
41 | If the diagnostic sets the "escape" flag, it will be printed as: | ||
42 | |||
43 | before<U+03C0><BF>after | ||
44 | ^~~~~~~~ | ||
45 | |||
46 | with -fdiagnostics-escape-format=unicode (the default), or as: | ||
47 | |||
48 | before<CF><80><BF>after | ||
49 | ^~~~~~~~ | ||
50 | |||
51 | if the user supplies -fdiagnostics-escape-format=bytes. | ||
52 | |||
53 | This only affects how the source is printed; it does not affect | ||
54 | how column numbers that are printed (as per -fdiagnostics-column-unit= | ||
55 | and -fdiagnostics-column-origin=). | ||
56 | |||
57 | gcc/c-family/ChangeLog: | ||
58 | * c-lex.c (c_lex_with_flags): When complaining about non-printable | ||
59 | CPP_OTHER tokens, set the "escape on output" flag. | ||
60 | |||
61 | gcc/ChangeLog: | ||
62 | * common.opt (fdiagnostics-escape-format=): New. | ||
63 | (diagnostics_escape_format): New enum. | ||
64 | (DIAGNOSTICS_ESCAPE_FORMAT_UNICODE): New enum value. | ||
65 | (DIAGNOSTICS_ESCAPE_FORMAT_BYTES): Likewise. | ||
66 | * diagnostic-format-json.cc (json_end_diagnostic): Add | ||
67 | "escape-source" attribute. | ||
68 | * diagnostic-show-locus.c | ||
69 | (exploc_with_display_col::exploc_with_display_col): Replace | ||
70 | "tabstop" param with a cpp_char_column_policy and add an "aspect" | ||
71 | param. Use these to compute m_display_col accordingly. | ||
72 | (struct char_display_policy): New struct. | ||
73 | (layout::m_policy): New field. | ||
74 | (layout::m_escape_on_output): New field. | ||
75 | (def_policy): New function. | ||
76 | (make_range): Update for changes to exploc_with_display_col ctor. | ||
77 | (default_print_decoded_ch): New. | ||
78 | (width_per_escaped_byte): New. | ||
79 | (escape_as_bytes_width): New. | ||
80 | (escape_as_bytes_print): New. | ||
81 | (escape_as_unicode_width): New. | ||
82 | (escape_as_unicode_print): New. | ||
83 | (make_policy): New. | ||
84 | (layout::layout): Initialize new fields. Update m_exploc ctor | ||
85 | call for above change to ctor. | ||
86 | (layout::maybe_add_location_range): Update for changes to | ||
87 | exploc_with_display_col ctor. | ||
88 | (layout::calculate_x_offset_display): Update for change to | ||
89 | cpp_display_width. | ||
90 | (layout::print_source_line): Pass policy | ||
91 | to cpp_display_width_computation. Capture cpp_decoded_char when | ||
92 | calling process_next_codepoint. Move printing of source code to | ||
93 | m_policy.m_print_cb. | ||
94 | (line_label::line_label): Pass in policy rather than context. | ||
95 | (layout::print_any_labels): Update for change to line_label ctor. | ||
96 | (get_affected_range): Pass in policy rather than context, updating | ||
97 | calls to location_compute_display_column accordingly. | ||
98 | (get_printed_columns): Likewise, also for cpp_display_width. | ||
99 | (correction::correction): Pass in policy rather than tabstop. | ||
100 | (correction::compute_display_cols): Pass m_policy rather than | ||
101 | m_tabstop to cpp_display_width. | ||
102 | (correction::m_tabstop): Replace with... | ||
103 | (correction::m_policy): ...this. | ||
104 | (line_corrections::line_corrections): Pass in policy rather than | ||
105 | context. | ||
106 | (line_corrections::m_context): Replace with... | ||
107 | (line_corrections::m_policy): ...this. | ||
108 | (line_corrections::add_hint): Update to use m_policy rather than | ||
109 | m_context. | ||
110 | (line_corrections::add_hint): Likewise. | ||
111 | (layout::print_trailing_fixits): Likewise. | ||
112 | (selftest::test_display_widths): New. | ||
113 | (selftest::test_layout_x_offset_display_utf8): Update to use | ||
114 | policy rather than tabstop. | ||
115 | (selftest::test_one_liner_labels_utf8): Add test of escaping | ||
116 | source lines. | ||
117 | (selftest::test_diagnostic_show_locus_one_liner_utf8): Update to | ||
118 | use policy rather than tabstop. | ||
119 | (selftest::test_overlapped_fixit_printing): Likewise. | ||
120 | (selftest::test_overlapped_fixit_printing_utf8): Likewise. | ||
121 | (selftest::test_overlapped_fixit_printing_2): Likewise. | ||
122 | (selftest::test_tab_expansion): Likewise. | ||
123 | (selftest::test_escaping_bytes_1): New. | ||
124 | (selftest::test_escaping_bytes_2): New. | ||
125 | (selftest::diagnostic_show_locus_c_tests): Call the new tests. | ||
126 | * diagnostic.c (diagnostic_initialize): Initialize | ||
127 | context->escape_format. | ||
128 | (convert_column_unit): Update to use default character width policy. | ||
129 | (selftest::test_diagnostic_get_location_text): Likewise. | ||
130 | * diagnostic.h (enum diagnostics_escape_format): New enum. | ||
131 | (diagnostic_context::escape_format): New field. | ||
132 | * doc/invoke.texi (-fdiagnostics-escape-format=): New option. | ||
133 | (-fdiagnostics-format=): Add "escape-source" attribute to examples | ||
134 | of JSON output, and document it. | ||
135 | * input.c (location_compute_display_column): Pass in "policy" | ||
136 | rather than "tabstop", passing to | ||
137 | cpp_byte_column_to_display_column. | ||
138 | (selftest::test_cpp_utf8): Update to use cpp_char_column_policy. | ||
139 | * input.h (class cpp_char_column_policy): New forward decl. | ||
140 | (location_compute_display_column): Pass in "policy" rather than | ||
141 | "tabstop". | ||
142 | * opts.c (common_handle_option): Handle | ||
143 | OPT_fdiagnostics_escape_format_. | ||
144 | * selftest.c (temp_source_file::temp_source_file): New ctor | ||
145 | overload taking a size_t. | ||
146 | * selftest.h (temp_source_file::temp_source_file): Likewise. | ||
147 | |||
148 | gcc/testsuite/ChangeLog: | ||
149 | * c-c++-common/diagnostic-format-json-1.c: Add regexp to consume | ||
150 | "escape-source" attribute. | ||
151 | * c-c++-common/diagnostic-format-json-2.c: Likewise. | ||
152 | * c-c++-common/diagnostic-format-json-3.c: Likewise. | ||
153 | * c-c++-common/diagnostic-format-json-4.c: Likewise, twice. | ||
154 | * c-c++-common/diagnostic-format-json-5.c: Likewise. | ||
155 | * gcc.dg/cpp/warn-normalized-4-bytes.c: New test. | ||
156 | * gcc.dg/cpp/warn-normalized-4-unicode.c: New test. | ||
157 | * gcc.dg/encoding-issues-bytes.c: New test. | ||
158 | * gcc.dg/encoding-issues-unicode.c: New test. | ||
159 | * gfortran.dg/diagnostic-format-json-1.F90: Add regexp to consume | ||
160 | "escape-source" attribute. | ||
161 | * gfortran.dg/diagnostic-format-json-2.F90: Likewise. | ||
162 | * gfortran.dg/diagnostic-format-json-3.F90: Likewise. | ||
163 | |||
164 | libcpp/ChangeLog: | ||
165 | * charset.c (convert_escape): Use encoding_rich_location when | ||
166 | complaining about nonprintable unknown escape sequences. | ||
167 | (cpp_display_width_computation::::cpp_display_width_computation): | ||
168 | Pass in policy rather than tabstop. | ||
169 | (cpp_display_width_computation::process_next_codepoint): Add "out" | ||
170 | param and populate *out if non-NULL. | ||
171 | (cpp_display_width_computation::advance_display_cols): Pass NULL | ||
172 | to process_next_codepoint. | ||
173 | (cpp_byte_column_to_display_column): Pass in policy rather than | ||
174 | tabstop. Pass NULL to process_next_codepoint. | ||
175 | (cpp_display_column_to_byte_column): Pass in policy rather than | ||
176 | tabstop. | ||
177 | * errors.c (cpp_diagnostic_get_current_location): New function, | ||
178 | splitting out the logic from... | ||
179 | (cpp_diagnostic): ...here. | ||
180 | (cpp_warning_at): New function. | ||
181 | (cpp_pedwarning_at): New function. | ||
182 | * include/cpplib.h (cpp_warning_at): New decl for rich_location. | ||
183 | (cpp_pedwarning_at): Likewise. | ||
184 | (struct cpp_decoded_char): New. | ||
185 | (struct cpp_char_column_policy): New. | ||
186 | (cpp_display_width_computation::cpp_display_width_computation): | ||
187 | Replace "tabstop" param with "policy". | ||
188 | (cpp_display_width_computation::process_next_codepoint): Add "out" | ||
189 | param. | ||
190 | (cpp_display_width_computation::m_tabstop): Replace with... | ||
191 | (cpp_display_width_computation::m_policy): ...this. | ||
192 | (cpp_byte_column_to_display_column): Replace "tabstop" param with | ||
193 | "policy". | ||
194 | (cpp_display_width): Likewise. | ||
195 | (cpp_display_column_to_byte_column): Likewise. | ||
196 | * include/line-map.h (rich_location::escape_on_output_p): New. | ||
197 | (rich_location::set_escape_on_output): New. | ||
198 | (rich_location::m_escape_on_output): New. | ||
199 | * internal.h (cpp_diagnostic_get_current_location): New decl. | ||
200 | (class encoding_rich_location): New. | ||
201 | * lex.c (skip_whitespace): Use encoding_rich_location when | ||
202 | complaining about null characters. | ||
203 | (warn_about_normalization): Generate a source range when | ||
204 | complaining about improperly normalized tokens, rather than just a | ||
205 | point, and use encoding_rich_location so that the source code | ||
206 | is escaped on printing. | ||
207 | * line-map.c (rich_location::rich_location): Initialize | ||
208 | m_escape_on_output. | ||
209 | |||
210 | Signed-off-by: David Malcolm <dmalcolm@redhat.com> | ||
211 | |||
212 | CVE: CVE-2021-42574 | ||
213 | Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=bd5e882cf6e0def3dd1bc106075d59a303fe0d1e] | ||
214 | Signed-off-by: Pgowda <pgowda.cve@gmail.com> | ||
215 | |||
216 | --- | ||
217 | gcc/c-family/c-lex.c | 6 +- | ||
218 | gcc/common.opt | 13 + | ||
219 | gcc/diagnostic-format-json.cc | 3 + | ||
220 | gcc/diagnostic-show-locus.c | 580 +++++++++++++++--- | ||
221 | gcc/diagnostic.c | 10 +- | ||
222 | gcc/diagnostic.h | 18 + | ||
223 | gcc/doc/invoke.texi | 43 +- | ||
224 | gcc/input.c | 62 +- | ||
225 | gcc/input.h | 7 +- | ||
226 | gcc/opts.c | 4 + | ||
227 | gcc/selftest.c | 15 + | ||
228 | gcc/selftest.h | 2 + | ||
229 | .../c-c++-common/diagnostic-format-json-1.c | 1 + | ||
230 | .../c-c++-common/diagnostic-format-json-2.c | 1 + | ||
231 | .../c-c++-common/diagnostic-format-json-3.c | 1 + | ||
232 | .../c-c++-common/diagnostic-format-json-4.c | 2 + | ||
233 | .../c-c++-common/diagnostic-format-json-5.c | 1 + | ||
234 | .../gcc.dg/cpp/warn-normalized-4-bytes.c | 21 + | ||
235 | .../gcc.dg/cpp/warn-normalized-4-unicode.c | 19 + | ||
236 | gcc/testsuite/gcc.dg/encoding-issues-bytes.c | Bin 0 -> 595 bytes | ||
237 | .../gcc.dg/encoding-issues-unicode.c | Bin 0 -> 613 bytes | ||
238 | .../gfortran.dg/diagnostic-format-json-1.F90 | 1 + | ||
239 | .../gfortran.dg/diagnostic-format-json-2.F90 | 1 + | ||
240 | .../gfortran.dg/diagnostic-format-json-3.F90 | 1 + | ||
241 | libcpp/charset.c | 63 +- | ||
242 | libcpp/errors.c | 82 ++- | ||
243 | libcpp/include/cpplib.h | 76 ++- | ||
244 | libcpp/include/line-map.h | 13 + | ||
245 | libcpp/internal.h | 23 + | ||
246 | libcpp/lex.c | 38 +- | ||
247 | libcpp/line-map.c | 3 +- | ||
248 | 31 files changed, 942 insertions(+), 168 deletions(-) | ||
249 | create mode 100644 gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c | ||
250 | create mode 100644 gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c | ||
251 | create mode 100644 gcc/testsuite/gcc.dg/encoding-issues-bytes.c | ||
252 | create mode 100644 gcc/testsuite/gcc.dg/encoding-issues-unicode.c | ||
253 | |||
254 | diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c | ||
255 | --- a/gcc/c-family/c-lex.c 2021-07-27 23:55:06.980283060 -0700 | ||
256 | +++ b/gcc/c-family/c-lex.c 2021-12-14 01:16:01.541943272 -0800 | ||
257 | @@ -603,7 +603,11 @@ c_lex_with_flags (tree *value, location_ | ||
258 | else if (ISGRAPH (c)) | ||
259 | error_at (*loc, "stray %qc in program", (int) c); | ||
260 | else | ||
261 | - error_at (*loc, "stray %<\\%o%> in program", (int) c); | ||
262 | + { | ||
263 | + rich_location rich_loc (line_table, *loc); | ||
264 | + rich_loc.set_escape_on_output (true); | ||
265 | + error_at (&rich_loc, "stray %<\\%o%> in program", (int) c); | ||
266 | + } | ||
267 | } | ||
268 | goto retry; | ||
269 | |||
270 | diff --git a/gcc/common.opt b/gcc/common.opt | ||
271 | --- a/gcc/common.opt 2021-12-13 22:08:44.939137107 -0800 | ||
272 | +++ b/gcc/common.opt 2021-12-14 01:16:01.541943272 -0800 | ||
273 | @@ -1348,6 +1348,10 @@ fdiagnostics-format= | ||
274 | Common Joined RejectNegative Enum(diagnostics_output_format) | ||
275 | -fdiagnostics-format=[text|json] Select output format. | ||
276 | |||
277 | +fdiagnostics-escape-format= | ||
278 | +Common Joined RejectNegative Enum(diagnostics_escape_format) | ||
279 | +-fdiagnostics-escape-format=[unicode|bytes] Select how to escape non-printable-ASCII bytes in the source for diagnostics that suggest it. | ||
280 | + | ||
281 | ; Required for these enum values. | ||
282 | SourceInclude | ||
283 | diagnostic.h | ||
284 | @@ -1362,6 +1366,15 @@ EnumValue | ||
285 | Enum(diagnostics_column_unit) String(byte) Value(DIAGNOSTICS_COLUMN_UNIT_BYTE) | ||
286 | |||
287 | Enum | ||
288 | +Name(diagnostics_escape_format) Type(int) | ||
289 | + | ||
290 | +EnumValue | ||
291 | +Enum(diagnostics_escape_format) String(unicode) Value(DIAGNOSTICS_ESCAPE_FORMAT_UNICODE) | ||
292 | + | ||
293 | +EnumValue | ||
294 | +Enum(diagnostics_escape_format) String(bytes) Value(DIAGNOSTICS_ESCAPE_FORMAT_BYTES) | ||
295 | + | ||
296 | +Enum | ||
297 | Name(diagnostics_output_format) Type(int) | ||
298 | |||
299 | EnumValue | ||
300 | diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c | ||
301 | --- a/gcc/diagnostic.c 2021-07-27 23:55:07.232286576 -0700 | ||
302 | +++ b/gcc/diagnostic.c 2021-12-14 01:16:01.545943202 -0800 | ||
303 | @@ -230,6 +230,7 @@ diagnostic_initialize (diagnostic_contex | ||
304 | context->column_unit = DIAGNOSTICS_COLUMN_UNIT_DISPLAY; | ||
305 | context->column_origin = 1; | ||
306 | context->tabstop = 8; | ||
307 | + context->escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE; | ||
308 | context->edit_context_ptr = NULL; | ||
309 | context->diagnostic_group_nesting_depth = 0; | ||
310 | context->diagnostic_group_emission_count = 0; | ||
311 | @@ -382,7 +383,10 @@ convert_column_unit (enum diagnostics_co | ||
312 | gcc_unreachable (); | ||
313 | |||
314 | case DIAGNOSTICS_COLUMN_UNIT_DISPLAY: | ||
315 | - return location_compute_display_column (s, tabstop); | ||
316 | + { | ||
317 | + cpp_char_column_policy policy (tabstop, cpp_wcwidth); | ||
318 | + return location_compute_display_column (s, policy); | ||
319 | + } | ||
320 | |||
321 | case DIAGNOSTICS_COLUMN_UNIT_BYTE: | ||
322 | return s.column; | ||
323 | @@ -2275,8 +2279,8 @@ test_diagnostic_get_location_text () | ||
324 | const char *const content = "smile \xf0\x9f\x98\x82\n"; | ||
325 | const int line_bytes = strlen (content) - 1; | ||
326 | const int def_tabstop = 8; | ||
327 | - const int display_width = cpp_display_width (content, line_bytes, | ||
328 | - def_tabstop); | ||
329 | + const cpp_char_column_policy policy (def_tabstop, cpp_wcwidth); | ||
330 | + const int display_width = cpp_display_width (content, line_bytes, policy); | ||
331 | ASSERT_EQ (line_bytes - 2, display_width); | ||
332 | temp_source_file tmp (SELFTEST_LOCATION, ".c", content); | ||
333 | const char *const fname = tmp.get_filename (); | ||
334 | diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc | ||
335 | --- a/gcc/diagnostic-format-json.cc 2021-07-27 23:55:07.232286576 -0700 | ||
336 | +++ b/gcc/diagnostic-format-json.cc 2021-12-14 01:16:01.541943272 -0800 | ||
337 | @@ -264,6 +264,9 @@ json_end_diagnostic (diagnostic_context | ||
338 | json::value *path_value = context->make_json_for_path (context, path); | ||
339 | diag_obj->set ("path", path_value); | ||
340 | } | ||
341 | + | ||
342 | + diag_obj->set ("escape-source", | ||
343 | + new json::literal (richloc->escape_on_output_p ())); | ||
344 | } | ||
345 | |||
346 | /* No-op implementation of "begin_group_cb" for JSON output. */ | ||
347 | diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h | ||
348 | --- a/gcc/diagnostic.h 2021-07-27 23:55:07.236286632 -0700 | ||
349 | +++ b/gcc/diagnostic.h 2021-12-14 01:16:01.545943202 -0800 | ||
350 | @@ -38,6 +38,20 @@ enum diagnostics_column_unit | ||
351 | DIAGNOSTICS_COLUMN_UNIT_BYTE | ||
352 | }; | ||
353 | |||
354 | +/* An enum for controlling how to print non-ASCII characters/bytes when | ||
355 | + a diagnostic suggests escaping the source code on output. */ | ||
356 | + | ||
357 | +enum diagnostics_escape_format | ||
358 | +{ | ||
359 | + /* Escape non-ASCII Unicode characters in the form <U+XXXX> and | ||
360 | + non-UTF-8 bytes in the form <XX>. */ | ||
361 | + DIAGNOSTICS_ESCAPE_FORMAT_UNICODE, | ||
362 | + | ||
363 | + /* Escape non-ASCII bytes in the form <XX> (thus showing the underlying | ||
364 | + encoding of non-ASCII Unicode characters). */ | ||
365 | + DIAGNOSTICS_ESCAPE_FORMAT_BYTES | ||
366 | +}; | ||
367 | + | ||
368 | /* Enum for overriding the standard output format. */ | ||
369 | |||
370 | enum diagnostics_output_format | ||
371 | @@ -320,6 +334,10 @@ struct diagnostic_context | ||
372 | /* The size of the tabstop for tab expansion. */ | ||
373 | int tabstop; | ||
374 | |||
375 | + /* How should non-ASCII/non-printable bytes be escaped when | ||
376 | + a diagnostic suggests escaping the source code on output. */ | ||
377 | + enum diagnostics_escape_format escape_format; | ||
378 | + | ||
379 | /* If non-NULL, an edit_context to which fix-it hints should be | ||
380 | applied, for generating patches. */ | ||
381 | edit_context *edit_context_ptr; | ||
382 | diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c | ||
383 | --- a/gcc/diagnostic-show-locus.c 2021-07-27 23:55:07.232286576 -0700 | ||
384 | +++ b/gcc/diagnostic-show-locus.c 2021-12-14 01:16:01.545943202 -0800 | ||
385 | @@ -175,10 +175,26 @@ enum column_unit { | ||
386 | class exploc_with_display_col : public expanded_location | ||
387 | { | ||
388 | public: | ||
389 | - exploc_with_display_col (const expanded_location &exploc, int tabstop) | ||
390 | - : expanded_location (exploc), | ||
391 | - m_display_col (location_compute_display_column (exploc, tabstop)) | ||
392 | - {} | ||
393 | + exploc_with_display_col (const expanded_location &exploc, | ||
394 | + const cpp_char_column_policy &policy, | ||
395 | + enum location_aspect aspect) | ||
396 | + : expanded_location (exploc), | ||
397 | + m_display_col (location_compute_display_column (exploc, policy)) | ||
398 | + { | ||
399 | + if (exploc.column > 0) | ||
400 | + { | ||
401 | + /* m_display_col is now the final column of the byte. | ||
402 | + If escaping has happened, we may want the first column instead. */ | ||
403 | + if (aspect != LOCATION_ASPECT_FINISH) | ||
404 | + { | ||
405 | + expanded_location prev_exploc (exploc); | ||
406 | + prev_exploc.column--; | ||
407 | + int prev_display_col | ||
408 | + = (location_compute_display_column (prev_exploc, policy)); | ||
409 | + m_display_col = prev_display_col + 1; | ||
410 | + } | ||
411 | + } | ||
412 | + } | ||
413 | |||
414 | int m_display_col; | ||
415 | }; | ||
416 | @@ -313,6 +329,31 @@ test_line_span () | ||
417 | |||
418 | #endif /* #if CHECKING_P */ | ||
419 | |||
420 | +/* A bundle of information containing how to print unicode | ||
421 | + characters and bytes when quoting source code. | ||
422 | + | ||
423 | + Provides a unified place to support escaping some subset | ||
424 | + of characters to some format. | ||
425 | + | ||
426 | + Extends char_column_policy; printing is split out to avoid | ||
427 | + libcpp having to know about pretty_printer. */ | ||
428 | + | ||
429 | +struct char_display_policy : public cpp_char_column_policy | ||
430 | +{ | ||
431 | + public: | ||
432 | + char_display_policy (int tabstop, | ||
433 | + int (*width_cb) (cppchar_t c), | ||
434 | + void (*print_cb) (pretty_printer *pp, | ||
435 | + const cpp_decoded_char &cp)) | ||
436 | + : cpp_char_column_policy (tabstop, width_cb), | ||
437 | + m_print_cb (print_cb) | ||
438 | + { | ||
439 | + } | ||
440 | + | ||
441 | + void (*m_print_cb) (pretty_printer *pp, | ||
442 | + const cpp_decoded_char &cp); | ||
443 | +}; | ||
444 | + | ||
445 | /* A class to control the overall layout when printing a diagnostic. | ||
446 | |||
447 | The layout is determined within the constructor. | ||
448 | @@ -345,6 +386,8 @@ class layout | ||
449 | |||
450 | void print_line (linenum_type row); | ||
451 | |||
452 | + void on_bad_codepoint (const char *ptr, cppchar_t ch, size_t ch_sz); | ||
453 | + | ||
454 | private: | ||
455 | bool will_show_line_p (linenum_type row) const; | ||
456 | void print_leading_fixits (linenum_type row); | ||
457 | @@ -386,6 +429,7 @@ class layout | ||
458 | private: | ||
459 | diagnostic_context *m_context; | ||
460 | pretty_printer *m_pp; | ||
461 | + char_display_policy m_policy; | ||
462 | location_t m_primary_loc; | ||
463 | exploc_with_display_col m_exploc; | ||
464 | colorizer m_colorizer; | ||
465 | @@ -398,6 +442,7 @@ class layout | ||
466 | auto_vec <line_span> m_line_spans; | ||
467 | int m_linenum_width; | ||
468 | int m_x_offset_display; | ||
469 | + bool m_escape_on_output; | ||
470 | }; | ||
471 | |||
472 | /* Implementation of "class colorizer". */ | ||
473 | @@ -646,6 +691,11 @@ layout_range::intersects_line_p (linenum | ||
474 | /* Default for when we don't care what the tab expansion is set to. */ | ||
475 | static const int def_tabstop = 8; | ||
476 | |||
477 | +static cpp_char_column_policy def_policy () | ||
478 | +{ | ||
479 | + return cpp_char_column_policy (8, cpp_wcwidth); | ||
480 | +} | ||
481 | + | ||
482 | /* Create some expanded locations for testing layout_range. The filename | ||
483 | member of the explocs is set to the empty string. This member will only be | ||
484 | inspected by the calls to location_compute_display_column() made from the | ||
485 | @@ -662,10 +712,13 @@ make_range (int start_line, int start_co | ||
486 | = {"", start_line, start_col, NULL, false}; | ||
487 | const expanded_location finish_exploc | ||
488 | = {"", end_line, end_col, NULL, false}; | ||
489 | - return layout_range (exploc_with_display_col (start_exploc, def_tabstop), | ||
490 | - exploc_with_display_col (finish_exploc, def_tabstop), | ||
491 | + return layout_range (exploc_with_display_col (start_exploc, def_policy (), | ||
492 | + LOCATION_ASPECT_START), | ||
493 | + exploc_with_display_col (finish_exploc, def_policy (), | ||
494 | + LOCATION_ASPECT_FINISH), | ||
495 | SHOW_RANGE_WITHOUT_CARET, | ||
496 | - exploc_with_display_col (start_exploc, def_tabstop), | ||
497 | + exploc_with_display_col (start_exploc, def_policy (), | ||
498 | + LOCATION_ASPECT_CARET), | ||
499 | 0, NULL); | ||
500 | } | ||
501 | |||
502 | @@ -959,6 +1012,164 @@ fixit_cmp (const void *p_a, const void * | ||
503 | return hint_a->get_start_loc () - hint_b->get_start_loc (); | ||
504 | } | ||
505 | |||
506 | +/* Callbacks for use when not escaping the source. */ | ||
507 | + | ||
508 | +/* The default callback for char_column_policy::m_width_cb is cpp_wcwidth. */ | ||
509 | + | ||
510 | +/* Callback for char_display_policy::m_print_cb for printing source chars | ||
511 | + when not escaping the source. */ | ||
512 | + | ||
513 | +static void | ||
514 | +default_print_decoded_ch (pretty_printer *pp, | ||
515 | + const cpp_decoded_char &decoded_ch) | ||
516 | +{ | ||
517 | + for (const char *ptr = decoded_ch.m_start_byte; | ||
518 | + ptr != decoded_ch.m_next_byte; ptr++) | ||
519 | + { | ||
520 | + if (*ptr == '\0' || *ptr == '\r') | ||
521 | + { | ||
522 | + pp_space (pp); | ||
523 | + continue; | ||
524 | + } | ||
525 | + | ||
526 | + pp_character (pp, *ptr); | ||
527 | + } | ||
528 | +} | ||
529 | + | ||
530 | +/* Callbacks for use with DIAGNOSTICS_ESCAPE_FORMAT_BYTES. */ | ||
531 | + | ||
532 | +static const int width_per_escaped_byte = 4; | ||
533 | + | ||
534 | +/* Callback for char_column_policy::m_width_cb for determining the | ||
535 | + display width when escaping with DIAGNOSTICS_ESCAPE_FORMAT_BYTES. */ | ||
536 | + | ||
537 | +static int | ||
538 | +escape_as_bytes_width (cppchar_t ch) | ||
539 | +{ | ||
540 | + if (ch < 0x80 && ISPRINT (ch)) | ||
541 | + return cpp_wcwidth (ch); | ||
542 | + else | ||
543 | + { | ||
544 | + if (ch <= 0x7F) return 1 * width_per_escaped_byte; | ||
545 | + if (ch <= 0x7FF) return 2 * width_per_escaped_byte; | ||
546 | + if (ch <= 0xFFFF) return 3 * width_per_escaped_byte; | ||
547 | + return 4 * width_per_escaped_byte; | ||
548 | + } | ||
549 | +} | ||
550 | + | ||
551 | +/* Callback for char_display_policy::m_print_cb for printing source chars | ||
552 | + when escaping with DIAGNOSTICS_ESCAPE_FORMAT_BYTES. */ | ||
553 | + | ||
554 | +static void | ||
555 | +escape_as_bytes_print (pretty_printer *pp, | ||
556 | + const cpp_decoded_char &decoded_ch) | ||
557 | +{ | ||
558 | + if (!decoded_ch.m_valid_ch) | ||
559 | + { | ||
560 | + for (const char *iter = decoded_ch.m_start_byte; | ||
561 | + iter != decoded_ch.m_next_byte; ++iter) | ||
562 | + { | ||
563 | + char buf[16]; | ||
564 | + sprintf (buf, "<%02x>", (unsigned char)*iter); | ||
565 | + pp_string (pp, buf); | ||
566 | + } | ||
567 | + return; | ||
568 | + } | ||
569 | + | ||
570 | + cppchar_t ch = decoded_ch.m_ch; | ||
571 | + if (ch < 0x80 && ISPRINT (ch)) | ||
572 | + pp_character (pp, ch); | ||
573 | + else | ||
574 | + { | ||
575 | + for (const char *iter = decoded_ch.m_start_byte; | ||
576 | + iter < decoded_ch.m_next_byte; ++iter) | ||
577 | + { | ||
578 | + char buf[16]; | ||
579 | + sprintf (buf, "<%02x>", (unsigned char)*iter); | ||
580 | + pp_string (pp, buf); | ||
581 | + } | ||
582 | + } | ||
583 | +} | ||
584 | + | ||
585 | +/* Callbacks for use with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE. */ | ||
586 | + | ||
587 | +/* Callback for char_column_policy::m_width_cb for determining the | ||
588 | + display width when escaping with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE. */ | ||
589 | + | ||
590 | +static int | ||
591 | +escape_as_unicode_width (cppchar_t ch) | ||
592 | +{ | ||
593 | + if (ch < 0x80 && ISPRINT (ch)) | ||
594 | + return cpp_wcwidth (ch); | ||
595 | + else | ||
596 | + { | ||
597 | + // Width of "<U+%04x>" | ||
598 | + if (ch > 0xfffff) | ||
599 | + return 10; | ||
600 | + else if (ch > 0xffff) | ||
601 | + return 9; | ||
602 | + else | ||
603 | + return 8; | ||
604 | + } | ||
605 | +} | ||
606 | + | ||
607 | +/* Callback for char_display_policy::m_print_cb for printing source chars | ||
608 | + when escaping with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE. */ | ||
609 | + | ||
610 | +static void | ||
611 | +escape_as_unicode_print (pretty_printer *pp, | ||
612 | + const cpp_decoded_char &decoded_ch) | ||
613 | +{ | ||
614 | + if (!decoded_ch.m_valid_ch) | ||
615 | + { | ||
616 | + escape_as_bytes_print (pp, decoded_ch); | ||
617 | + return; | ||
618 | + } | ||
619 | + | ||
620 | + cppchar_t ch = decoded_ch.m_ch; | ||
621 | + if (ch < 0x80 && ISPRINT (ch)) | ||
622 | + pp_character (pp, ch); | ||
623 | + else | ||
624 | + { | ||
625 | + char buf[16]; | ||
626 | + sprintf (buf, "<U+%04X>", ch); | ||
627 | + pp_string (pp, buf); | ||
628 | + } | ||
629 | +} | ||
630 | + | ||
631 | +/* Populate a char_display_policy based on DC and RICHLOC. */ | ||
632 | + | ||
633 | +static char_display_policy | ||
634 | +make_policy (const diagnostic_context &dc, | ||
635 | + const rich_location &richloc) | ||
636 | +{ | ||
637 | + /* The default is to not escape non-ASCII bytes. */ | ||
638 | + char_display_policy result | ||
639 | + (dc.tabstop, cpp_wcwidth, default_print_decoded_ch); | ||
640 | + | ||
641 | + /* If the diagnostic suggests escaping non-ASCII bytes, then | ||
642 | + use policy from user-supplied options. */ | ||
643 | + if (richloc.escape_on_output_p ()) | ||
644 | + { | ||
645 | + result.m_undecoded_byte_width = width_per_escaped_byte; | ||
646 | + switch (dc.escape_format) | ||
647 | + { | ||
648 | + default: | ||
649 | + gcc_unreachable (); | ||
650 | + case DIAGNOSTICS_ESCAPE_FORMAT_UNICODE: | ||
651 | + result.m_width_cb = escape_as_unicode_width; | ||
652 | + result.m_print_cb = escape_as_unicode_print; | ||
653 | + break; | ||
654 | + case DIAGNOSTICS_ESCAPE_FORMAT_BYTES: | ||
655 | + result.m_width_cb = escape_as_bytes_width; | ||
656 | + result.m_print_cb = escape_as_bytes_print; | ||
657 | + break; | ||
658 | + } | ||
659 | + } | ||
660 | + | ||
661 | + return result; | ||
662 | +} | ||
663 | + | ||
664 | /* Implementation of class layout. */ | ||
665 | |||
666 | /* Constructor for class layout. | ||
667 | @@ -975,8 +1186,10 @@ layout::layout (diagnostic_context * con | ||
668 | diagnostic_t diagnostic_kind) | ||
669 | : m_context (context), | ||
670 | m_pp (context->printer), | ||
671 | + m_policy (make_policy (*context, *richloc)), | ||
672 | m_primary_loc (richloc->get_range (0)->m_loc), | ||
673 | - m_exploc (richloc->get_expanded_location (0), context->tabstop), | ||
674 | + m_exploc (richloc->get_expanded_location (0), m_policy, | ||
675 | + LOCATION_ASPECT_CARET), | ||
676 | m_colorizer (context, diagnostic_kind), | ||
677 | m_colorize_source_p (context->colorize_source_p), | ||
678 | m_show_labels_p (context->show_labels_p), | ||
679 | @@ -986,7 +1199,8 @@ layout::layout (diagnostic_context * con | ||
680 | m_fixit_hints (richloc->get_num_fixit_hints ()), | ||
681 | m_line_spans (1 + richloc->get_num_locations ()), | ||
682 | m_linenum_width (0), | ||
683 | - m_x_offset_display (0) | ||
684 | + m_x_offset_display (0), | ||
685 | + m_escape_on_output (richloc->escape_on_output_p ()) | ||
686 | { | ||
687 | for (unsigned int idx = 0; idx < richloc->get_num_locations (); idx++) | ||
688 | { | ||
689 | @@ -1072,10 +1286,13 @@ layout::maybe_add_location_range (const | ||
690 | |||
691 | /* Everything is now known to be in the correct source file, | ||
692 | but it may require further sanitization. */ | ||
693 | - layout_range ri (exploc_with_display_col (start, m_context->tabstop), | ||
694 | - exploc_with_display_col (finish, m_context->tabstop), | ||
695 | + layout_range ri (exploc_with_display_col (start, m_policy, | ||
696 | + LOCATION_ASPECT_START), | ||
697 | + exploc_with_display_col (finish, m_policy, | ||
698 | + LOCATION_ASPECT_FINISH), | ||
699 | loc_range->m_range_display_kind, | ||
700 | - exploc_with_display_col (caret, m_context->tabstop), | ||
701 | + exploc_with_display_col (caret, m_policy, | ||
702 | + LOCATION_ASPECT_CARET), | ||
703 | original_idx, loc_range->m_label); | ||
704 | |||
705 | /* If we have a range that finishes before it starts (perhaps | ||
706 | @@ -1409,7 +1626,7 @@ layout::calculate_x_offset_display () | ||
707 | = get_line_bytes_without_trailing_whitespace (line.get_buffer (), | ||
708 | line.length ()); | ||
709 | int eol_display_column | ||
710 | - = cpp_display_width (line.get_buffer (), line_bytes, m_context->tabstop); | ||
711 | + = cpp_display_width (line.get_buffer (), line_bytes, m_policy); | ||
712 | if (caret_display_column > eol_display_column | ||
713 | || !caret_display_column) | ||
714 | { | ||
715 | @@ -1488,7 +1705,7 @@ layout::print_source_line (linenum_type | ||
716 | /* This object helps to keep track of which display column we are at, which is | ||
717 | necessary for computing the line bounds in display units, for doing | ||
718 | tab expansion, and for implementing m_x_offset_display. */ | ||
719 | - cpp_display_width_computation dw (line, line_bytes, m_context->tabstop); | ||
720 | + cpp_display_width_computation dw (line, line_bytes, m_policy); | ||
721 | |||
722 | /* Skip the first m_x_offset_display display columns. In case the leading | ||
723 | portion that will be skipped ends with a character with wcwidth > 1, then | ||
724 | @@ -1536,7 +1753,8 @@ layout::print_source_line (linenum_type | ||
725 | tabs and replacing some control bytes with spaces as necessary. */ | ||
726 | const char *c = dw.next_byte (); | ||
727 | const int start_disp_col = dw.display_cols_processed () + 1; | ||
728 | - const int this_display_width = dw.process_next_codepoint (); | ||
729 | + cpp_decoded_char cp; | ||
730 | + const int this_display_width = dw.process_next_codepoint (&cp); | ||
731 | if (*c == '\t') | ||
732 | { | ||
733 | /* The returned display width is the number of spaces into which the | ||
734 | @@ -1545,15 +1763,6 @@ layout::print_source_line (linenum_type | ||
735 | pp_space (m_pp); | ||
736 | continue; | ||
737 | } | ||
738 | - if (*c == '\0' || *c == '\r') | ||
739 | - { | ||
740 | - /* cpp_wcwidth() promises to return 1 for all control bytes, and we | ||
741 | - want to output these as a single space too, so this case is | ||
742 | - actually the same as the '\t' case. */ | ||
743 | - gcc_assert (this_display_width == 1); | ||
744 | - pp_space (m_pp); | ||
745 | - continue; | ||
746 | - } | ||
747 | |||
748 | /* We have a (possibly multibyte) character to output; update the line | ||
749 | bounds if it is not whitespace. */ | ||
750 | @@ -1565,7 +1774,8 @@ layout::print_source_line (linenum_type | ||
751 | } | ||
752 | |||
753 | /* Output the character. */ | ||
754 | - while (c != dw.next_byte ()) pp_character (m_pp, *c++); | ||
755 | + m_policy.m_print_cb (m_pp, cp); | ||
756 | + c = dw.next_byte (); | ||
757 | } | ||
758 | print_newline (); | ||
759 | return lbounds; | ||
760 | @@ -1664,14 +1874,14 @@ layout::print_annotation_line (linenum_t | ||
761 | class line_label | ||
762 | { | ||
763 | public: | ||
764 | - line_label (diagnostic_context *context, int state_idx, int column, | ||
765 | + line_label (const cpp_char_column_policy &policy, | ||
766 | + int state_idx, int column, | ||
767 | label_text text) | ||
768 | : m_state_idx (state_idx), m_column (column), | ||
769 | m_text (text), m_label_line (0), m_has_vbar (true) | ||
770 | { | ||
771 | const int bytes = strlen (text.m_buffer); | ||
772 | - m_display_width | ||
773 | - = cpp_display_width (text.m_buffer, bytes, context->tabstop); | ||
774 | + m_display_width = cpp_display_width (text.m_buffer, bytes, policy); | ||
775 | } | ||
776 | |||
777 | /* Sorting is primarily by column, then by state index. */ | ||
778 | @@ -1731,7 +1941,7 @@ layout::print_any_labels (linenum_type r | ||
779 | if (text.m_buffer == NULL) | ||
780 | continue; | ||
781 | |||
782 | - labels.safe_push (line_label (m_context, i, disp_col, text)); | ||
783 | + labels.safe_push (line_label (m_policy, i, disp_col, text)); | ||
784 | } | ||
785 | } | ||
786 | |||
787 | @@ -2011,7 +2221,7 @@ public: | ||
788 | |||
789 | /* Get the range of bytes or display columns that HINT would affect. */ | ||
790 | static column_range | ||
791 | -get_affected_range (diagnostic_context *context, | ||
792 | +get_affected_range (const cpp_char_column_policy &policy, | ||
793 | const fixit_hint *hint, enum column_unit col_unit) | ||
794 | { | ||
795 | expanded_location exploc_start = expand_location (hint->get_start_loc ()); | ||
796 | @@ -2022,13 +2232,11 @@ get_affected_range (diagnostic_context * | ||
797 | int finish_column; | ||
798 | if (col_unit == CU_DISPLAY_COLS) | ||
799 | { | ||
800 | - start_column | ||
801 | - = location_compute_display_column (exploc_start, context->tabstop); | ||
802 | + start_column = location_compute_display_column (exploc_start, policy); | ||
803 | if (hint->insertion_p ()) | ||
804 | finish_column = start_column - 1; | ||
805 | else | ||
806 | - finish_column | ||
807 | - = location_compute_display_column (exploc_finish, context->tabstop); | ||
808 | + finish_column = location_compute_display_column (exploc_finish, policy); | ||
809 | } | ||
810 | else | ||
811 | { | ||
812 | @@ -2041,12 +2249,13 @@ get_affected_range (diagnostic_context * | ||
813 | /* Get the range of display columns that would be printed for HINT. */ | ||
814 | |||
815 | static column_range | ||
816 | -get_printed_columns (diagnostic_context *context, const fixit_hint *hint) | ||
817 | +get_printed_columns (const cpp_char_column_policy &policy, | ||
818 | + const fixit_hint *hint) | ||
819 | { | ||
820 | expanded_location exploc = expand_location (hint->get_start_loc ()); | ||
821 | - int start_column = location_compute_display_column (exploc, context->tabstop); | ||
822 | + int start_column = location_compute_display_column (exploc, policy); | ||
823 | int hint_width = cpp_display_width (hint->get_string (), hint->get_length (), | ||
824 | - context->tabstop); | ||
825 | + policy); | ||
826 | int final_hint_column = start_column + hint_width - 1; | ||
827 | if (hint->insertion_p ()) | ||
828 | { | ||
829 | @@ -2056,8 +2265,7 @@ get_printed_columns (diagnostic_context | ||
830 | { | ||
831 | exploc = expand_location (hint->get_next_loc ()); | ||
832 | --exploc.column; | ||
833 | - int finish_column | ||
834 | - = location_compute_display_column (exploc, context->tabstop); | ||
835 | + int finish_column = location_compute_display_column (exploc, policy); | ||
836 | return column_range (start_column, | ||
837 | MAX (finish_column, final_hint_column)); | ||
838 | } | ||
839 | @@ -2075,13 +2283,13 @@ public: | ||
840 | column_range affected_columns, | ||
841 | column_range printed_columns, | ||
842 | const char *new_text, size_t new_text_len, | ||
843 | - int tabstop) | ||
844 | + const cpp_char_column_policy &policy) | ||
845 | : m_affected_bytes (affected_bytes), | ||
846 | m_affected_columns (affected_columns), | ||
847 | m_printed_columns (printed_columns), | ||
848 | m_text (xstrdup (new_text)), | ||
849 | m_byte_length (new_text_len), | ||
850 | - m_tabstop (tabstop), | ||
851 | + m_policy (policy), | ||
852 | m_alloc_sz (new_text_len + 1) | ||
853 | { | ||
854 | compute_display_cols (); | ||
855 | @@ -2099,7 +2307,7 @@ public: | ||
856 | |||
857 | void compute_display_cols () | ||
858 | { | ||
859 | - m_display_cols = cpp_display_width (m_text, m_byte_length, m_tabstop); | ||
860 | + m_display_cols = cpp_display_width (m_text, m_byte_length, m_policy); | ||
861 | } | ||
862 | |||
863 | void overwrite (int dst_offset, const char_span &src_span) | ||
864 | @@ -2127,7 +2335,7 @@ public: | ||
865 | char *m_text; | ||
866 | size_t m_byte_length; /* Not including null-terminator. */ | ||
867 | int m_display_cols; | ||
868 | - int m_tabstop; | ||
869 | + const cpp_char_column_policy &m_policy; | ||
870 | size_t m_alloc_sz; | ||
871 | }; | ||
872 | |||
873 | @@ -2163,15 +2371,16 @@ correction::ensure_terminated () | ||
874 | class line_corrections | ||
875 | { | ||
876 | public: | ||
877 | - line_corrections (diagnostic_context *context, const char *filename, | ||
878 | + line_corrections (const char_display_policy &policy, | ||
879 | + const char *filename, | ||
880 | linenum_type row) | ||
881 | - : m_context (context), m_filename (filename), m_row (row) | ||
882 | + : m_policy (policy), m_filename (filename), m_row (row) | ||
883 | {} | ||
884 | ~line_corrections (); | ||
885 | |||
886 | void add_hint (const fixit_hint *hint); | ||
887 | |||
888 | - diagnostic_context *m_context; | ||
889 | + const char_display_policy &m_policy; | ||
890 | const char *m_filename; | ||
891 | linenum_type m_row; | ||
892 | auto_vec <correction *> m_corrections; | ||
893 | @@ -2217,10 +2426,10 @@ source_line::source_line (const char *fi | ||
894 | void | ||
895 | line_corrections::add_hint (const fixit_hint *hint) | ||
896 | { | ||
897 | - column_range affected_bytes = get_affected_range (m_context, hint, CU_BYTES); | ||
898 | - column_range affected_columns = get_affected_range (m_context, hint, | ||
899 | + column_range affected_bytes = get_affected_range (m_policy, hint, CU_BYTES); | ||
900 | + column_range affected_columns = get_affected_range (m_policy, hint, | ||
901 | CU_DISPLAY_COLS); | ||
902 | - column_range printed_columns = get_printed_columns (m_context, hint); | ||
903 | + column_range printed_columns = get_printed_columns (m_policy, hint); | ||
904 | |||
905 | /* Potentially consolidate. */ | ||
906 | if (!m_corrections.is_empty ()) | ||
907 | @@ -2289,7 +2498,7 @@ line_corrections::add_hint (const fixit_ | ||
908 | printed_columns, | ||
909 | hint->get_string (), | ||
910 | hint->get_length (), | ||
911 | - m_context->tabstop)); | ||
912 | + m_policy)); | ||
913 | } | ||
914 | |||
915 | /* If there are any fixit hints on source line ROW, print them. | ||
916 | @@ -2303,7 +2512,7 @@ layout::print_trailing_fixits (linenum_t | ||
917 | { | ||
918 | /* Build a list of correction instances for the line, | ||
919 | potentially consolidating hints (for the sake of readability). */ | ||
920 | - line_corrections corrections (m_context, m_exploc.file, row); | ||
921 | + line_corrections corrections (m_policy, m_exploc.file, row); | ||
922 | for (unsigned int i = 0; i < m_fixit_hints.length (); i++) | ||
923 | { | ||
924 | const fixit_hint *hint = m_fixit_hints[i]; | ||
925 | @@ -2646,6 +2855,59 @@ namespace selftest { | ||
926 | |||
927 | /* Selftests for diagnostic_show_locus. */ | ||
928 | |||
929 | +/* Verify that cpp_display_width correctly handles escaping. */ | ||
930 | + | ||
931 | +static void | ||
932 | +test_display_widths () | ||
933 | +{ | ||
934 | + gcc_rich_location richloc (UNKNOWN_LOCATION); | ||
935 | + | ||
936 | + /* U+03C0 "GREEK SMALL LETTER PI". */ | ||
937 | + const char *pi = "\xCF\x80"; | ||
938 | + /* U+1F642 "SLIGHTLY SMILING FACE". */ | ||
939 | + const char *emoji = "\xF0\x9F\x99\x82"; | ||
940 | + /* Stray trailing byte of a UTF-8 character. */ | ||
941 | + const char *stray = "\xBF"; | ||
942 | + /* U+10FFFF. */ | ||
943 | + const char *max_codepoint = "\xF4\x8F\xBF\xBF"; | ||
944 | + | ||
945 | + /* No escaping. */ | ||
946 | + { | ||
947 | + test_diagnostic_context dc; | ||
948 | + char_display_policy policy (make_policy (dc, richloc)); | ||
949 | + ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 1); | ||
950 | + ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 2); | ||
951 | + ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 1); | ||
952 | + /* Don't check width of U+10FFFF; it's in a private use plane. */ | ||
953 | + } | ||
954 | + | ||
955 | + richloc.set_escape_on_output (true); | ||
956 | + | ||
957 | + { | ||
958 | + test_diagnostic_context dc; | ||
959 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE; | ||
960 | + char_display_policy policy (make_policy (dc, richloc)); | ||
961 | + ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 8); | ||
962 | + ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 9); | ||
963 | + ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 4); | ||
964 | + ASSERT_EQ (cpp_display_width (max_codepoint, strlen (max_codepoint), | ||
965 | + policy), | ||
966 | + strlen ("<U+10FFFF>")); | ||
967 | + } | ||
968 | + | ||
969 | + { | ||
970 | + test_diagnostic_context dc; | ||
971 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES; | ||
972 | + char_display_policy policy (make_policy (dc, richloc)); | ||
973 | + ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 8); | ||
974 | + ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 16); | ||
975 | + ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 4); | ||
976 | + ASSERT_EQ (cpp_display_width (max_codepoint, strlen (max_codepoint), | ||
977 | + policy), | ||
978 | + 16); | ||
979 | + } | ||
980 | +} | ||
981 | + | ||
982 | /* For precise tests of the layout, make clear where the source line will | ||
983 | start. test_left_margin sets the total byte count from the left side of the | ||
984 | screen to the start of source lines, after the line number and the separator, | ||
985 | @@ -2715,10 +2977,10 @@ test_layout_x_offset_display_utf8 (const | ||
986 | char_span lspan = location_get_source_line (tmp.get_filename (), 1); | ||
987 | ASSERT_EQ (line_display_cols, | ||
988 | cpp_display_width (lspan.get_buffer (), lspan.length (), | ||
989 | - def_tabstop)); | ||
990 | + def_policy ())); | ||
991 | ASSERT_EQ (line_display_cols, | ||
992 | location_compute_display_column (expand_location (line_end), | ||
993 | - def_tabstop)); | ||
994 | + def_policy ())); | ||
995 | ASSERT_EQ (0, memcmp (lspan.get_buffer () + (emoji_col - 1), | ||
996 | "\xf0\x9f\x98\x82\xf0\x9f\x98\x82", 8)); | ||
997 | |||
998 | @@ -2866,12 +3128,13 @@ test_layout_x_offset_display_tab (const | ||
999 | ASSERT_EQ ('\t', *(lspan.get_buffer () + (tab_col - 1))); | ||
1000 | for (int tabstop = 1; tabstop != num_tabstops; ++tabstop) | ||
1001 | { | ||
1002 | + cpp_char_column_policy policy (tabstop, cpp_wcwidth); | ||
1003 | ASSERT_EQ (line_bytes + extra_width[tabstop], | ||
1004 | cpp_display_width (lspan.get_buffer (), lspan.length (), | ||
1005 | - tabstop)); | ||
1006 | + policy)); | ||
1007 | ASSERT_EQ (line_bytes + extra_width[tabstop], | ||
1008 | location_compute_display_column (expand_location (line_end), | ||
1009 | - tabstop)); | ||
1010 | + policy)); | ||
1011 | } | ||
1012 | |||
1013 | /* Check that the tab is expanded to the expected number of spaces. */ | ||
1014 | @@ -4003,6 +4266,43 @@ test_one_liner_labels_utf8 () | ||
1015 | " bb\xf0\x9f\x98\x82\xf0\x9f\x98\x82\n", | ||
1016 | pp_formatted_text (dc.printer)); | ||
1017 | } | ||
1018 | + | ||
1019 | + /* Example of escaping the source lines. */ | ||
1020 | + { | ||
1021 | + text_range_label label0 ("label 0\xf0\x9f\x98\x82"); | ||
1022 | + text_range_label label1 ("label 1\xcf\x80"); | ||
1023 | + text_range_label label2 ("label 2\xcf\x80"); | ||
1024 | + gcc_rich_location richloc (foo, &label0); | ||
1025 | + richloc.add_range (bar, SHOW_RANGE_WITHOUT_CARET, &label1); | ||
1026 | + richloc.add_range (field, SHOW_RANGE_WITHOUT_CARET, &label2); | ||
1027 | + richloc.set_escape_on_output (true); | ||
1028 | + | ||
1029 | + { | ||
1030 | + test_diagnostic_context dc; | ||
1031 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE; | ||
1032 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1033 | + ASSERT_STREQ (" <U+1F602>_foo = <U+03C0>_bar.<U+1F602>_field<U+03C0>;\n" | ||
1034 | + " ^~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~\n" | ||
1035 | + " | | |\n" | ||
1036 | + " | | label 2\xcf\x80\n" | ||
1037 | + " | label 1\xcf\x80\n" | ||
1038 | + " label 0\xf0\x9f\x98\x82\n", | ||
1039 | + pp_formatted_text (dc.printer)); | ||
1040 | + } | ||
1041 | + { | ||
1042 | + test_diagnostic_context dc; | ||
1043 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES; | ||
1044 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1045 | + ASSERT_STREQ | ||
1046 | + (" <f0><9f><98><82>_foo = <cf><80>_bar.<f0><9f><98><82>_field<cf><80>;\n" | ||
1047 | + " ^~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" | ||
1048 | + " | | |\n" | ||
1049 | + " | | label 2\xcf\x80\n" | ||
1050 | + " | label 1\xcf\x80\n" | ||
1051 | + " label 0\xf0\x9f\x98\x82\n", | ||
1052 | + pp_formatted_text (dc.printer)); | ||
1053 | + } | ||
1054 | + } | ||
1055 | } | ||
1056 | |||
1057 | /* Make sure that colorization codes don't interrupt a multibyte | ||
1058 | @@ -4057,9 +4357,9 @@ test_diagnostic_show_locus_one_liner_utf | ||
1059 | |||
1060 | char_span lspan = location_get_source_line (tmp.get_filename (), 1); | ||
1061 | ASSERT_EQ (25, cpp_display_width (lspan.get_buffer (), lspan.length (), | ||
1062 | - def_tabstop)); | ||
1063 | + def_policy ())); | ||
1064 | ASSERT_EQ (25, location_compute_display_column (expand_location (line_end), | ||
1065 | - def_tabstop)); | ||
1066 | + def_policy ())); | ||
1067 | |||
1068 | test_one_liner_simple_caret_utf8 (); | ||
1069 | test_one_liner_caret_and_range_utf8 (); | ||
1070 | @@ -4445,30 +4745,31 @@ test_overlapped_fixit_printing (const li | ||
1071 | pp_formatted_text (dc.printer)); | ||
1072 | |||
1073 | /* Unit-test the line_corrections machinery. */ | ||
1074 | + char_display_policy policy (make_policy (dc, richloc)); | ||
1075 | ASSERT_EQ (3, richloc.get_num_fixit_hints ()); | ||
1076 | const fixit_hint *hint_0 = richloc.get_fixit_hint (0); | ||
1077 | ASSERT_EQ (column_range (12, 12), | ||
1078 | - get_affected_range (&dc, hint_0, CU_BYTES)); | ||
1079 | + get_affected_range (policy, hint_0, CU_BYTES)); | ||
1080 | ASSERT_EQ (column_range (12, 12), | ||
1081 | - get_affected_range (&dc, hint_0, CU_DISPLAY_COLS)); | ||
1082 | - ASSERT_EQ (column_range (12, 22), get_printed_columns (&dc, hint_0)); | ||
1083 | + get_affected_range (policy, hint_0, CU_DISPLAY_COLS)); | ||
1084 | + ASSERT_EQ (column_range (12, 22), get_printed_columns (policy, hint_0)); | ||
1085 | const fixit_hint *hint_1 = richloc.get_fixit_hint (1); | ||
1086 | ASSERT_EQ (column_range (18, 18), | ||
1087 | - get_affected_range (&dc, hint_1, CU_BYTES)); | ||
1088 | + get_affected_range (policy, hint_1, CU_BYTES)); | ||
1089 | ASSERT_EQ (column_range (18, 18), | ||
1090 | - get_affected_range (&dc, hint_1, CU_DISPLAY_COLS)); | ||
1091 | - ASSERT_EQ (column_range (18, 20), get_printed_columns (&dc, hint_1)); | ||
1092 | + get_affected_range (policy, hint_1, CU_DISPLAY_COLS)); | ||
1093 | + ASSERT_EQ (column_range (18, 20), get_printed_columns (policy, hint_1)); | ||
1094 | const fixit_hint *hint_2 = richloc.get_fixit_hint (2); | ||
1095 | ASSERT_EQ (column_range (29, 28), | ||
1096 | - get_affected_range (&dc, hint_2, CU_BYTES)); | ||
1097 | + get_affected_range (policy, hint_2, CU_BYTES)); | ||
1098 | ASSERT_EQ (column_range (29, 28), | ||
1099 | - get_affected_range (&dc, hint_2, CU_DISPLAY_COLS)); | ||
1100 | - ASSERT_EQ (column_range (29, 29), get_printed_columns (&dc, hint_2)); | ||
1101 | + get_affected_range (policy, hint_2, CU_DISPLAY_COLS)); | ||
1102 | + ASSERT_EQ (column_range (29, 29), get_printed_columns (policy, hint_2)); | ||
1103 | |||
1104 | /* Add each hint in turn to a line_corrections instance, | ||
1105 | and verify that they are consolidated into one correction instance | ||
1106 | as expected. */ | ||
1107 | - line_corrections lc (&dc, tmp.get_filename (), 1); | ||
1108 | + line_corrections lc (policy, tmp.get_filename (), 1); | ||
1109 | |||
1110 | /* The first replace hint by itself. */ | ||
1111 | lc.add_hint (hint_0); | ||
1112 | @@ -4660,30 +4961,31 @@ test_overlapped_fixit_printing_utf8 (con | ||
1113 | pp_formatted_text (dc.printer)); | ||
1114 | |||
1115 | /* Unit-test the line_corrections machinery. */ | ||
1116 | + char_display_policy policy (make_policy (dc, richloc)); | ||
1117 | ASSERT_EQ (3, richloc.get_num_fixit_hints ()); | ||
1118 | const fixit_hint *hint_0 = richloc.get_fixit_hint (0); | ||
1119 | ASSERT_EQ (column_range (14, 14), | ||
1120 | - get_affected_range (&dc, hint_0, CU_BYTES)); | ||
1121 | + get_affected_range (policy, hint_0, CU_BYTES)); | ||
1122 | ASSERT_EQ (column_range (12, 12), | ||
1123 | - get_affected_range (&dc, hint_0, CU_DISPLAY_COLS)); | ||
1124 | - ASSERT_EQ (column_range (12, 22), get_printed_columns (&dc, hint_0)); | ||
1125 | + get_affected_range (policy, hint_0, CU_DISPLAY_COLS)); | ||
1126 | + ASSERT_EQ (column_range (12, 22), get_printed_columns (policy, hint_0)); | ||
1127 | const fixit_hint *hint_1 = richloc.get_fixit_hint (1); | ||
1128 | ASSERT_EQ (column_range (22, 22), | ||
1129 | - get_affected_range (&dc, hint_1, CU_BYTES)); | ||
1130 | + get_affected_range (policy, hint_1, CU_BYTES)); | ||
1131 | ASSERT_EQ (column_range (18, 18), | ||
1132 | - get_affected_range (&dc, hint_1, CU_DISPLAY_COLS)); | ||
1133 | - ASSERT_EQ (column_range (18, 20), get_printed_columns (&dc, hint_1)); | ||
1134 | + get_affected_range (policy, hint_1, CU_DISPLAY_COLS)); | ||
1135 | + ASSERT_EQ (column_range (18, 20), get_printed_columns (policy, hint_1)); | ||
1136 | const fixit_hint *hint_2 = richloc.get_fixit_hint (2); | ||
1137 | ASSERT_EQ (column_range (35, 34), | ||
1138 | - get_affected_range (&dc, hint_2, CU_BYTES)); | ||
1139 | + get_affected_range (policy, hint_2, CU_BYTES)); | ||
1140 | ASSERT_EQ (column_range (30, 29), | ||
1141 | - get_affected_range (&dc, hint_2, CU_DISPLAY_COLS)); | ||
1142 | - ASSERT_EQ (column_range (30, 30), get_printed_columns (&dc, hint_2)); | ||
1143 | + get_affected_range (policy, hint_2, CU_DISPLAY_COLS)); | ||
1144 | + ASSERT_EQ (column_range (30, 30), get_printed_columns (policy, hint_2)); | ||
1145 | |||
1146 | /* Add each hint in turn to a line_corrections instance, | ||
1147 | and verify that they are consolidated into one correction instance | ||
1148 | as expected. */ | ||
1149 | - line_corrections lc (&dc, tmp.get_filename (), 1); | ||
1150 | + line_corrections lc (policy, tmp.get_filename (), 1); | ||
1151 | |||
1152 | /* The first replace hint by itself. */ | ||
1153 | lc.add_hint (hint_0); | ||
1154 | @@ -4877,15 +5179,16 @@ test_overlapped_fixit_printing_2 (const | ||
1155 | richloc.add_fixit_insert_before (col_21, "}"); | ||
1156 | |||
1157 | /* These fixits should be accepted; they can't be consolidated. */ | ||
1158 | + char_display_policy policy (make_policy (dc, richloc)); | ||
1159 | ASSERT_EQ (2, richloc.get_num_fixit_hints ()); | ||
1160 | const fixit_hint *hint_0 = richloc.get_fixit_hint (0); | ||
1161 | ASSERT_EQ (column_range (23, 22), | ||
1162 | - get_affected_range (&dc, hint_0, CU_BYTES)); | ||
1163 | - ASSERT_EQ (column_range (23, 23), get_printed_columns (&dc, hint_0)); | ||
1164 | + get_affected_range (policy, hint_0, CU_BYTES)); | ||
1165 | + ASSERT_EQ (column_range (23, 23), get_printed_columns (policy, hint_0)); | ||
1166 | const fixit_hint *hint_1 = richloc.get_fixit_hint (1); | ||
1167 | ASSERT_EQ (column_range (21, 20), | ||
1168 | - get_affected_range (&dc, hint_1, CU_BYTES)); | ||
1169 | - ASSERT_EQ (column_range (21, 21), get_printed_columns (&dc, hint_1)); | ||
1170 | + get_affected_range (policy, hint_1, CU_BYTES)); | ||
1171 | + ASSERT_EQ (column_range (21, 21), get_printed_columns (policy, hint_1)); | ||
1172 | |||
1173 | /* Verify that they're printed correctly. */ | ||
1174 | diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1175 | @@ -5152,10 +5455,11 @@ test_tab_expansion (const line_table_cas | ||
1176 | ....................123 45678901234 56789012345 columns */ | ||
1177 | |||
1178 | const int tabstop = 8; | ||
1179 | + cpp_char_column_policy policy (tabstop, cpp_wcwidth); | ||
1180 | const int first_non_ws_byte_col = 7; | ||
1181 | const int right_quote_byte_col = 15; | ||
1182 | const int last_byte_col = 25; | ||
1183 | - ASSERT_EQ (35, cpp_display_width (content, last_byte_col, tabstop)); | ||
1184 | + ASSERT_EQ (35, cpp_display_width (content, last_byte_col, policy)); | ||
1185 | |||
1186 | temp_source_file tmp (SELFTEST_LOCATION, ".c", content); | ||
1187 | line_table_test ltt (case_); | ||
1188 | @@ -5198,6 +5502,114 @@ test_tab_expansion (const line_table_cas | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | +/* Verify that the escaping machinery can cope with a variety of different | ||
1193 | + invalid bytes. */ | ||
1194 | + | ||
1195 | +static void | ||
1196 | +test_escaping_bytes_1 (const line_table_case &case_) | ||
1197 | +{ | ||
1198 | + const char content[] = "before\0\1\2\3\r\x80\xff""after\n"; | ||
1199 | + const size_t sz = sizeof (content); | ||
1200 | + temp_source_file tmp (SELFTEST_LOCATION, ".c", content, sz); | ||
1201 | + line_table_test ltt (case_); | ||
1202 | + const line_map_ordinary *ord_map = linemap_check_ordinary | ||
1203 | + (linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 0)); | ||
1204 | + linemap_line_start (line_table, 1, 100); | ||
1205 | + | ||
1206 | + location_t finish | ||
1207 | + = linemap_position_for_line_and_column (line_table, ord_map, 1, | ||
1208 | + strlen (content)); | ||
1209 | + | ||
1210 | + if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS) | ||
1211 | + return; | ||
1212 | + | ||
1213 | + /* Locations of the NUL and \r bytes. */ | ||
1214 | + location_t nul_loc | ||
1215 | + = linemap_position_for_line_and_column (line_table, ord_map, 1, 7); | ||
1216 | + location_t r_loc | ||
1217 | + = linemap_position_for_line_and_column (line_table, ord_map, 1, 11); | ||
1218 | + gcc_rich_location richloc (nul_loc); | ||
1219 | + richloc.add_range (r_loc); | ||
1220 | + | ||
1221 | + { | ||
1222 | + test_diagnostic_context dc; | ||
1223 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1224 | + ASSERT_STREQ (" before \1\2\3 \x80\xff""after\n" | ||
1225 | + " ^ ~\n", | ||
1226 | + pp_formatted_text (dc.printer)); | ||
1227 | + } | ||
1228 | + richloc.set_escape_on_output (true); | ||
1229 | + { | ||
1230 | + test_diagnostic_context dc; | ||
1231 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE; | ||
1232 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1233 | + ASSERT_STREQ | ||
1234 | + (" before<U+0000><U+0001><U+0002><U+0003><U+000D><80><ff>after\n" | ||
1235 | + " ^~~~~~~~ ~~~~~~~~\n", | ||
1236 | + pp_formatted_text (dc.printer)); | ||
1237 | + } | ||
1238 | + { | ||
1239 | + test_diagnostic_context dc; | ||
1240 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES; | ||
1241 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1242 | + ASSERT_STREQ (" before<00><01><02><03><0d><80><ff>after\n" | ||
1243 | + " ^~~~ ~~~~\n", | ||
1244 | + pp_formatted_text (dc.printer)); | ||
1245 | + } | ||
1246 | +} | ||
1247 | + | ||
1248 | +/* As above, but verify that we handle the initial byte of a line | ||
1249 | + correctly. */ | ||
1250 | + | ||
1251 | +static void | ||
1252 | +test_escaping_bytes_2 (const line_table_case &case_) | ||
1253 | +{ | ||
1254 | + const char content[] = "\0after\n"; | ||
1255 | + const size_t sz = sizeof (content); | ||
1256 | + temp_source_file tmp (SELFTEST_LOCATION, ".c", content, sz); | ||
1257 | + line_table_test ltt (case_); | ||
1258 | + const line_map_ordinary *ord_map = linemap_check_ordinary | ||
1259 | + (linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 0)); | ||
1260 | + linemap_line_start (line_table, 1, 100); | ||
1261 | + | ||
1262 | + location_t finish | ||
1263 | + = linemap_position_for_line_and_column (line_table, ord_map, 1, | ||
1264 | + strlen (content)); | ||
1265 | + | ||
1266 | + if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS) | ||
1267 | + return; | ||
1268 | + | ||
1269 | + /* Location of the NUL byte. */ | ||
1270 | + location_t nul_loc | ||
1271 | + = linemap_position_for_line_and_column (line_table, ord_map, 1, 1); | ||
1272 | + gcc_rich_location richloc (nul_loc); | ||
1273 | + | ||
1274 | + { | ||
1275 | + test_diagnostic_context dc; | ||
1276 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1277 | + ASSERT_STREQ (" after\n" | ||
1278 | + " ^\n", | ||
1279 | + pp_formatted_text (dc.printer)); | ||
1280 | + } | ||
1281 | + richloc.set_escape_on_output (true); | ||
1282 | + { | ||
1283 | + test_diagnostic_context dc; | ||
1284 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE; | ||
1285 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1286 | + ASSERT_STREQ (" <U+0000>after\n" | ||
1287 | + " ^~~~~~~~\n", | ||
1288 | + pp_formatted_text (dc.printer)); | ||
1289 | + } | ||
1290 | + { | ||
1291 | + test_diagnostic_context dc; | ||
1292 | + dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES; | ||
1293 | + diagnostic_show_locus (&dc, &richloc, DK_ERROR); | ||
1294 | + ASSERT_STREQ (" <00>after\n" | ||
1295 | + " ^~~~\n", | ||
1296 | + pp_formatted_text (dc.printer)); | ||
1297 | + } | ||
1298 | +} | ||
1299 | + | ||
1300 | /* Verify that line numbers are correctly printed for the case of | ||
1301 | a multiline range in which the width of the line numbers changes | ||
1302 | (e.g. from "9" to "10"). */ | ||
1303 | @@ -5254,6 +5666,8 @@ diagnostic_show_locus_c_tests () | ||
1304 | test_layout_range_for_single_line (); | ||
1305 | test_layout_range_for_multiple_lines (); | ||
1306 | |||
1307 | + test_display_widths (); | ||
1308 | + | ||
1309 | for_each_line_table_case (test_layout_x_offset_display_utf8); | ||
1310 | for_each_line_table_case (test_layout_x_offset_display_tab); | ||
1311 | |||
1312 | @@ -5274,6 +5688,8 @@ diagnostic_show_locus_c_tests () | ||
1313 | for_each_line_table_case (test_fixit_replace_containing_newline); | ||
1314 | for_each_line_table_case (test_fixit_deletion_affecting_newline); | ||
1315 | for_each_line_table_case (test_tab_expansion); | ||
1316 | + for_each_line_table_case (test_escaping_bytes_1); | ||
1317 | + for_each_line_table_case (test_escaping_bytes_2); | ||
1318 | |||
1319 | test_line_numbers_multiline_range (); | ||
1320 | } | ||
1321 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi | ||
1322 | --- a/gcc/doc/invoke.texi 2021-12-13 23:23:05.764437151 -0800 | ||
1323 | +++ b/gcc/doc/invoke.texi 2021-12-14 01:16:01.553943061 -0800 | ||
1324 | @@ -312,7 +312,8 @@ Objective-C and Objective-C++ Dialects}. | ||
1325 | -fdiagnostics-show-path-depths @gol | ||
1326 | -fno-show-column @gol | ||
1327 | -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol | ||
1328 | --fdiagnostics-column-origin=@var{origin}} | ||
1329 | +-fdiagnostics-column-origin=@var{origin} @gol | ||
1330 | +-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}} | ||
1331 | |||
1332 | @item Warning Options | ||
1333 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | ||
1334 | @@ -5083,6 +5084,38 @@ first column. The default value of 1 co | ||
1335 | behavior and to the GNU style guide. Some utilities may perform better with an | ||
1336 | origin of 0; any non-negative value may be specified. | ||
1337 | |||
1338 | +@item -fdiagnostics-escape-format=@var{FORMAT} | ||
1339 | +@opindex fdiagnostics-escape-format | ||
1340 | +When GCC prints pertinent source lines for a diagnostic it normally attempts | ||
1341 | +to print the source bytes directly. However, some diagnostics relate to encoding | ||
1342 | +issues in the source file, such as malformed UTF-8, or issues with Unicode | ||
1343 | +normalization. These diagnostics are flagged so that GCC will escape bytes | ||
1344 | +that are not printable ASCII when printing their pertinent source lines. | ||
1345 | + | ||
1346 | +This option controls how such bytes should be escaped. | ||
1347 | + | ||
1348 | +The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | ||
1349 | +are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | ||
1350 | +correspond to a Unicode character validly-encoded in UTF-8-encoded will be | ||
1351 | +displayed as hexadecimal in the form @samp{<XX>}. | ||
1352 | + | ||
1353 | +For example, a source line containing the string @samp{before} followed by the | ||
1354 | +Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | ||
1355 | +0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | ||
1356 | +the string @samp{after} will be printed for such a diagnostic as: | ||
1357 | + | ||
1358 | +@smallexample | ||
1359 | + before<U+03C0><BF>after | ||
1360 | +@end smallexample | ||
1361 | + | ||
1362 | +Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | ||
1363 | +in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | ||
1364 | +Unicode characters. For the example above, the following will be printed: | ||
1365 | + | ||
1366 | +@smallexample | ||
1367 | + before<CF><80><BF>after | ||
1368 | +@end smallexample | ||
1369 | + | ||
1370 | @item -fdiagnostics-format=@var{FORMAT} | ||
1371 | @opindex fdiagnostics-format | ||
1372 | Select a different format for printing diagnostics. | ||
1373 | @@ -5150,9 +5183,11 @@ might be printed in JSON form (after for | ||
1374 | @} | ||
1375 | @} | ||
1376 | ], | ||
1377 | + "escape-source": false, | ||
1378 | "message": "...this statement, but the latter is @dots{}" | ||
1379 | @} | ||
1380 | ] | ||
1381 | + "escape-source": false, | ||
1382 | "column-origin": 1, | ||
1383 | @}, | ||
1384 | @dots{} | ||
1385 | @@ -5239,6 +5274,7 @@ of the expression, which have labels. I | ||
1386 | "label": "T @{aka struct t@}" | ||
1387 | @} | ||
1388 | ], | ||
1389 | + "escape-source": false, | ||
1390 | "message": "invalid operands to binary + @dots{}" | ||
1391 | @} | ||
1392 | @end smallexample | ||
1393 | @@ -5292,6 +5328,7 @@ might be printed in JSON form as: | ||
1394 | @} | ||
1395 | @} | ||
1396 | ], | ||
1397 | + "escape-source": false, | ||
1398 | "message": "\u2018struct s\u2019 has no member named @dots{}" | ||
1399 | @} | ||
1400 | @end smallexample | ||
1401 | @@ -5349,6 +5386,10 @@ For example, the intraprocedural example | ||
1402 | ] | ||
1403 | @end smallexample | ||
1404 | |||
1405 | +Diagnostics have a boolean attribute @code{escape-source}, hinting whether | ||
1406 | +non-ASCII bytes should be escaped when printing the pertinent lines of | ||
1407 | +source code (@code{true} for diagnostics involving source encoding issues). | ||
1408 | + | ||
1409 | @end table | ||
1410 | |||
1411 | @node Warning Options | ||
1412 | diff --git a/gcc/input.c b/gcc/input.c | ||
1413 | --- a/gcc/input.c 2021-07-27 23:55:07.328287915 -0700 | ||
1414 | +++ b/gcc/input.c 2021-12-14 01:16:01.553943061 -0800 | ||
1415 | @@ -913,7 +913,8 @@ make_location (location_t caret, source_ | ||
1416 | source line in order to calculate the display width. If that cannot be done | ||
1417 | for any reason, then returns the byte column as a fallback. */ | ||
1418 | int | ||
1419 | -location_compute_display_column (expanded_location exploc, int tabstop) | ||
1420 | +location_compute_display_column (expanded_location exploc, | ||
1421 | + const cpp_char_column_policy &policy) | ||
1422 | { | ||
1423 | if (!(exploc.file && *exploc.file && exploc.line && exploc.column)) | ||
1424 | return exploc.column; | ||
1425 | @@ -921,7 +922,7 @@ location_compute_display_column (expande | ||
1426 | /* If line is NULL, this function returns exploc.column which is the | ||
1427 | desired fallback. */ | ||
1428 | return cpp_byte_column_to_display_column (line.get_buffer (), line.length (), | ||
1429 | - exploc.column, tabstop); | ||
1430 | + exploc.column, policy); | ||
1431 | } | ||
1432 | |||
1433 | /* Dump statistics to stderr about the memory usage of the line_table | ||
1434 | @@ -3611,43 +3612,50 @@ test_line_offset_overflow () | ||
1435 | void test_cpp_utf8 () | ||
1436 | { | ||
1437 | const int def_tabstop = 8; | ||
1438 | + cpp_char_column_policy policy (def_tabstop, cpp_wcwidth); | ||
1439 | + | ||
1440 | /* Verify that wcwidth of invalid UTF-8 or control bytes is 1. */ | ||
1441 | { | ||
1442 | - int w_bad = cpp_display_width ("\xf0!\x9f!\x98!\x82!", 8, def_tabstop); | ||
1443 | + int w_bad = cpp_display_width ("\xf0!\x9f!\x98!\x82!", 8, policy); | ||
1444 | ASSERT_EQ (8, w_bad); | ||
1445 | - int w_ctrl = cpp_display_width ("\r\n\v\0\1", 5, def_tabstop); | ||
1446 | + int w_ctrl = cpp_display_width ("\r\n\v\0\1", 5, policy); | ||
1447 | ASSERT_EQ (5, w_ctrl); | ||
1448 | } | ||
1449 | |||
1450 | /* Verify that wcwidth of valid UTF-8 is as expected. */ | ||
1451 | { | ||
1452 | - const int w_pi = cpp_display_width ("\xcf\x80", 2, def_tabstop); | ||
1453 | + const int w_pi = cpp_display_width ("\xcf\x80", 2, policy); | ||
1454 | ASSERT_EQ (1, w_pi); | ||
1455 | - const int w_emoji = cpp_display_width ("\xf0\x9f\x98\x82", 4, def_tabstop); | ||
1456 | + const int w_emoji = cpp_display_width ("\xf0\x9f\x98\x82", 4, policy); | ||
1457 | ASSERT_EQ (2, w_emoji); | ||
1458 | const int w_umlaut_precomposed = cpp_display_width ("\xc3\xbf", 2, | ||
1459 | - def_tabstop); | ||
1460 | + policy); | ||
1461 | ASSERT_EQ (1, w_umlaut_precomposed); | ||
1462 | const int w_umlaut_combining = cpp_display_width ("y\xcc\x88", 3, | ||
1463 | - def_tabstop); | ||
1464 | + policy); | ||
1465 | ASSERT_EQ (1, w_umlaut_combining); | ||
1466 | - const int w_han = cpp_display_width ("\xe4\xb8\xba", 3, def_tabstop); | ||
1467 | + const int w_han = cpp_display_width ("\xe4\xb8\xba", 3, policy); | ||
1468 | ASSERT_EQ (2, w_han); | ||
1469 | - const int w_ascii = cpp_display_width ("GCC", 3, def_tabstop); | ||
1470 | + const int w_ascii = cpp_display_width ("GCC", 3, policy); | ||
1471 | ASSERT_EQ (3, w_ascii); | ||
1472 | const int w_mixed = cpp_display_width ("\xcf\x80 = 3.14 \xf0\x9f\x98\x82" | ||
1473 | "\x9f! \xe4\xb8\xba y\xcc\x88", | ||
1474 | - 24, def_tabstop); | ||
1475 | + 24, policy); | ||
1476 | ASSERT_EQ (18, w_mixed); | ||
1477 | } | ||
1478 | |||
1479 | /* Verify that display width properly expands tabs. */ | ||
1480 | { | ||
1481 | const char *tstr = "\tabc\td"; | ||
1482 | - ASSERT_EQ (6, cpp_display_width (tstr, 6, 1)); | ||
1483 | - ASSERT_EQ (10, cpp_display_width (tstr, 6, 3)); | ||
1484 | - ASSERT_EQ (17, cpp_display_width (tstr, 6, 8)); | ||
1485 | - ASSERT_EQ (1, cpp_display_column_to_byte_column (tstr, 6, 7, 8)); | ||
1486 | + ASSERT_EQ (6, cpp_display_width (tstr, 6, | ||
1487 | + cpp_char_column_policy (1, cpp_wcwidth))); | ||
1488 | + ASSERT_EQ (10, cpp_display_width (tstr, 6, | ||
1489 | + cpp_char_column_policy (3, cpp_wcwidth))); | ||
1490 | + ASSERT_EQ (17, cpp_display_width (tstr, 6, | ||
1491 | + cpp_char_column_policy (8, cpp_wcwidth))); | ||
1492 | + ASSERT_EQ (1, | ||
1493 | + cpp_display_column_to_byte_column | ||
1494 | + (tstr, 6, 7, cpp_char_column_policy (8, cpp_wcwidth))); | ||
1495 | } | ||
1496 | |||
1497 | /* Verify that cpp_byte_column_to_display_column can go past the end, | ||
1498 | @@ -3660,13 +3668,13 @@ void test_cpp_utf8 () | ||
1499 | /* 111122223456 | ||
1500 | Byte columns. */ | ||
1501 | |||
1502 | - ASSERT_EQ (5, cpp_display_width (str, 6, def_tabstop)); | ||
1503 | + ASSERT_EQ (5, cpp_display_width (str, 6, policy)); | ||
1504 | ASSERT_EQ (105, | ||
1505 | - cpp_byte_column_to_display_column (str, 6, 106, def_tabstop)); | ||
1506 | + cpp_byte_column_to_display_column (str, 6, 106, policy)); | ||
1507 | ASSERT_EQ (10000, | ||
1508 | - cpp_byte_column_to_display_column (NULL, 0, 10000, def_tabstop)); | ||
1509 | + cpp_byte_column_to_display_column (NULL, 0, 10000, policy)); | ||
1510 | ASSERT_EQ (0, | ||
1511 | - cpp_byte_column_to_display_column (NULL, 10000, 0, def_tabstop)); | ||
1512 | + cpp_byte_column_to_display_column (NULL, 10000, 0, policy)); | ||
1513 | } | ||
1514 | |||
1515 | /* Verify that cpp_display_column_to_byte_column can go past the end, | ||
1516 | @@ -3680,25 +3688,25 @@ void test_cpp_utf8 () | ||
1517 | /* 000000000000000000000000000000000111111 | ||
1518 | 111122223333444456666777788889999012345 | ||
1519 | Byte columns. */ | ||
1520 | - ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 2, def_tabstop)); | ||
1521 | + ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 2, policy)); | ||
1522 | ASSERT_EQ (15, | ||
1523 | - cpp_display_column_to_byte_column (str, 15, 11, def_tabstop)); | ||
1524 | + cpp_display_column_to_byte_column (str, 15, 11, policy)); | ||
1525 | ASSERT_EQ (115, | ||
1526 | - cpp_display_column_to_byte_column (str, 15, 111, def_tabstop)); | ||
1527 | + cpp_display_column_to_byte_column (str, 15, 111, policy)); | ||
1528 | ASSERT_EQ (10000, | ||
1529 | - cpp_display_column_to_byte_column (NULL, 0, 10000, def_tabstop)); | ||
1530 | + cpp_display_column_to_byte_column (NULL, 0, 10000, policy)); | ||
1531 | ASSERT_EQ (0, | ||
1532 | - cpp_display_column_to_byte_column (NULL, 10000, 0, def_tabstop)); | ||
1533 | + cpp_display_column_to_byte_column (NULL, 10000, 0, policy)); | ||
1534 | |||
1535 | /* Verify that we do not interrupt a UTF-8 sequence. */ | ||
1536 | - ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 1, def_tabstop)); | ||
1537 | + ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 1, policy)); | ||
1538 | |||
1539 | for (int byte_col = 1; byte_col <= 15; ++byte_col) | ||
1540 | { | ||
1541 | const int disp_col | ||
1542 | - = cpp_byte_column_to_display_column (str, 15, byte_col, def_tabstop); | ||
1543 | + = cpp_byte_column_to_display_column (str, 15, byte_col, policy); | ||
1544 | const int byte_col2 | ||
1545 | - = cpp_display_column_to_byte_column (str, 15, disp_col, def_tabstop); | ||
1546 | + = cpp_display_column_to_byte_column (str, 15, disp_col, policy); | ||
1547 | |||
1548 | /* If we ask for the display column in the middle of a UTF-8 | ||
1549 | sequence, it will return the length of the partial sequence, | ||
1550 | diff --git a/gcc/input.h b/gcc/input.h | ||
1551 | --- a/gcc/input.h 2021-07-27 23:55:07.328287915 -0700 | ||
1552 | +++ b/gcc/input.h 2021-12-14 01:16:01.553943061 -0800 | ||
1553 | @@ -39,8 +39,11 @@ STATIC_ASSERT (BUILTINS_LOCATION < RESER | ||
1554 | extern bool is_location_from_builtin_token (location_t); | ||
1555 | extern expanded_location expand_location (location_t); | ||
1556 | |||
1557 | -extern int location_compute_display_column (expanded_location exploc, | ||
1558 | - int tabstop); | ||
1559 | +class cpp_char_column_policy; | ||
1560 | + | ||
1561 | +extern int | ||
1562 | +location_compute_display_column (expanded_location exploc, | ||
1563 | + const cpp_char_column_policy &policy); | ||
1564 | |||
1565 | /* A class capturing the bounds of a buffer, to allow for run-time | ||
1566 | bounds-checking in a checked build. */ | ||
1567 | diff --git a/gcc/opts.c b/gcc/opts.c | ||
1568 | --- a/gcc/opts.c 2021-07-27 23:55:07.364288417 -0700 | ||
1569 | +++ b/gcc/opts.c 2021-12-14 01:16:01.553943061 -0800 | ||
1570 | @@ -2573,6 +2573,10 @@ common_handle_option (struct gcc_options | ||
1571 | dc->column_origin = value; | ||
1572 | break; | ||
1573 | |||
1574 | + case OPT_fdiagnostics_escape_format_: | ||
1575 | + dc->escape_format = (enum diagnostics_escape_format)value; | ||
1576 | + break; | ||
1577 | + | ||
1578 | case OPT_fdiagnostics_show_cwe: | ||
1579 | dc->show_cwe = value; | ||
1580 | break; | ||
1581 | diff --git a/gcc/selftest.c b/gcc/selftest.c | ||
1582 | --- a/gcc/selftest.c 2021-07-27 23:55:07.500290315 -0700 | ||
1583 | +++ b/gcc/selftest.c 2021-12-14 01:16:01.557942991 -0800 | ||
1584 | @@ -193,6 +193,21 @@ temp_source_file::temp_source_file (cons | ||
1585 | fclose (out); | ||
1586 | } | ||
1587 | |||
1588 | +/* As above, but with a size, to allow for NUL bytes in CONTENT. */ | ||
1589 | + | ||
1590 | +temp_source_file::temp_source_file (const location &loc, | ||
1591 | + const char *suffix, | ||
1592 | + const char *content, | ||
1593 | + size_t sz) | ||
1594 | +: named_temp_file (suffix) | ||
1595 | +{ | ||
1596 | + FILE *out = fopen (get_filename (), "w"); | ||
1597 | + if (!out) | ||
1598 | + fail_formatted (loc, "unable to open tempfile: %s", get_filename ()); | ||
1599 | + fwrite (content, sz, 1, out); | ||
1600 | + fclose (out); | ||
1601 | +} | ||
1602 | + | ||
1603 | /* Avoid introducing locale-specific differences in the results | ||
1604 | by hardcoding open_quote and close_quote. */ | ||
1605 | |||
1606 | diff --git a/gcc/selftest.h b/gcc/selftest.h | ||
1607 | --- a/gcc/selftest.h 2021-07-27 23:55:07.500290315 -0700 | ||
1608 | +++ b/gcc/selftest.h 2021-12-14 01:16:01.557942991 -0800 | ||
1609 | @@ -112,6 +112,8 @@ class temp_source_file : public named_te | ||
1610 | public: | ||
1611 | temp_source_file (const location &loc, const char *suffix, | ||
1612 | const char *content); | ||
1613 | + temp_source_file (const location &loc, const char *suffix, | ||
1614 | + const char *content, size_t sz); | ||
1615 | }; | ||
1616 | |||
1617 | /* RAII-style class for avoiding introducing locale-specific differences | ||
1618 | diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c | ||
1619 | --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c 2021-07-27 23:55:07.596291654 -0700 | ||
1620 | +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c 2021-12-14 01:16:01.557942991 -0800 | ||
1621 | @@ -9,6 +9,7 @@ | ||
1622 | |||
1623 | /* { dg-regexp "\"kind\": \"error\"" } */ | ||
1624 | /* { dg-regexp "\"column-origin\": 1" } */ | ||
1625 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1626 | /* { dg-regexp "\"message\": \"#error message\"" } */ | ||
1627 | |||
1628 | /* { dg-regexp "\"caret\": \{" } */ | ||
1629 | diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c | ||
1630 | --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c 2021-07-27 23:55:07.596291654 -0700 | ||
1631 | +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c 2021-12-14 01:16:01.557942991 -0800 | ||
1632 | @@ -9,6 +9,7 @@ | ||
1633 | |||
1634 | /* { dg-regexp "\"kind\": \"warning\"" } */ | ||
1635 | /* { dg-regexp "\"column-origin\": 1" } */ | ||
1636 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1637 | /* { dg-regexp "\"message\": \"#warning message\"" } */ | ||
1638 | /* { dg-regexp "\"option\": \"-Wcpp\"" } */ | ||
1639 | /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */ | ||
1640 | diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c | ||
1641 | --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c 2021-07-27 23:55:07.596291654 -0700 | ||
1642 | +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c 2021-12-14 01:16:01.557942991 -0800 | ||
1643 | @@ -9,6 +9,7 @@ | ||
1644 | |||
1645 | /* { dg-regexp "\"kind\": \"error\"" } */ | ||
1646 | /* { dg-regexp "\"column-origin\": 1" } */ | ||
1647 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1648 | /* { dg-regexp "\"message\": \"#warning message\"" } */ | ||
1649 | /* { dg-regexp "\"option\": \"-Werror=cpp\"" } */ | ||
1650 | /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */ | ||
1651 | diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c | ||
1652 | --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c 2021-07-27 23:55:07.596291654 -0700 | ||
1653 | +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c 2021-12-14 01:16:01.557942991 -0800 | ||
1654 | @@ -19,6 +19,7 @@ int test (void) | ||
1655 | |||
1656 | /* { dg-regexp "\"kind\": \"note\"" } */ | ||
1657 | /* { dg-regexp "\"message\": \"...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'\"" } */ | ||
1658 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1659 | |||
1660 | /* { dg-regexp "\"caret\": \{" } */ | ||
1661 | /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */ | ||
1662 | @@ -39,6 +40,7 @@ int test (void) | ||
1663 | /* { dg-regexp "\"kind\": \"warning\"" } */ | ||
1664 | /* { dg-regexp "\"column-origin\": 1" } */ | ||
1665 | /* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */ | ||
1666 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1667 | /* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */ | ||
1668 | /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */ | ||
1669 | |||
1670 | diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c | ||
1671 | --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c 2021-07-27 23:55:07.596291654 -0700 | ||
1672 | +++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c 2021-12-14 01:16:01.557942991 -0800 | ||
1673 | @@ -14,6 +14,7 @@ int test (struct s *ptr) | ||
1674 | |||
1675 | /* { dg-regexp "\"kind\": \"error\"" } */ | ||
1676 | /* { dg-regexp "\"column-origin\": 1" } */ | ||
1677 | +/* { dg-regexp "\"escape-source\": false" } */ | ||
1678 | /* { dg-regexp "\"message\": \".*\"" } */ | ||
1679 | |||
1680 | /* Verify fix-it hints. */ | ||
1681 | diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c | ||
1682 | --- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c 1969-12-31 16:00:00.000000000 -0800 | ||
1683 | +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c 2021-12-14 01:16:01.557942991 -0800 | ||
1684 | @@ -0,0 +1,21 @@ | ||
1685 | +// { dg-do preprocess } | ||
1686 | +// { dg-options "-std=gnu99 -Werror=normalized=nfc -fdiagnostics-show-caret -fdiagnostics-escape-format=bytes" } | ||
1687 | +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ | ||
1688 | + | ||
1689 | +/* འ= U+0F43 TIBETAN LETTER GHA, which has decomposition "0F42 0FB7" i.e. | ||
1690 | + U+0F42 TIBETAN LETTER GA: འ| ||
1691 | + U+0FB7 TIBETAN SUBJOINED LETTER HA: ྷ | ||
1692 | + | ||
1693 | + The UTF-8 encoding of U+0F43 TIBETAN LETTER GHA is: E0 BD 83. */ | ||
1694 | + | ||
1695 | +foo before_\u0F43_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." } | ||
1696 | +/* { dg-begin-multiline-output "" } | ||
1697 | + foo before_\u0F43_after bar | ||
1698 | + ^~~~~~~~~~~~~~~~~~~ | ||
1699 | + { dg-end-multiline-output "" } */ | ||
1700 | + | ||
1701 | +foo before_à½_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." } | ||
1702 | +/* { dg-begin-multiline-output "" } | ||
1703 | + foo before_<e0><bd><83>_after bar | ||
1704 | + ^~~~~~~~~~~~~~~~~~~~~~~~~ | ||
1705 | + { dg-end-multiline-output "" } */ | ||
1706 | diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c | ||
1707 | --- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c 1969-12-31 16:00:00.000000000 -0800 | ||
1708 | +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c 2021-12-14 01:16:01.557942991 -0800 | ||
1709 | @@ -0,0 +1,19 @@ | ||
1710 | +// { dg-do preprocess } | ||
1711 | +// { dg-options "-std=gnu99 -Werror=normalized=nfc -fdiagnostics-show-caret -fdiagnostics-escape-format=unicode" } | ||
1712 | +/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ | ||
1713 | + | ||
1714 | +/* འ= U+0F43 TIBETAN LETTER GHA, which has decomposition "0F42 0FB7" i.e. | ||
1715 | + U+0F42 TIBETAN LETTER GA: འ| ||
1716 | + U+0FB7 TIBETAN SUBJOINED LETTER HA: ྷ */ | ||
1717 | + | ||
1718 | +foo before_\u0F43_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." } | ||
1719 | +/* { dg-begin-multiline-output "" } | ||
1720 | + foo before_\u0F43_after bar | ||
1721 | + ^~~~~~~~~~~~~~~~~~~ | ||
1722 | + { dg-end-multiline-output "" } */ | ||
1723 | + | ||
1724 | +foo before_à½_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." } | ||
1725 | +/* { dg-begin-multiline-output "" } | ||
1726 | + foo before_<U+0F43>_after bar | ||
1727 | + ^~~~~~~~~~~~~~~~~~~~~ | ||
1728 | + { dg-end-multiline-output "" } */ | ||
1729 | diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90 | ||
1730 | --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90 2021-07-27 23:55:08.472303878 -0700 | ||
1731 | +++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90 2021-12-14 01:16:01.557942991 -0800 | ||
1732 | @@ -9,6 +9,7 @@ | ||
1733 | |||
1734 | ! { dg-regexp "\"kind\": \"error\"" } | ||
1735 | ! { dg-regexp "\"column-origin\": 1" } | ||
1736 | +! { dg-regexp "\"escape-source\": false" } | ||
1737 | ! { dg-regexp "\"message\": \"#error message\"" } | ||
1738 | |||
1739 | ! { dg-regexp "\"caret\": \{" } | ||
1740 | diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90 | ||
1741 | --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90 2021-07-27 23:55:08.472303878 -0700 | ||
1742 | +++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90 2021-12-14 01:16:01.557942991 -0800 | ||
1743 | @@ -9,6 +9,7 @@ | ||
1744 | |||
1745 | ! { dg-regexp "\"kind\": \"warning\"" } | ||
1746 | ! { dg-regexp "\"column-origin\": 1" } | ||
1747 | +! { dg-regexp "\"escape-source\": false" } | ||
1748 | ! { dg-regexp "\"message\": \"#warning message\"" } | ||
1749 | ! { dg-regexp "\"option\": \"-Wcpp\"" } | ||
1750 | ! { dg-regexp "\"option_url\": \"\[^\n\r\"\]*#index-Wcpp\"" } | ||
1751 | diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90 | ||
1752 | --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90 2021-07-27 23:55:08.472303878 -0700 | ||
1753 | +++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90 2021-12-14 01:16:01.557942991 -0800 | ||
1754 | @@ -9,6 +9,7 @@ | ||
1755 | |||
1756 | ! { dg-regexp "\"kind\": \"error\"" } | ||
1757 | ! { dg-regexp "\"column-origin\": 1" } | ||
1758 | +! { dg-regexp "\"escape-source\": false" } | ||
1759 | ! { dg-regexp "\"message\": \"#warning message\"" } | ||
1760 | ! { dg-regexp "\"option\": \"-Werror=cpp\"" } | ||
1761 | ! { dg-regexp "\"option_url\": \"\[^\n\r\"\]*#index-Wcpp\"" } | ||
1762 | diff --git a/libcpp/charset.c b/libcpp/charset.c | ||
1763 | --- a/libcpp/charset.c 2021-07-27 23:55:08.712307227 -0700 | ||
1764 | +++ b/libcpp/charset.c 2021-12-14 01:16:01.557942991 -0800 | ||
1765 | @@ -1552,12 +1552,14 @@ convert_escape (cpp_reader *pfile, const | ||
1766 | "unknown escape sequence: '\\%c'", (int) c); | ||
1767 | else | ||
1768 | { | ||
1769 | + encoding_rich_location rich_loc (pfile); | ||
1770 | + | ||
1771 | /* diagnostic.c does not support "%03o". When it does, this | ||
1772 | code can use %03o directly in the diagnostic again. */ | ||
1773 | char buf[32]; | ||
1774 | sprintf(buf, "%03o", (int) c); | ||
1775 | - cpp_error (pfile, CPP_DL_PEDWARN, | ||
1776 | - "unknown escape sequence: '\\%s'", buf); | ||
1777 | + cpp_error_at (pfile, CPP_DL_PEDWARN, &rich_loc, | ||
1778 | + "unknown escape sequence: '\\%s'", buf); | ||
1779 | } | ||
1780 | } | ||
1781 | |||
1782 | @@ -2280,14 +2282,16 @@ cpp_string_location_reader::get_next () | ||
1783 | } | ||
1784 | |||
1785 | cpp_display_width_computation:: | ||
1786 | -cpp_display_width_computation (const char *data, int data_length, int tabstop) : | ||
1787 | +cpp_display_width_computation (const char *data, int data_length, | ||
1788 | + const cpp_char_column_policy &policy) : | ||
1789 | m_begin (data), | ||
1790 | m_next (m_begin), | ||
1791 | m_bytes_left (data_length), | ||
1792 | - m_tabstop (tabstop), | ||
1793 | + m_policy (policy), | ||
1794 | m_display_cols (0) | ||
1795 | { | ||
1796 | - gcc_assert (m_tabstop > 0); | ||
1797 | + gcc_assert (policy.m_tabstop > 0); | ||
1798 | + gcc_assert (policy.m_width_cb); | ||
1799 | } | ||
1800 | |||
1801 | |||
1802 | @@ -2299,19 +2303,28 @@ cpp_display_width_computation (const cha | ||
1803 | point to a valid UTF-8-encoded sequence, then it will be treated as a single | ||
1804 | byte with display width 1. m_cur_display_col is the current display column, | ||
1805 | relative to which tab stops should be expanded. Returns the display width of | ||
1806 | - the codepoint just processed. */ | ||
1807 | + the codepoint just processed. | ||
1808 | + If OUT is non-NULL, it is populated. */ | ||
1809 | |||
1810 | int | ||
1811 | -cpp_display_width_computation::process_next_codepoint () | ||
1812 | +cpp_display_width_computation::process_next_codepoint (cpp_decoded_char *out) | ||
1813 | { | ||
1814 | cppchar_t c; | ||
1815 | int next_width; | ||
1816 | |||
1817 | + if (out) | ||
1818 | + out->m_start_byte = m_next; | ||
1819 | + | ||
1820 | if (*m_next == '\t') | ||
1821 | { | ||
1822 | ++m_next; | ||
1823 | --m_bytes_left; | ||
1824 | - next_width = m_tabstop - (m_display_cols % m_tabstop); | ||
1825 | + next_width = m_policy.m_tabstop - (m_display_cols % m_policy.m_tabstop); | ||
1826 | + if (out) | ||
1827 | + { | ||
1828 | + out->m_ch = '\t'; | ||
1829 | + out->m_valid_ch = true; | ||
1830 | + } | ||
1831 | } | ||
1832 | else if (one_utf8_to_cppchar ((const uchar **) &m_next, &m_bytes_left, &c) | ||
1833 | != 0) | ||
1834 | @@ -2321,14 +2334,24 @@ cpp_display_width_computation::process_n | ||
1835 | of one. */ | ||
1836 | ++m_next; | ||
1837 | --m_bytes_left; | ||
1838 | - next_width = 1; | ||
1839 | + next_width = m_policy.m_undecoded_byte_width; | ||
1840 | + if (out) | ||
1841 | + out->m_valid_ch = false; | ||
1842 | } | ||
1843 | else | ||
1844 | { | ||
1845 | /* one_utf8_to_cppchar() has updated m_next and m_bytes_left for us. */ | ||
1846 | - next_width = cpp_wcwidth (c); | ||
1847 | + next_width = m_policy.m_width_cb (c); | ||
1848 | + if (out) | ||
1849 | + { | ||
1850 | + out->m_ch = c; | ||
1851 | + out->m_valid_ch = true; | ||
1852 | + } | ||
1853 | } | ||
1854 | |||
1855 | + if (out) | ||
1856 | + out->m_next_byte = m_next; | ||
1857 | + | ||
1858 | m_display_cols += next_width; | ||
1859 | return next_width; | ||
1860 | } | ||
1861 | @@ -2344,7 +2367,7 @@ cpp_display_width_computation::advance_d | ||
1862 | const int start = m_display_cols; | ||
1863 | const int target = start + n; | ||
1864 | while (m_display_cols < target && !done ()) | ||
1865 | - process_next_codepoint (); | ||
1866 | + process_next_codepoint (NULL); | ||
1867 | return m_display_cols - start; | ||
1868 | } | ||
1869 | |||
1870 | @@ -2352,29 +2375,33 @@ cpp_display_width_computation::advance_d | ||
1871 | how many display columns are occupied by the first COLUMN bytes. COLUMN | ||
1872 | may exceed DATA_LENGTH, in which case the phantom bytes at the end are | ||
1873 | treated as if they have display width 1. Tabs are expanded to the next tab | ||
1874 | - stop, relative to the start of DATA. */ | ||
1875 | + stop, relative to the start of DATA, and non-printable-ASCII characters | ||
1876 | + will be escaped as per POLICY. */ | ||
1877 | |||
1878 | int | ||
1879 | cpp_byte_column_to_display_column (const char *data, int data_length, | ||
1880 | - int column, int tabstop) | ||
1881 | + int column, | ||
1882 | + const cpp_char_column_policy &policy) | ||
1883 | { | ||
1884 | const int offset = MAX (0, column - data_length); | ||
1885 | - cpp_display_width_computation dw (data, column - offset, tabstop); | ||
1886 | + cpp_display_width_computation dw (data, column - offset, policy); | ||
1887 | while (!dw.done ()) | ||
1888 | - dw.process_next_codepoint (); | ||
1889 | + dw.process_next_codepoint (NULL); | ||
1890 | return dw.display_cols_processed () + offset; | ||
1891 | } | ||
1892 | |||
1893 | /* For the string of length DATA_LENGTH bytes that begins at DATA, compute | ||
1894 | the least number of bytes that will result in at least DISPLAY_COL display | ||
1895 | columns. The return value may exceed DATA_LENGTH if the entire string does | ||
1896 | - not occupy enough display columns. */ | ||
1897 | + not occupy enough display columns. Non-printable-ASCII characters | ||
1898 | + will be escaped as per POLICY. */ | ||
1899 | |||
1900 | int | ||
1901 | cpp_display_column_to_byte_column (const char *data, int data_length, | ||
1902 | - int display_col, int tabstop) | ||
1903 | + int display_col, | ||
1904 | + const cpp_char_column_policy &policy) | ||
1905 | { | ||
1906 | - cpp_display_width_computation dw (data, data_length, tabstop); | ||
1907 | + cpp_display_width_computation dw (data, data_length, policy); | ||
1908 | const int avail_display = dw.advance_display_cols (display_col); | ||
1909 | return dw.bytes_processed () + MAX (0, display_col - avail_display); | ||
1910 | } | ||
1911 | diff --git a/libcpp/errors.c b/libcpp/errors.c | ||
1912 | --- a/libcpp/errors.c 2021-07-27 23:55:08.712307227 -0700 | ||
1913 | +++ b/libcpp/errors.c 2021-12-14 01:16:01.557942991 -0800 | ||
1914 | @@ -27,6 +27,31 @@ along with this program; see the file CO | ||
1915 | #include "cpplib.h" | ||
1916 | #include "internal.h" | ||
1917 | |||
1918 | +/* Get a location_t for the current location in PFILE, | ||
1919 | + generally that of the previously lexed token. */ | ||
1920 | + | ||
1921 | +location_t | ||
1922 | +cpp_diagnostic_get_current_location (cpp_reader *pfile) | ||
1923 | +{ | ||
1924 | + if (CPP_OPTION (pfile, traditional)) | ||
1925 | + { | ||
1926 | + if (pfile->state.in_directive) | ||
1927 | + return pfile->directive_line; | ||
1928 | + else | ||
1929 | + return pfile->line_table->highest_line; | ||
1930 | + } | ||
1931 | + /* We don't want to refer to a token before the beginning of the | ||
1932 | + current run -- that is invalid. */ | ||
1933 | + else if (pfile->cur_token == pfile->cur_run->base) | ||
1934 | + { | ||
1935 | + return 0; | ||
1936 | + } | ||
1937 | + else | ||
1938 | + { | ||
1939 | + return pfile->cur_token[-1].src_loc; | ||
1940 | + } | ||
1941 | +} | ||
1942 | + | ||
1943 | /* Print a diagnostic at the given location. */ | ||
1944 | |||
1945 | ATTRIBUTE_FPTR_PRINTF(5,0) | ||
1946 | @@ -52,25 +77,7 @@ cpp_diagnostic (cpp_reader * pfile, enum | ||
1947 | enum cpp_warning_reason reason, | ||
1948 | const char *msgid, va_list *ap) | ||
1949 | { | ||
1950 | - location_t src_loc; | ||
1951 | - | ||
1952 | - if (CPP_OPTION (pfile, traditional)) | ||
1953 | - { | ||
1954 | - if (pfile->state.in_directive) | ||
1955 | - src_loc = pfile->directive_line; | ||
1956 | - else | ||
1957 | - src_loc = pfile->line_table->highest_line; | ||
1958 | - } | ||
1959 | - /* We don't want to refer to a token before the beginning of the | ||
1960 | - current run -- that is invalid. */ | ||
1961 | - else if (pfile->cur_token == pfile->cur_run->base) | ||
1962 | - { | ||
1963 | - src_loc = 0; | ||
1964 | - } | ||
1965 | - else | ||
1966 | - { | ||
1967 | - src_loc = pfile->cur_token[-1].src_loc; | ||
1968 | - } | ||
1969 | + location_t src_loc = cpp_diagnostic_get_current_location (pfile); | ||
1970 | rich_location richloc (pfile->line_table, src_loc); | ||
1971 | return cpp_diagnostic_at (pfile, level, reason, &richloc, msgid, ap); | ||
1972 | } | ||
1973 | @@ -142,6 +149,43 @@ cpp_warning_syshdr (cpp_reader * pfile, | ||
1974 | |||
1975 | va_end (ap); | ||
1976 | return ret; | ||
1977 | +} | ||
1978 | + | ||
1979 | +/* As cpp_warning above, but use RICHLOC as the location of the diagnostic. */ | ||
1980 | + | ||
1981 | +bool cpp_warning_at (cpp_reader *pfile, enum cpp_warning_reason reason, | ||
1982 | + rich_location *richloc, const char *msgid, ...) | ||
1983 | +{ | ||
1984 | + va_list ap; | ||
1985 | + bool ret; | ||
1986 | + | ||
1987 | + va_start (ap, msgid); | ||
1988 | + | ||
1989 | + ret = cpp_diagnostic_at (pfile, CPP_DL_WARNING, reason, richloc, | ||
1990 | + msgid, &ap); | ||
1991 | + | ||
1992 | + va_end (ap); | ||
1993 | + return ret; | ||
1994 | + | ||
1995 | +} | ||
1996 | + | ||
1997 | +/* As cpp_pedwarning above, but use RICHLOC as the location of the | ||
1998 | + diagnostic. */ | ||
1999 | + | ||
2000 | +bool | ||
2001 | +cpp_pedwarning_at (cpp_reader * pfile, enum cpp_warning_reason reason, | ||
2002 | + rich_location *richloc, const char *msgid, ...) | ||
2003 | +{ | ||
2004 | + va_list ap; | ||
2005 | + bool ret; | ||
2006 | + | ||
2007 | + va_start (ap, msgid); | ||
2008 | + | ||
2009 | + ret = cpp_diagnostic_at (pfile, CPP_DL_PEDWARN, reason, richloc, | ||
2010 | + msgid, &ap); | ||
2011 | + | ||
2012 | + va_end (ap); | ||
2013 | + return ret; | ||
2014 | } | ||
2015 | |||
2016 | /* Print a diagnostic at a specific location. */ | ||
2017 | diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h | ||
2018 | --- a/libcpp/include/cpplib.h 2021-12-13 23:23:05.768437079 -0800 | ||
2019 | +++ b/libcpp/include/cpplib.h 2021-12-14 01:20:16.189507386 -0800 | ||
2020 | @@ -1275,6 +1275,14 @@ extern bool cpp_warning_syshdr (cpp_read | ||
2021 | const char *msgid, ...) | ||
2022 | ATTRIBUTE_PRINTF_3; | ||
2023 | |||
2024 | +/* As their counterparts above, but use RICHLOC. */ | ||
2025 | +extern bool cpp_warning_at (cpp_reader *, enum cpp_warning_reason, | ||
2026 | + rich_location *richloc, const char *msgid, ...) | ||
2027 | + ATTRIBUTE_PRINTF_4; | ||
2028 | +extern bool cpp_pedwarning_at (cpp_reader *, enum cpp_warning_reason, | ||
2029 | + rich_location *richloc, const char *msgid, ...) | ||
2030 | + ATTRIBUTE_PRINTF_4; | ||
2031 | + | ||
2032 | /* Output a diagnostic with "MSGID: " preceding the | ||
2033 | error string of errno. No location is printed. */ | ||
2034 | extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level, | ||
2035 | @@ -1435,42 +1443,95 @@ extern const char * cpp_get_userdef_suff | ||
2036 | |||
2037 | /* In charset.c */ | ||
2038 | |||
2039 | +/* The result of attempting to decode a run of UTF-8 bytes. */ | ||
2040 | + | ||
2041 | +struct cpp_decoded_char | ||
2042 | +{ | ||
2043 | + const char *m_start_byte; | ||
2044 | + const char *m_next_byte; | ||
2045 | + | ||
2046 | + bool m_valid_ch; | ||
2047 | + cppchar_t m_ch; | ||
2048 | +}; | ||
2049 | + | ||
2050 | +/* Information for mapping between code points and display columns. | ||
2051 | + | ||
2052 | + This is a tabstop value, along with a callback for getting the | ||
2053 | + widths of characters. Normally this callback is cpp_wcwidth, but we | ||
2054 | + support other schemes for escaping non-ASCII unicode as a series of | ||
2055 | + ASCII chars when printing the user's source code in diagnostic-show-locus.c | ||
2056 | + | ||
2057 | + For example, consider: | ||
2058 | + - the Unicode character U+03C0 "GREEK SMALL LETTER PI" (UTF-8: 0xCF 0x80) | ||
2059 | + - the Unicode character U+1F642 "SLIGHTLY SMILING FACE" | ||
2060 | + (UTF-8: 0xF0 0x9F 0x99 0x82) | ||
2061 | + - the byte 0xBF (a stray trailing byte of a UTF-8 character) | ||
2062 | + Normally U+03C0 would occupy one display column, U+1F642 | ||
2063 | + would occupy two display columns, and the stray byte would be | ||
2064 | + printed verbatim as one display column. | ||
2065 | + | ||
2066 | + However when escaping them as unicode code points as "<U+03C0>" | ||
2067 | + and "<U+1F642>" they occupy 8 and 9 display columns respectively, | ||
2068 | + and when escaping them as bytes as "<CF><80>" and "<F0><9F><99><82>" | ||
2069 | + they occupy 8 and 16 display columns respectively. In both cases | ||
2070 | + the stray byte is escaped to <BF> as 4 display columns. */ | ||
2071 | + | ||
2072 | +struct cpp_char_column_policy | ||
2073 | +{ | ||
2074 | + cpp_char_column_policy (int tabstop, | ||
2075 | + int (*width_cb) (cppchar_t c)) | ||
2076 | + : m_tabstop (tabstop), | ||
2077 | + m_undecoded_byte_width (1), | ||
2078 | + m_width_cb (width_cb) | ||
2079 | + {} | ||
2080 | + | ||
2081 | + int m_tabstop; | ||
2082 | + /* Width in display columns of a stray byte that isn't decodable | ||
2083 | + as UTF-8. */ | ||
2084 | + int m_undecoded_byte_width; | ||
2085 | + int (*m_width_cb) (cppchar_t c); | ||
2086 | +}; | ||
2087 | + | ||
2088 | /* A class to manage the state while converting a UTF-8 sequence to cppchar_t | ||
2089 | and computing the display width one character at a time. */ | ||
2090 | class cpp_display_width_computation { | ||
2091 | public: | ||
2092 | cpp_display_width_computation (const char *data, int data_length, | ||
2093 | - int tabstop); | ||
2094 | + const cpp_char_column_policy &policy); | ||
2095 | const char *next_byte () const { return m_next; } | ||
2096 | int bytes_processed () const { return m_next - m_begin; } | ||
2097 | int bytes_left () const { return m_bytes_left; } | ||
2098 | bool done () const { return !bytes_left (); } | ||
2099 | int display_cols_processed () const { return m_display_cols; } | ||
2100 | |||
2101 | - int process_next_codepoint (); | ||
2102 | + int process_next_codepoint (cpp_decoded_char *out); | ||
2103 | int advance_display_cols (int n); | ||
2104 | |||
2105 | private: | ||
2106 | const char *const m_begin; | ||
2107 | const char *m_next; | ||
2108 | size_t m_bytes_left; | ||
2109 | - const int m_tabstop; | ||
2110 | + const cpp_char_column_policy &m_policy; | ||
2111 | int m_display_cols; | ||
2112 | }; | ||
2113 | |||
2114 | /* Convenience functions that are simple use cases for class | ||
2115 | cpp_display_width_computation. Tab characters will be expanded to spaces | ||
2116 | - as determined by TABSTOP. */ | ||
2117 | + as determined by POLICY.m_tabstop, and non-printable-ASCII characters | ||
2118 | + will be escaped as per POLICY. */ | ||
2119 | + | ||
2120 | int cpp_byte_column_to_display_column (const char *data, int data_length, | ||
2121 | - int column, int tabstop); | ||
2122 | + int column, | ||
2123 | + const cpp_char_column_policy &policy); | ||
2124 | inline int cpp_display_width (const char *data, int data_length, | ||
2125 | - int tabstop) | ||
2126 | + const cpp_char_column_policy &policy) | ||
2127 | { | ||
2128 | return cpp_byte_column_to_display_column (data, data_length, data_length, | ||
2129 | - tabstop); | ||
2130 | + policy); | ||
2131 | } | ||
2132 | int cpp_display_column_to_byte_column (const char *data, int data_length, | ||
2133 | - int display_col, int tabstop); | ||
2134 | + int display_col, | ||
2135 | + const cpp_char_column_policy &policy); | ||
2136 | int cpp_wcwidth (cppchar_t c); | ||
2137 | |||
2138 | #endif /* ! LIBCPP_CPPLIB_H */ | ||
2139 | diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h | ||
2140 | --- a/libcpp/include/line-map.h 2021-07-27 23:55:08.716307283 -0700 | ||
2141 | +++ b/libcpp/include/line-map.h 2021-12-14 01:16:01.557942991 -0800 | ||
2142 | @@ -1781,6 +1781,18 @@ class rich_location | ||
2143 | const diagnostic_path *get_path () const { return m_path; } | ||
2144 | void set_path (const diagnostic_path *path) { m_path = path; } | ||
2145 | |||
2146 | + /* A flag for hinting that the diagnostic involves character encoding | ||
2147 | + issues, and thus that it will be helpful to the user if we show some | ||
2148 | + representation of how the characters in the pertinent source lines | ||
2149 | + are encoded. | ||
2150 | + The default is false (i.e. do not escape). | ||
2151 | + When set to true, non-ASCII bytes in the pertinent source lines will | ||
2152 | + be escaped in a manner controlled by the user-supplied option | ||
2153 | + -fdiagnostics-escape-format=, so that the user can better understand | ||
2154 | + what's going on with the encoding in their source file. */ | ||
2155 | + bool escape_on_output_p () const { return m_escape_on_output; } | ||
2156 | + void set_escape_on_output (bool flag) { m_escape_on_output = flag; } | ||
2157 | + | ||
2158 | private: | ||
2159 | bool reject_impossible_fixit (location_t where); | ||
2160 | void stop_supporting_fixits (); | ||
2161 | @@ -1807,6 +1819,7 @@ protected: | ||
2162 | bool m_fixits_cannot_be_auto_applied; | ||
2163 | |||
2164 | const diagnostic_path *m_path; | ||
2165 | + bool m_escape_on_output; | ||
2166 | }; | ||
2167 | |||
2168 | /* A struct for the result of range_label::get_text: a NUL-terminated buffer | ||
2169 | diff --git a/libcpp/internal.h b/libcpp/internal.h | ||
2170 | --- a/libcpp/internal.h 2021-12-13 23:23:05.768437079 -0800 | ||
2171 | +++ b/libcpp/internal.h 2021-12-14 01:16:01.557942991 -0800 | ||
2172 | @@ -776,6 +776,9 @@ extern void _cpp_do_file_change (cpp_rea | ||
2173 | extern void _cpp_pop_buffer (cpp_reader *); | ||
2174 | extern char *_cpp_bracket_include (cpp_reader *); | ||
2175 | |||
2176 | +/* In errors.c */ | ||
2177 | +extern location_t cpp_diagnostic_get_current_location (cpp_reader *); | ||
2178 | + | ||
2179 | /* In traditional.c. */ | ||
2180 | extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *, bool); | ||
2181 | extern bool _cpp_read_logical_line_trad (cpp_reader *); | ||
2182 | @@ -942,6 +945,26 @@ int linemap_get_expansion_line (class li | ||
2183 | const char* linemap_get_expansion_filename (class line_maps *, | ||
2184 | location_t); | ||
2185 | |||
2186 | +/* A subclass of rich_location for emitting a diagnostic | ||
2187 | + at the current location of the reader, but flagging | ||
2188 | + it with set_escape_on_output (true). */ | ||
2189 | +class encoding_rich_location : public rich_location | ||
2190 | +{ | ||
2191 | + public: | ||
2192 | + encoding_rich_location (cpp_reader *pfile) | ||
2193 | + : rich_location (pfile->line_table, | ||
2194 | + cpp_diagnostic_get_current_location (pfile)) | ||
2195 | + { | ||
2196 | + set_escape_on_output (true); | ||
2197 | + } | ||
2198 | + | ||
2199 | + encoding_rich_location (cpp_reader *pfile, location_t loc) | ||
2200 | + : rich_location (pfile->line_table, loc) | ||
2201 | + { | ||
2202 | + set_escape_on_output (true); | ||
2203 | + } | ||
2204 | +}; | ||
2205 | + | ||
2206 | #ifdef __cplusplus | ||
2207 | } | ||
2208 | #endif | ||
2209 | diff --git a/libcpp/lex.c b/libcpp/lex.c | ||
2210 | --- a/libcpp/lex.c 2021-12-14 01:14:48.435225968 -0800 | ||
2211 | +++ b/libcpp/lex.c 2021-12-14 01:24:37.220995816 -0800 | ||
2212 | @@ -1774,7 +1774,11 @@ skip_whitespace (cpp_reader *pfile, cppc | ||
2213 | while (is_nvspace (c)); | ||
2214 | |||
2215 | if (saw_NUL) | ||
2216 | - cpp_error (pfile, CPP_DL_WARNING, "null character(s) ignored"); | ||
2217 | + { | ||
2218 | + encoding_rich_location rich_loc (pfile); | ||
2219 | + cpp_error_at (pfile, CPP_DL_WARNING, &rich_loc, | ||
2220 | + "null character(s) ignored"); | ||
2221 | + } | ||
2222 | |||
2223 | buffer->cur--; | ||
2224 | } | ||
2225 | @@ -1803,6 +1807,28 @@ warn_about_normalization (cpp_reader *pf | ||
2226 | if (CPP_OPTION (pfile, warn_normalize) < NORMALIZE_STATE_RESULT (s) | ||
2227 | && !pfile->state.skipping) | ||
2228 | { | ||
2229 | + location_t loc = token->src_loc; | ||
2230 | + | ||
2231 | + /* If possible, create a location range for the token. */ | ||
2232 | + if (loc >= RESERVED_LOCATION_COUNT | ||
2233 | + && token->type != CPP_EOF | ||
2234 | + /* There must be no line notes to process. */ | ||
2235 | + && (!(pfile->buffer->cur | ||
2236 | + >= pfile->buffer->notes[pfile->buffer->cur_note].pos | ||
2237 | + && !pfile->overlaid_buffer))) | ||
2238 | + { | ||
2239 | + source_range tok_range; | ||
2240 | + tok_range.m_start = loc; | ||
2241 | + tok_range.m_finish | ||
2242 | + = linemap_position_for_column (pfile->line_table, | ||
2243 | + CPP_BUF_COLUMN (pfile->buffer, | ||
2244 | + pfile->buffer->cur)); | ||
2245 | + loc = COMBINE_LOCATION_DATA (pfile->line_table, | ||
2246 | + loc, tok_range, NULL); | ||
2247 | + } | ||
2248 | + | ||
2249 | + encoding_rich_location rich_loc (pfile, loc); | ||
2250 | + | ||
2251 | /* Make sure that the token is printed using UCNs, even | ||
2252 | if we'd otherwise happily print UTF-8. */ | ||
2253 | unsigned char *buf = XNEWVEC (unsigned char, cpp_token_len (token)); | ||
2254 | @@ -1810,11 +1836,11 @@ warn_about_normalization (cpp_reader *pf | ||
2255 | |||
2256 | sz = cpp_spell_token (pfile, token, buf, false) - buf; | ||
2257 | if (NORMALIZE_STATE_RESULT (s) == normalized_C) | ||
2258 | - cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, | ||
2259 | - "`%.*s' is not in NFKC", (int) sz, buf); | ||
2260 | + cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc, | ||
2261 | + "`%.*s' is not in NFKC", (int) sz, buf); | ||
2262 | else | ||
2263 | - cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, | ||
2264 | - "`%.*s' is not in NFC", (int) sz, buf); | ||
2265 | + cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc, | ||
2266 | + "`%.*s' is not in NFC", (int) sz, buf); | ||
2267 | free (buf); | ||
2268 | } | ||
2269 | } | ||
2270 | diff --git a/libcpp/line-map.c b/libcpp/line-map.c | ||
2271 | --- a/libcpp/line-map.c 2021-07-27 23:55:08.716307283 -0700 | ||
2272 | +++ b/libcpp/line-map.c 2021-12-14 01:16:01.561942921 -0800 | ||
2273 | @@ -2086,7 +2086,8 @@ rich_location::rich_location (line_maps | ||
2274 | m_fixit_hints (), | ||
2275 | m_seen_impossible_fixit (false), | ||
2276 | m_fixits_cannot_be_auto_applied (false), | ||
2277 | - m_path (NULL) | ||
2278 | + m_path (NULL), | ||
2279 | + m_escape_on_output (false) | ||
2280 | { | ||
2281 | add_range (loc, SHOW_RANGE_WITH_CARET, label); | ||
2282 | } | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-46195.patch b/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-46195.patch deleted file mode 100644 index 7b3651c73e..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0001-CVE-2021-46195.patch +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | From f10bec5ffa487ad3033ed5f38cfd0fc7d696deab Mon Sep 17 00:00:00 2001 | ||
2 | From: Nick Clifton <nickc@redhat.com> | ||
3 | Date: Mon, 31 Jan 2022 14:28:42 +0000 | ||
4 | Subject: [PATCH] libiberty: Fix infinite recursion in rust demangler. | ||
5 | |||
6 | libiberty/ | ||
7 | PR demangler/98886 | ||
8 | PR demangler/99935 | ||
9 | * rust-demangle.c (struct rust_demangler): Add a recursion | ||
10 | counter. | ||
11 | (demangle_path): Increment/decrement the recursion counter upon | ||
12 | entry and exit. Fail if the counter exceeds a fixed limit. | ||
13 | (demangle_type): Likewise. | ||
14 | (rust_demangle_callback): Initialise the recursion counter, | ||
15 | disabling if requested by the option flags. | ||
16 | |||
17 | CVE: CVE-2021-46195 | ||
18 | Upstream-Status: Backport | ||
19 | [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=f10bec5ffa487ad3033ed5f38cfd0fc7d696deab] | ||
20 | Signed-off-by: Pgowda <pgowda.cve@gmail.com> | ||
21 | --- | ||
22 | libiberty/rust-demangle.c | 47 ++++++++++++++++++++++++++++++++++----- | ||
23 | 1 file changed, 41 insertions(+), 6 deletions(-) | ||
24 | |||
25 | diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c | ||
26 | index 18c760491bd..3b24d63892a 100644 | ||
27 | --- a/libiberty/rust-demangle.c | ||
28 | +++ b/libiberty/rust-demangle.c | ||
29 | @@ -74,6 +74,12 @@ struct rust_demangler | ||
30 | /* Rust mangling version, with legacy mangling being -1. */ | ||
31 | int version; | ||
32 | |||
33 | + /* Recursion depth. */ | ||
34 | + unsigned int recursion; | ||
35 | + /* Maximum number of times demangle_path may be called recursively. */ | ||
36 | +#define RUST_MAX_RECURSION_COUNT 1024 | ||
37 | +#define RUST_NO_RECURSION_LIMIT ((unsigned int) -1) | ||
38 | + | ||
39 | uint64_t bound_lifetime_depth; | ||
40 | }; | ||
41 | |||
42 | @@ -671,6 +677,15 @@ demangle_path (struct rust_demangler *rdm, int in_value) | ||
43 | if (rdm->errored) | ||
44 | return; | ||
45 | |||
46 | + if (rdm->recursion != RUST_NO_RECURSION_LIMIT) | ||
47 | + { | ||
48 | + ++ rdm->recursion; | ||
49 | + if (rdm->recursion > RUST_MAX_RECURSION_COUNT) | ||
50 | + /* FIXME: There ought to be a way to report | ||
51 | + that the recursion limit has been reached. */ | ||
52 | + goto fail_return; | ||
53 | + } | ||
54 | + | ||
55 | switch (tag = next (rdm)) | ||
56 | { | ||
57 | case 'C': | ||
58 | @@ -688,10 +703,7 @@ demangle_path (struct rust_demangler *rdm, int in_value) | ||
59 | case 'N': | ||
60 | ns = next (rdm); | ||
61 | if (!ISLOWER (ns) && !ISUPPER (ns)) | ||
62 | - { | ||
63 | - rdm->errored = 1; | ||
64 | - return; | ||
65 | - } | ||
66 | + goto fail_return; | ||
67 | |||
68 | demangle_path (rdm, in_value); | ||
69 | |||
70 | @@ -776,9 +788,15 @@ demangle_path (struct rust_demangler *rdm, int in_value) | ||
71 | } | ||
72 | break; | ||
73 | default: | ||
74 | - rdm->errored = 1; | ||
75 | - return; | ||
76 | + goto fail_return; | ||
77 | } | ||
78 | + goto pass_return; | ||
79 | + | ||
80 | + fail_return: | ||
81 | + rdm->errored = 1; | ||
82 | + pass_return: | ||
83 | + if (rdm->recursion != RUST_NO_RECURSION_LIMIT) | ||
84 | + -- rdm->recursion; | ||
85 | } | ||
86 | |||
87 | static void | ||
88 | @@ -870,6 +888,19 @@ demangle_type (struct rust_demangler *rdm) | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | + if (rdm->recursion != RUST_NO_RECURSION_LIMIT) | ||
93 | + { | ||
94 | + ++ rdm->recursion; | ||
95 | + if (rdm->recursion > RUST_MAX_RECURSION_COUNT) | ||
96 | + /* FIXME: There ought to be a way to report | ||
97 | + that the recursion limit has been reached. */ | ||
98 | + { | ||
99 | + rdm->errored = 1; | ||
100 | + -- rdm->recursion; | ||
101 | + return; | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
105 | switch (tag) | ||
106 | { | ||
107 | case 'R': | ||
108 | @@ -1030,6 +1061,9 @@ demangle_type (struct rust_demangler *rdm) | ||
109 | rdm->next--; | ||
110 | demangle_path (rdm, 0); | ||
111 | } | ||
112 | + | ||
113 | + if (rdm->recursion != RUST_NO_RECURSION_LIMIT) | ||
114 | + -- rdm->recursion; | ||
115 | } | ||
116 | |||
117 | /* A trait in a trait object may have some "existential projections" | ||
118 | @@ -1320,6 +1354,7 @@ rust_demangle_callback (const char *mangled, int options, | ||
119 | rdm.skipping_printing = 0; | ||
120 | rdm.verbose = (options & DMGL_VERBOSE) != 0; | ||
121 | rdm.version = 0; | ||
122 | + rdm.recursion = (options & DMGL_NO_RECURSE_LIMIT) ? RUST_NO_RECURSION_LIMIT : 0; | ||
123 | rdm.bound_lifetime_depth = 0; | ||
124 | |||
125 | /* Rust symbols always start with _R (v0) or _ZN (legacy). */ | ||
126 | -- | ||
127 | 2.27.0 | ||
128 | |||
diff --git a/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch index 0bf8834bb2..66e582ca98 100644 --- a/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch +++ b/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 6badb97389cae4ff9a533d38dc7cceefe21b97a8 Mon Sep 17 00:00:00 2001 | 1 | From 31f94ef5b43a984a98f0eebd2dcf1b53aa1d7bce Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 08:37:11 +0400 | 3 | Date: Fri, 29 Mar 2013 08:37:11 +0400 |
4 | Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET | 4 | Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET |
@@ -12,10 +12,10 @@ Upstream-Status: Inappropriate [embedded specific] | |||
12 | 2 files changed, 2 insertions(+), 2 deletions(-) | 12 | 2 files changed, 2 insertions(+), 2 deletions(-) |
13 | 13 | ||
14 | diff --git a/configure b/configure | 14 | diff --git a/configure b/configure |
15 | index e218a19e333..45744e6e471 100755 | 15 | index 5dcaab14ae9..f76310a36bb 100755 |
16 | --- a/configure | 16 | --- a/configure |
17 | +++ b/configure | 17 | +++ b/configure |
18 | @@ -9750,7 +9750,7 @@ fi | 18 | @@ -10165,7 +10165,7 @@ fi |
19 | # for target_alias and gcc doesn't manage it consistently. | 19 | # for target_alias and gcc doesn't manage it consistently. |
20 | target_configargs="--cache-file=./config.cache ${target_configargs}" | 20 | target_configargs="--cache-file=./config.cache ${target_configargs}" |
21 | 21 | ||
@@ -25,10 +25,10 @@ index e218a19e333..45744e6e471 100755 | |||
25 | *" newlib "*) | 25 | *" newlib "*) |
26 | case " $target_configargs " in | 26 | case " $target_configargs " in |
27 | diff --git a/configure.ac b/configure.ac | 27 | diff --git a/configure.ac b/configure.ac |
28 | index 7e8e628b325..bf66b51373c 100644 | 28 | index 85977482aee..8b9097c7a45 100644 |
29 | --- a/configure.ac | 29 | --- a/configure.ac |
30 | +++ b/configure.ac | 30 | +++ b/configure.ac |
31 | @@ -3255,7 +3255,7 @@ fi | 31 | @@ -3346,7 +3346,7 @@ fi |
32 | # for target_alias and gcc doesn't manage it consistently. | 32 | # for target_alias and gcc doesn't manage it consistently. |
33 | target_configargs="--cache-file=./config.cache ${target_configargs}" | 33 | target_configargs="--cache-file=./config.cache ${target_configargs}" |
34 | 34 | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0002-CVE-2021-42574.patch b/meta/recipes-devtools/gcc/gcc/0002-CVE-2021-42574.patch deleted file mode 100644 index 9bad81d4d0..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0002-CVE-2021-42574.patch +++ /dev/null | |||
@@ -1,1765 +0,0 @@ | |||
1 | From 51c500269bf53749b107807d84271385fad35628 Mon Sep 17 00:00:00 2001 | ||
2 | From: Marek Polacek <polacek@redhat.com> | ||
3 | Date: Wed, 6 Oct 2021 14:33:59 -0400 | ||
4 | Subject: [PATCH] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026] | ||
5 | |||
6 | From a link below: | ||
7 | "An issue was discovered in the Bidirectional Algorithm in the Unicode | ||
8 | Specification through 14.0. It permits the visual reordering of | ||
9 | characters via control sequences, which can be used to craft source code | ||
10 | that renders different logic than the logical ordering of tokens | ||
11 | ingested by compilers and interpreters. Adversaries can leverage this to | ||
12 | encode source code for compilers accepting Unicode such that targeted | ||
13 | vulnerabilities are introduced invisibly to human reviewers." | ||
14 | |||
15 | More info: | ||
16 | https://nvd.nist.gov/vuln/detail/CVE-2021-42574 | ||
17 | https://trojansource.codes/ | ||
18 | |||
19 | This is not a compiler bug. However, to mitigate the problem, this patch | ||
20 | implements -Wbidi-chars=[none|unpaired|any] to warn about possibly | ||
21 | misleading Unicode bidirectional control characters the preprocessor may | ||
22 | encounter. | ||
23 | |||
24 | The default is =unpaired, which warns about improperly terminated | ||
25 | bidirectional control characters; e.g. a LRE without its corresponding PDF. | ||
26 | The level =any warns about any use of bidirectional control characters. | ||
27 | |||
28 | This patch handles both UCNs and UTF-8 characters. UCNs designating | ||
29 | bidi characters in identifiers are accepted since r204886. Then r217144 | ||
30 | enabled -fextended-identifiers by default. Extended characters in C/C++ | ||
31 | identifiers have been accepted since r275979. However, this patch still | ||
32 | warns about mixing UTF-8 and UCN bidi characters; there seems to be no | ||
33 | good reason to allow mixing them. | ||
34 | |||
35 | We warn in different contexts: comments (both C and C++-style), string | ||
36 | literals, character constants, and identifiers. Expectedly, UCNs are ignored | ||
37 | in comments and raw string literals. The bidirectional control characters | ||
38 | can nest so this patch handles that as well. | ||
39 | |||
40 | I have not included nor tested this at all with Fortran (which also has | ||
41 | string literals and line comments). | ||
42 | |||
43 | Dave M. posted patches improving diagnostic involving Unicode characters. | ||
44 | This patch does not make use of this new infrastructure yet. | ||
45 | |||
46 | PR preprocessor/103026 | ||
47 | |||
48 | gcc/c-family/ChangeLog: | ||
49 | |||
50 | * c.opt (Wbidi-chars, Wbidi-chars=): New option. | ||
51 | |||
52 | gcc/ChangeLog: | ||
53 | |||
54 | * doc/invoke.texi: Document -Wbidi-chars. | ||
55 | |||
56 | libcpp/ChangeLog: | ||
57 | |||
58 | * include/cpplib.h (enum cpp_bidirectional_level): New. | ||
59 | (struct cpp_options): Add cpp_warn_bidirectional. | ||
60 | (enum cpp_warning_reason): Add CPP_W_BIDIRECTIONAL. | ||
61 | * internal.h (struct cpp_reader): Add warn_bidi_p member | ||
62 | function. | ||
63 | * init.c (cpp_create_reader): Set cpp_warn_bidirectional. | ||
64 | * lex.c (bidi): New namespace. | ||
65 | (get_bidi_utf8): New function. | ||
66 | (get_bidi_ucn): Likewise. | ||
67 | (maybe_warn_bidi_on_close): Likewise. | ||
68 | (maybe_warn_bidi_on_char): Likewise. | ||
69 | (_cpp_skip_block_comment): Implement warning about bidirectional | ||
70 | control characters. | ||
71 | (skip_line_comment): Likewise. | ||
72 | (forms_identifier_p): Likewise. | ||
73 | (lex_identifier): Likewise. | ||
74 | (lex_string): Likewise. | ||
75 | (lex_raw_string): Likewise. | ||
76 | |||
77 | gcc/testsuite/ChangeLog: | ||
78 | |||
79 | * c-c++-common/Wbidi-chars-1.c: New test. | ||
80 | * c-c++-common/Wbidi-chars-2.c: New test. | ||
81 | * c-c++-common/Wbidi-chars-3.c: New test. | ||
82 | * c-c++-common/Wbidi-chars-4.c: New test. | ||
83 | * c-c++-common/Wbidi-chars-5.c: New test. | ||
84 | * c-c++-common/Wbidi-chars-6.c: New test. | ||
85 | * c-c++-common/Wbidi-chars-7.c: New test. | ||
86 | * c-c++-common/Wbidi-chars-8.c: New test. | ||
87 | * c-c++-common/Wbidi-chars-9.c: New test. | ||
88 | * c-c++-common/Wbidi-chars-10.c: New test. | ||
89 | * c-c++-common/Wbidi-chars-11.c: New test. | ||
90 | * c-c++-common/Wbidi-chars-12.c: New test. | ||
91 | * c-c++-common/Wbidi-chars-13.c: New test. | ||
92 | * c-c++-common/Wbidi-chars-14.c: New test. | ||
93 | * c-c++-common/Wbidi-chars-15.c: New test. | ||
94 | * c-c++-common/Wbidi-chars-16.c: New test. | ||
95 | * c-c++-common/Wbidi-chars-17.c: New test. | ||
96 | |||
97 | CVE: CVE-2021-42574 | ||
98 | Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=51c500269bf53749b107807d84271385fad35628] | ||
99 | Signed-off-by: Pgowda <pgowda.cve@gmail.com> | ||
100 | |||
101 | --- | ||
102 | gcc/c-family/c.opt | 24 ++ | ||
103 | gcc/doc/invoke.texi | 21 +- | ||
104 | gcc/testsuite/c-c++-common/Wbidi-chars-1.c | 12 + | ||
105 | gcc/testsuite/c-c++-common/Wbidi-chars-10.c | 27 ++ | ||
106 | gcc/testsuite/c-c++-common/Wbidi-chars-11.c | 13 + | ||
107 | gcc/testsuite/c-c++-common/Wbidi-chars-12.c | 19 + | ||
108 | gcc/testsuite/c-c++-common/Wbidi-chars-13.c | 17 + | ||
109 | gcc/testsuite/c-c++-common/Wbidi-chars-14.c | 38 ++ | ||
110 | gcc/testsuite/c-c++-common/Wbidi-chars-15.c | 59 +++ | ||
111 | gcc/testsuite/c-c++-common/Wbidi-chars-16.c | 26 ++ | ||
112 | gcc/testsuite/c-c++-common/Wbidi-chars-17.c | 30 ++ | ||
113 | gcc/testsuite/c-c++-common/Wbidi-chars-2.c | 9 + | ||
114 | gcc/testsuite/c-c++-common/Wbidi-chars-3.c | 11 + | ||
115 | gcc/testsuite/c-c++-common/Wbidi-chars-4.c | 188 +++++++++ | ||
116 | gcc/testsuite/c-c++-common/Wbidi-chars-5.c | 188 +++++++++ | ||
117 | gcc/testsuite/c-c++-common/Wbidi-chars-6.c | 155 ++++++++ | ||
118 | gcc/testsuite/c-c++-common/Wbidi-chars-7.c | 9 + | ||
119 | gcc/testsuite/c-c++-common/Wbidi-chars-8.c | 13 + | ||
120 | gcc/testsuite/c-c++-common/Wbidi-chars-9.c | 29 ++ | ||
121 | libcpp/include/cpplib.h | 18 +- | ||
122 | libcpp/init.c | 1 + | ||
123 | libcpp/internal.h | 7 + | ||
124 | libcpp/lex.c | 408 +++++++++++++++++++- | ||
125 | 23 files changed, 1315 insertions(+), 7 deletions(-) | ||
126 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-1.c | ||
127 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-10.c | ||
128 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-11.c | ||
129 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-12.c | ||
130 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-13.c | ||
131 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-14.c | ||
132 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-15.c | ||
133 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-16.c | ||
134 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-17.c | ||
135 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-2.c | ||
136 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-3.c | ||
137 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-4.c | ||
138 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-5.c | ||
139 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-6.c | ||
140 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-7.c | ||
141 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-8.c | ||
142 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-9.c | ||
143 | |||
144 | diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt | ||
145 | index 8a4cd634f77..3976fc368db 100644 | ||
146 | --- a/gcc/c-family/c.opt | ||
147 | +++ b/gcc/c-family/c.opt | ||
148 | @@ -370,6 +370,30 @@ Wbad-function-cast | ||
149 | C ObjC Var(warn_bad_function_cast) Warning | ||
150 | Warn about casting functions to incompatible types. | ||
151 | |||
152 | +Wbidi-chars | ||
153 | +C ObjC C++ ObjC++ Warning Alias(Wbidi-chars=,any,none) | ||
154 | +; | ||
155 | + | ||
156 | +Wbidi-chars= | ||
157 | +C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(cpp_warn_bidirectional) CppReason(CPP_W_BIDIRECTIONAL) Var(warn_bidirectional) Init(bidirectional_unpaired) Enum(cpp_bidirectional_level) | ||
158 | +-Wbidi-chars=[none|unpaired|any] Warn about UTF-8 bidirectional control characters. | ||
159 | + | ||
160 | +; Required for these enum values. | ||
161 | +SourceInclude | ||
162 | +cpplib.h | ||
163 | + | ||
164 | +Enum | ||
165 | +Name(cpp_bidirectional_level) Type(int) UnknownError(argument %qs to %<-Wbidi-chars%> not recognized) | ||
166 | + | ||
167 | +EnumValue | ||
168 | +Enum(cpp_bidirectional_level) String(none) Value(bidirectional_none) | ||
169 | + | ||
170 | +EnumValue | ||
171 | +Enum(cpp_bidirectional_level) String(unpaired) Value(bidirectional_unpaired) | ||
172 | + | ||
173 | +EnumValue | ||
174 | +Enum(cpp_bidirectional_level) String(any) Value(bidirectional_any) | ||
175 | + | ||
176 | Wbool-compare | ||
177 | C ObjC C++ ObjC++ Var(warn_bool_compare) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) | ||
178 | Warn about boolean expression compared with an integer value different from true/false. | ||
179 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi | ||
180 | index 6070288856c..a22758d18ee 100644 | ||
181 | --- a/gcc/doc/invoke.texi | ||
182 | +++ b/gcc/doc/invoke.texi | ||
183 | @@ -326,7 +326,9 @@ Objective-C and Objective-C++ Dialects}. | ||
184 | -Warith-conversion @gol | ||
185 | -Warray-bounds -Warray-bounds=@var{n} @gol | ||
186 | -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias @gol | ||
187 | --Wno-attribute-warning -Wbool-compare -Wbool-operation @gol | ||
188 | +-Wno-attribute-warning @gol | ||
189 | +-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]} @gol | ||
190 | +-Wbool-compare -Wbool-operation @gol | ||
191 | -Wno-builtin-declaration-mismatch @gol | ||
192 | -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol | ||
193 | -Wc11-c2x-compat @gol | ||
194 | @@ -7559,6 +7561,23 @@ Attributes considered include @code{allo | ||
195 | This is the default. You can disable these warnings with either | ||
196 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | ||
197 | |||
198 | +@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]} | ||
199 | +@opindex Wbidi-chars= | ||
200 | +@opindex Wbidi-chars | ||
201 | +@opindex Wno-bidi-chars | ||
202 | +Warn about possibly misleading UTF-8 bidirectional control characters in | ||
203 | +comments, string literals, character constants, and identifiers. Such | ||
204 | +characters can change left-to-right writing direction into right-to-left | ||
205 | +(and vice versa), which can cause confusion between the logical order and | ||
206 | +visual order. This may be dangerous; for instance, it may seem that a piece | ||
207 | +of code is not commented out, whereas it in fact is. | ||
208 | + | ||
209 | +There are three levels of warning supported by GCC@. The default is | ||
210 | +@option{-Wbidi-chars=unpaired}, which warns about improperly terminated | ||
211 | +bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | ||
212 | +@option{-Wbidi-chars=any} warns about any use of bidirectional control | ||
213 | +characters. | ||
214 | + | ||
215 | @item -Wbool-compare | ||
216 | @opindex Wno-bool-compare | ||
217 | @opindex Wbool-compare | ||
218 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-10.c b/gcc/testsuite/c-c++-common/Wbidi-chars-10.c | ||
219 | new file mode 100644 | ||
220 | index 00000000000..34f5ac19271 | ||
221 | --- /dev/null | ||
222 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-10.c | ||
223 | @@ -0,0 +1,27 @@ | ||
224 | +/* PR preprocessor/103026 */ | ||
225 | +/* { dg-do compile } */ | ||
226 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
227 | +/* More nesting testing. */ | ||
228 | + | ||
229 | +/* RLEâ« LRI⦠PDF⬠PDIâ©*/ | ||
230 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
231 | +int LRE_\u202a_PDF_\u202c; | ||
232 | +int LRE_\u202a_PDF_\u202c_LRE_\u202a_PDF_\u202c; | ||
233 | +int LRE_\u202a_LRI_\u2066_PDF_\u202c_PDI_\u2069; | ||
234 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
235 | +int RLE_\u202b_RLI_\u2067_PDF_\u202c_PDI_\u2069; | ||
236 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
237 | +int RLE_\u202b_RLI_\u2067_PDI_\u2069_PDF_\u202c; | ||
238 | +int FSI_\u2068_LRO_\u202d_PDI_\u2069_PDF_\u202c; | ||
239 | +int FSI_\u2068; | ||
240 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
241 | +int FSI_\u2068_PDI_\u2069; | ||
242 | +int FSI_\u2068_FSI_\u2068_PDI_\u2069; | ||
243 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
244 | +int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069; | ||
245 | +int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069; | ||
246 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
247 | +int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDF_\u202c; | ||
248 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
249 | +int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_FSI_\u2068_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069; | ||
250 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
251 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-11.c b/gcc/testsuite/c-c++-common/Wbidi-chars-11.c | ||
252 | new file mode 100644 | ||
253 | index 00000000000..270ce2368a9 | ||
254 | --- /dev/null | ||
255 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-11.c | ||
256 | @@ -0,0 +1,13 @@ | ||
257 | +/* PR preprocessor/103026 */ | ||
258 | +/* { dg-do compile } */ | ||
259 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
260 | +/* Test that we warn when mixing UCN and UTF-8. */ | ||
261 | + | ||
262 | +int LRE_âª_PDF_\u202c; | ||
263 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
264 | +int LRE_\u202a_PDF_â¬_; | ||
265 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
266 | +const char *s1 = "LRE_âª_PDF_\u202c"; | ||
267 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
268 | +const char *s2 = "LRE_\u202a_PDF_â¬"; | ||
269 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
270 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-12.c b/gcc/testsuite/c-c++-common/Wbidi-chars-12.c | ||
271 | new file mode 100644 | ||
272 | index 00000000000..b07eec1da91 | ||
273 | --- /dev/null | ||
274 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-12.c | ||
275 | @@ -0,0 +1,19 @@ | ||
276 | +/* PR preprocessor/103026 */ | ||
277 | +/* { dg-do compile { target { c || c++11 } } } */ | ||
278 | +/* { dg-options "-Wbidi-chars=any" } */ | ||
279 | +/* Test raw strings. */ | ||
280 | + | ||
281 | +const char *s1 = R"(a b c LRE⪠1 2 3 PDF⬠x y z)"; | ||
282 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
283 | +const char *s2 = R"(a b c RLE⫠1 2 3 PDF⬠x y z)"; | ||
284 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
285 | +const char *s3 = R"(a b c LROâ 1 2 3 PDF⬠x y z)"; | ||
286 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
287 | +const char *s4 = R"(a b c RLO⮠1 2 3 PDF⬠x y z)"; | ||
288 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
289 | +const char *s7 = R"(a b c FSI⨠1 2 3 PDI⩠x y) z"; | ||
290 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
291 | +const char *s8 = R"(a b c PDIâ© x y )z"; | ||
292 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
293 | +const char *s9 = R"(a b c PDF⬠x y z)"; | ||
294 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
295 | diff -uprN '-x*.orig' '-x*.rej' del/gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c | ||
296 | --- del/gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c 1969-12-31 16:00:00.000000000 -0800 | ||
297 | +++ gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c 2021-12-13 23:11:22.328439287 -0800 | ||
298 | @@ -0,0 +1,17 @@ | ||
299 | +/* PR preprocessor/103026 */ | ||
300 | +/* { dg-do compile { target { c || c++11 } } } */ | ||
301 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
302 | +/* Test raw strings. */ | ||
303 | + | ||
304 | +const char *s1 = R"(a b c LRE⪠1 2 3)"; | ||
305 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
306 | +const char *s2 = R"(a b c RLEâ« 1 2 3)"; | ||
307 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
308 | +const char *s3 = R"(a b c LROâ 1 2 3)"; | ||
309 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
310 | +const char *s4 = R"(a b c FSI⨠1 2 3)"; | ||
311 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
312 | +const char *s5 = R"(a b c LRI⦠1 2 3)"; | ||
313 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
314 | +const char *s6 = R"(a b c RLI⧠1 2 3)"; | ||
315 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
316 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-14.c b/gcc/testsuite/c-c++-common/Wbidi-chars-14.c | ||
317 | new file mode 100644 | ||
318 | index 00000000000..ba5f75d9553 | ||
319 | --- /dev/null | ||
320 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-14.c | ||
321 | @@ -0,0 +1,38 @@ | ||
322 | +/* PR preprocessor/103026 */ | ||
323 | +/* { dg-do compile } */ | ||
324 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
325 | +/* Test PDI handling, which also pops any subsequent LREs, RLEs, LROs, | ||
326 | + or RLOs. */ | ||
327 | + | ||
328 | +/* LRI_â¦_LRI_â¦_RLE_â«_RLE_â«_RLE_â«_PDI_â©*/ | ||
329 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
330 | +// LRI_â¦_RLE_â«_RLE_â«_RLE_â«_PDI_â© | ||
331 | +// LRI_â¦_RLO_â®_RLE_â«_RLE_â«_PDI_â© | ||
332 | +// LRI_â¦_RLO_â®_RLE_â«_PDI_â© | ||
333 | +// FSI_â¨_RLO_â®_PDI_â© | ||
334 | +// FSI_â¨_FSI_â¨_RLO_â®_PDI_â© | ||
335 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
336 | + | ||
337 | +int LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069; | ||
338 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
339 | +int LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069_PDI_\u2069; | ||
340 | +int LRI_\u2066_LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069_PDI_\u2069; | ||
341 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
342 | +int PDI_\u2069; | ||
343 | +int LRI_\u2066_PDI_\u2069; | ||
344 | +int RLI_\u2067_PDI_\u2069; | ||
345 | +int LRE_\u202a_LRI_\u2066_PDI_\u2069; | ||
346 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
347 | +int LRI_\u2066_LRE_\u202a_PDF_\u202c_PDI_\u2069; | ||
348 | +int LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069; | ||
349 | +int RLI_\u2067_LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069; | ||
350 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
351 | +int FSI_\u2068_LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069; | ||
352 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
353 | +int RLO_\u202e_PDI_\u2069; | ||
354 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
355 | +int RLI_\u2067_PDI_\u2069_RLI_\u2067; | ||
356 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
357 | +int FSI_\u2068_PDF_\u202c_PDI_\u2069; | ||
358 | +int FSI_\u2068_FSI_\u2068_PDF_\u202c_PDI_\u2069; | ||
359 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
360 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-15.c b/gcc/testsuite/c-c++-common/Wbidi-chars-15.c | ||
361 | new file mode 100644 | ||
362 | index 00000000000..a0ce8ff5e2c | ||
363 | --- /dev/null | ||
364 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-15.c | ||
365 | @@ -0,0 +1,59 @@ | ||
366 | +/* PR preprocessor/103026 */ | ||
367 | +/* { dg-do compile } */ | ||
368 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
369 | +/* Test unpaired bidi control chars in multiline comments. */ | ||
370 | + | ||
371 | +/* | ||
372 | + * LRE⪠end | ||
373 | + */ | ||
374 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
375 | +/* | ||
376 | + * RLEâ« end | ||
377 | + */ | ||
378 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
379 | +/* | ||
380 | + * LROâ end | ||
381 | + */ | ||
382 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
383 | +/* | ||
384 | + * RLOâ® end | ||
385 | + */ | ||
386 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
387 | +/* | ||
388 | + * LRI⦠end | ||
389 | + */ | ||
390 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
391 | +/* | ||
392 | + * RLI⧠end | ||
393 | + */ | ||
394 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
395 | +/* | ||
396 | + * FSI⨠end | ||
397 | + */ | ||
398 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
399 | +/* LRE⪠| ||
400 | + PDF⬠*/ | ||
401 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
402 | +/* FSI⨠| ||
403 | + PDIâ© */ | ||
404 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
405 | + | ||
406 | +/* LRE<âª> | ||
407 | + * | ||
408 | + */ | ||
409 | +/* { dg-warning "unpaired" "" { target *-*-* } .-3 } */ | ||
410 | + | ||
411 | +/* | ||
412 | + * LRE<âª> | ||
413 | + */ | ||
414 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
415 | + | ||
416 | +/* | ||
417 | + * | ||
418 | + * LRE<âª> */ | ||
419 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
420 | + | ||
421 | +/* RLI<â§> */ /* PDI<â©> */ | ||
422 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
423 | +/* LRE<âª> */ /* PDF<â¬> */ | ||
424 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
425 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-16.c b/gcc/testsuite/c-c++-common/Wbidi-chars-16.c | ||
426 | new file mode 100644 | ||
427 | index 00000000000..baa0159861c | ||
428 | --- /dev/null | ||
429 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-16.c | ||
430 | @@ -0,0 +1,26 @@ | ||
431 | +/* PR preprocessor/103026 */ | ||
432 | +/* { dg-do compile } */ | ||
433 | +/* { dg-options "-Wbidi-chars=any" } */ | ||
434 | +/* Test LTR/RTL chars. */ | ||
435 | + | ||
436 | +/* LTR<â> */ | ||
437 | +/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */ | ||
438 | +// LTR<â> | ||
439 | +/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */ | ||
440 | +/* RTL<â> */ | ||
441 | +/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */ | ||
442 | +// RTL<â> | ||
443 | +/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */ | ||
444 | + | ||
445 | +const char *s1 = "LTR<â>"; | ||
446 | +/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */ | ||
447 | +const char *s2 = "LTR\u200e"; | ||
448 | +/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */ | ||
449 | +const char *s3 = "LTR\u200E"; | ||
450 | +/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */ | ||
451 | +const char *s4 = "RTL<â>"; | ||
452 | +/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */ | ||
453 | +const char *s5 = "RTL\u200f"; | ||
454 | +/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */ | ||
455 | +const char *s6 = "RTL\u200F"; | ||
456 | +/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */ | ||
457 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-17.c b/gcc/testsuite/c-c++-common/Wbidi-chars-17.c | ||
458 | new file mode 100644 | ||
459 | index 00000000000..07cb4321f96 | ||
460 | --- /dev/null | ||
461 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-17.c | ||
462 | @@ -0,0 +1,30 @@ | ||
463 | +/* PR preprocessor/103026 */ | ||
464 | +/* { dg-do compile } */ | ||
465 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
466 | +/* Test LTR/RTL chars. */ | ||
467 | + | ||
468 | +/* LTR<â> */ | ||
469 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
470 | +// LTR<â> | ||
471 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
472 | +/* RTL<â> */ | ||
473 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
474 | +// RTL<â> | ||
475 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
476 | +int ltr_\u200e; | ||
477 | +/* { dg-error "universal character " "" { target *-*-* } .-1 } */ | ||
478 | +int rtl_\u200f; | ||
479 | +/* { dg-error "universal character " "" { target *-*-* } .-1 } */ | ||
480 | + | ||
481 | +const char *s1 = "LTR<â>"; | ||
482 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
483 | +const char *s2 = "LTR\u200e"; | ||
484 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
485 | +const char *s3 = "LTR\u200E"; | ||
486 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
487 | +const char *s4 = "RTL<â>"; | ||
488 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
489 | +const char *s5 = "RTL\u200f"; | ||
490 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
491 | +const char *s6 = "RTL\u200F"; | ||
492 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
493 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-1.c b/gcc/testsuite/c-c++-common/Wbidi-chars-1.c | ||
494 | new file mode 100644 | ||
495 | index 00000000000..2340374f276 | ||
496 | --- /dev/null | ||
497 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-1.c | ||
498 | @@ -0,0 +1,12 @@ | ||
499 | +/* PR preprocessor/103026 */ | ||
500 | +/* { dg-do compile } */ | ||
501 | + | ||
502 | +int main() { | ||
503 | + int isAdmin = 0; | ||
504 | + /*â® } â¦if (isAdmin)⩠⦠begin admins only */ | ||
505 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
506 | + __builtin_printf("You are an admin.\n"); | ||
507 | + /* end admins only â® { â¦*/ | ||
508 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
509 | + return 0; | ||
510 | +} | ||
511 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-2.c b/gcc/testsuite/c-c++-common/Wbidi-chars-2.c | ||
512 | new file mode 100644 | ||
513 | index 00000000000..2340374f276 | ||
514 | --- /dev/null | ||
515 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-2.c | ||
516 | @@ -0,0 +1,9 @@ | ||
517 | +/* PR preprocessor/103026 */ | ||
518 | +/* { dg-do compile } */ | ||
519 | + | ||
520 | +int main() { | ||
521 | + /* Say hello; newlineâ§/*/ return 0 ; | ||
522 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
523 | + __builtin_printf("Hello world.\n"); | ||
524 | + return 0; | ||
525 | +} | ||
526 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-3.c b/gcc/testsuite/c-c++-common/Wbidi-chars-3.c | ||
527 | new file mode 100644 | ||
528 | index 00000000000..9dc7edb6e64 | ||
529 | --- /dev/null | ||
530 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-3.c | ||
531 | @@ -0,0 +1,11 @@ | ||
532 | +/* PR preprocessor/103026 */ | ||
533 | +/* { dg-do compile } */ | ||
534 | + | ||
535 | +int main() { | ||
536 | + const char* access_level = "user"; | ||
537 | + if (__builtin_strcmp(access_level, "userâ® â¦// Check if adminâ© â¦")) { | ||
538 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
539 | + __builtin_printf("You are an admin.\n"); | ||
540 | + } | ||
541 | + return 0; | ||
542 | +} | ||
543 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-4.c b/gcc/testsuite/c-c++-common/Wbidi-chars-4.c | ||
544 | new file mode 100644 | ||
545 | index 00000000000..639e5c62e88 | ||
546 | --- /dev/null | ||
547 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-4.c | ||
548 | @@ -0,0 +1,188 @@ | ||
549 | +/* PR preprocessor/103026 */ | ||
550 | +/* { dg-do compile } */ | ||
551 | +/* { dg-options "-Wbidi-chars=any -Wno-multichar -Wno-overflow" } */ | ||
552 | +/* Test all bidi chars in various contexts (identifiers, comments, | ||
553 | + string literals, character constants), both UCN and UTF-8. The bidi | ||
554 | + chars here are properly terminated, except for the character constants. */ | ||
555 | + | ||
556 | +/* a b c LRE⪠1 2 3 PDF⬠x y z */ | ||
557 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
558 | +/* a b c RLE⫠1 2 3 PDF⬠x y z */ | ||
559 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
560 | +/* a b c LROâ 1 2 3 PDF⬠x y z */ | ||
561 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
562 | +/* a b c RLO⮠1 2 3 PDF⬠x y z */ | ||
563 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
564 | +/* a b c LRI⦠1 2 3 PDI⩠x y z */ | ||
565 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
566 | +/* a b c RLI⧠1 2 3 PDI⩠x y */ | ||
567 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
568 | +/* a b c FSI⨠1 2 3 PDI⩠x y z */ | ||
569 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
570 | + | ||
571 | +/* Same but C++ comments instead. */ | ||
572 | +// a b c LRE⪠1 2 3 PDF⬠x y z | ||
573 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
574 | +// a b c RLE⫠1 2 3 PDF⬠x y z | ||
575 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
576 | +// a b c LROâ 1 2 3 PDF⬠x y z | ||
577 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
578 | +// a b c RLO⮠1 2 3 PDF⬠x y z | ||
579 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
580 | +// a b c LRI⦠1 2 3 PDI⩠x y z | ||
581 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
582 | +// a b c RLI⧠1 2 3 PDI⩠x y | ||
583 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
584 | +// a b c FSI⨠1 2 3 PDI⩠x y z | ||
585 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
586 | + | ||
587 | +/* Here we're closing an unopened context, warn when =any. */ | ||
588 | +/* a b c PDIâ© x y z */ | ||
589 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
590 | +/* a b c PDF⬠x y z */ | ||
591 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
592 | +// a b c PDIâ© x y z | ||
593 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
594 | +// a b c PDF⬠x y z | ||
595 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
596 | + | ||
597 | +/* Multiline comments. */ | ||
598 | +/* a b c PDIâ© x y z | ||
599 | + */ | ||
600 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-2 } */ | ||
601 | +/* a b c PDF⬠x y z | ||
602 | + */ | ||
603 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-2 } */ | ||
604 | +/* first | ||
605 | + a b c PDIâ© x y z | ||
606 | + */ | ||
607 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-2 } */ | ||
608 | +/* first | ||
609 | + a b c PDF⬠x y z | ||
610 | + */ | ||
611 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-2 } */ | ||
612 | +/* first | ||
613 | + a b c PDIâ© x y z */ | ||
614 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
615 | +/* first | ||
616 | + a b c PDF⬠x y z */ | ||
617 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
618 | + | ||
619 | +void | ||
620 | +g1 () | ||
621 | +{ | ||
622 | + const char *s1 = "a b c LRE⪠1 2 3 PDF⬠x y z"; | ||
623 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
624 | + const char *s2 = "a b c RLE⫠1 2 3 PDF⬠x y z"; | ||
625 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
626 | + const char *s3 = "a b c LROâ 1 2 3 PDF⬠x y z"; | ||
627 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
628 | + const char *s4 = "a b c RLO⮠1 2 3 PDF⬠x y z"; | ||
629 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
630 | + const char *s5 = "a b c LRI⦠1 2 3 PDI⩠x y z"; | ||
631 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
632 | + const char *s6 = "a b c RLI⧠1 2 3 PDI⩠x y z"; | ||
633 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
634 | + const char *s7 = "a b c FSI⨠1 2 3 PDI⩠x y z"; | ||
635 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
636 | + const char *s8 = "a b c PDIâ© x y z"; | ||
637 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
638 | + const char *s9 = "a b c PDF⬠x y z"; | ||
639 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
640 | + | ||
641 | + const char *s10 = "a b c LRE\u202a 1 2 3 PDF\u202c x y z"; | ||
642 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
643 | + const char *s11 = "a b c LRE\u202A 1 2 3 PDF\u202c x y z"; | ||
644 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
645 | + const char *s12 = "a b c RLE\u202b 1 2 3 PDF\u202c x y z"; | ||
646 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
647 | + const char *s13 = "a b c RLE\u202B 1 2 3 PDF\u202c x y z"; | ||
648 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
649 | + const char *s14 = "a b c LRO\u202d 1 2 3 PDF\u202c x y z"; | ||
650 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
651 | + const char *s15 = "a b c LRO\u202D 1 2 3 PDF\u202c x y z"; | ||
652 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
653 | + const char *s16 = "a b c RLO\u202e 1 2 3 PDF\u202c x y z"; | ||
654 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
655 | + const char *s17 = "a b c RLO\u202E 1 2 3 PDF\u202c x y z"; | ||
656 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
657 | + const char *s18 = "a b c LRI\u2066 1 2 3 PDI\u2069 x y z"; | ||
658 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
659 | + const char *s19 = "a b c RLI\u2067 1 2 3 PDI\u2069 x y z"; | ||
660 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
661 | + const char *s20 = "a b c FSI\u2068 1 2 3 PDI\u2069 x y z"; | ||
662 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
663 | +} | ||
664 | + | ||
665 | +void | ||
666 | +g2 () | ||
667 | +{ | ||
668 | + const char c1 = '\u202a'; | ||
669 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
670 | + const char c2 = '\u202A'; | ||
671 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
672 | + const char c3 = '\u202b'; | ||
673 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
674 | + const char c4 = '\u202B'; | ||
675 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
676 | + const char c5 = '\u202d'; | ||
677 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
678 | + const char c6 = '\u202D'; | ||
679 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
680 | + const char c7 = '\u202e'; | ||
681 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
682 | + const char c8 = '\u202E'; | ||
683 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
684 | + const char c9 = '\u2066'; | ||
685 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
686 | + const char c10 = '\u2067'; | ||
687 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
688 | + const char c11 = '\u2068'; | ||
689 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
690 | +} | ||
691 | + | ||
692 | +int aâªbâ¬c; | ||
693 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
694 | +int aâ«bâ¬c; | ||
695 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
696 | +int aâbâ¬c; | ||
697 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
698 | +int aâ®bâ¬c; | ||
699 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
700 | +int aâ¦bâ©c; | ||
701 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
702 | +int aâ§bâ©c; | ||
703 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
704 | +int aâ¨bâ©c; | ||
705 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
706 | +int Aâ¬X; | ||
707 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
708 | +int A\u202cY; | ||
709 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
710 | +int A\u202CY2; | ||
711 | +/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */ | ||
712 | + | ||
713 | +int d\u202ae\u202cf; | ||
714 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
715 | +int d\u202Ae\u202cf2; | ||
716 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
717 | +int d\u202be\u202cf; | ||
718 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
719 | +int d\u202Be\u202cf2; | ||
720 | +/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */ | ||
721 | +int d\u202de\u202cf; | ||
722 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
723 | +int d\u202De\u202cf2; | ||
724 | +/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */ | ||
725 | +int d\u202ee\u202cf; | ||
726 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
727 | +int d\u202Ee\u202cf2; | ||
728 | +/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */ | ||
729 | +int d\u2066e\u2069f; | ||
730 | +/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */ | ||
731 | +int d\u2067e\u2069f; | ||
732 | +/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */ | ||
733 | +int d\u2068e\u2069f; | ||
734 | +/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */ | ||
735 | +int X\u2069; | ||
736 | +/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */ | ||
737 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-5.c b/gcc/testsuite/c-c++-common/Wbidi-chars-5.c | ||
738 | new file mode 100644 | ||
739 | index 00000000000..68cb053144b | ||
740 | --- /dev/null | ||
741 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-5.c | ||
742 | @@ -0,0 +1,188 @@ | ||
743 | +/* PR preprocessor/103026 */ | ||
744 | +/* { dg-do compile } */ | ||
745 | +/* { dg-options "-Wbidi-chars=unpaired -Wno-multichar -Wno-overflow" } */ | ||
746 | +/* Test all bidi chars in various contexts (identifiers, comments, | ||
747 | + string literals, character constants), both UCN and UTF-8. The bidi | ||
748 | + chars here are properly terminated, except for the character constants. */ | ||
749 | + | ||
750 | +/* a b c LRE⪠1 2 3 PDF⬠x y z */ | ||
751 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
752 | +/* a b c RLE⫠1 2 3 PDF⬠x y z */ | ||
753 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
754 | +/* a b c LROâ 1 2 3 PDF⬠x y z */ | ||
755 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
756 | +/* a b c RLO⮠1 2 3 PDF⬠x y z */ | ||
757 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
758 | +/* a b c LRI⦠1 2 3 PDI⩠x y z */ | ||
759 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
760 | +/* a b c RLI⧠1 2 3 PDI⩠x y */ | ||
761 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
762 | +/* a b c FSI⨠1 2 3 PDI⩠x y z */ | ||
763 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
764 | + | ||
765 | +/* Same but C++ comments instead. */ | ||
766 | +// a b c LRE⪠1 2 3 PDF⬠x y z | ||
767 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
768 | +// a b c RLE⫠1 2 3 PDF⬠x y z | ||
769 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
770 | +// a b c LROâ 1 2 3 PDF⬠x y z | ||
771 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
772 | +// a b c RLO⮠1 2 3 PDF⬠x y z | ||
773 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
774 | +// a b c LRI⦠1 2 3 PDI⩠x y z | ||
775 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
776 | +// a b c RLI⧠1 2 3 PDI⩠x y | ||
777 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
778 | +// a b c FSI⨠1 2 3 PDI⩠x y z | ||
779 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
780 | + | ||
781 | +/* Here we're closing an unopened context, warn when =any. */ | ||
782 | +/* a b c PDIâ© x y z */ | ||
783 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
784 | +/* a b c PDF⬠x y z */ | ||
785 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
786 | +// a b c PDIâ© x y z | ||
787 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
788 | +// a b c PDF⬠x y z | ||
789 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
790 | + | ||
791 | +/* Multiline comments. */ | ||
792 | +/* a b c PDIâ© x y z | ||
793 | + */ | ||
794 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */ | ||
795 | +/* a b c PDF⬠x y z | ||
796 | + */ | ||
797 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */ | ||
798 | +/* first | ||
799 | + a b c PDIâ© x y z | ||
800 | + */ | ||
801 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */ | ||
802 | +/* first | ||
803 | + a b c PDF⬠x y z | ||
804 | + */ | ||
805 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */ | ||
806 | +/* first | ||
807 | + a b c PDIâ© x y z */ | ||
808 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
809 | +/* first | ||
810 | + a b c PDF⬠x y z */ | ||
811 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
812 | + | ||
813 | +void | ||
814 | +g1 () | ||
815 | +{ | ||
816 | + const char *s1 = "a b c LRE⪠1 2 3 PDF⬠x y z"; | ||
817 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
818 | + const char *s2 = "a b c RLE⫠1 2 3 PDF⬠x y z"; | ||
819 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
820 | + const char *s3 = "a b c LROâ 1 2 3 PDF⬠x y z"; | ||
821 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
822 | + const char *s4 = "a b c RLO⮠1 2 3 PDF⬠x y z"; | ||
823 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
824 | + const char *s5 = "a b c LRI⦠1 2 3 PDI⩠x y z"; | ||
825 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
826 | + const char *s6 = "a b c RLI⧠1 2 3 PDI⩠x y z"; | ||
827 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
828 | + const char *s7 = "a b c FSI⨠1 2 3 PDI⩠x y z"; | ||
829 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
830 | + const char *s8 = "a b c PDIâ© x y z"; | ||
831 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
832 | + const char *s9 = "a b c PDF⬠x y z"; | ||
833 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
834 | + | ||
835 | + const char *s10 = "a b c LRE\u202a 1 2 3 PDF\u202c x y z"; | ||
836 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
837 | + const char *s11 = "a b c LRE\u202A 1 2 3 PDF\u202c x y z"; | ||
838 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
839 | + const char *s12 = "a b c RLE\u202b 1 2 3 PDF\u202c x y z"; | ||
840 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
841 | + const char *s13 = "a b c RLE\u202B 1 2 3 PDF\u202c x y z"; | ||
842 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
843 | + const char *s14 = "a b c LRO\u202d 1 2 3 PDF\u202c x y z"; | ||
844 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
845 | + const char *s15 = "a b c LRO\u202D 1 2 3 PDF\u202c x y z"; | ||
846 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
847 | + const char *s16 = "a b c RLO\u202e 1 2 3 PDF\u202c x y z"; | ||
848 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
849 | + const char *s17 = "a b c RLO\u202E 1 2 3 PDF\u202c x y z"; | ||
850 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
851 | + const char *s18 = "a b c LRI\u2066 1 2 3 PDI\u2069 x y z"; | ||
852 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
853 | + const char *s19 = "a b c RLI\u2067 1 2 3 PDI\u2069 x y z"; | ||
854 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
855 | + const char *s20 = "a b c FSI\u2068 1 2 3 PDI\u2069 x y z"; | ||
856 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
857 | +} | ||
858 | + | ||
859 | +void | ||
860 | +g2 () | ||
861 | +{ | ||
862 | + const char c1 = '\u202a'; | ||
863 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
864 | + const char c2 = '\u202A'; | ||
865 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
866 | + const char c3 = '\u202b'; | ||
867 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
868 | + const char c4 = '\u202B'; | ||
869 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
870 | + const char c5 = '\u202d'; | ||
871 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
872 | + const char c6 = '\u202D'; | ||
873 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
874 | + const char c7 = '\u202e'; | ||
875 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
876 | + const char c8 = '\u202E'; | ||
877 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
878 | + const char c9 = '\u2066'; | ||
879 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
880 | + const char c10 = '\u2067'; | ||
881 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
882 | + const char c11 = '\u2068'; | ||
883 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
884 | +} | ||
885 | + | ||
886 | +int aâªbâ¬c; | ||
887 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
888 | +int aâ«bâ¬c; | ||
889 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
890 | +int aâbâ¬c; | ||
891 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
892 | +int aâ®bâ¬c; | ||
893 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
894 | +int aâ¦bâ©c; | ||
895 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
896 | +int aâ§bâ©c; | ||
897 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
898 | +int aâ¨bâ©c; | ||
899 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
900 | +int Aâ¬X; | ||
901 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
902 | +int A\u202cY; | ||
903 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
904 | +int A\u202CY2; | ||
905 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
906 | + | ||
907 | +int d\u202ae\u202cf; | ||
908 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
909 | +int d\u202Ae\u202cf2; | ||
910 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
911 | +int d\u202be\u202cf; | ||
912 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
913 | +int d\u202Be\u202cf2; | ||
914 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
915 | +int d\u202de\u202cf; | ||
916 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
917 | +int d\u202De\u202cf2; | ||
918 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
919 | +int d\u202ee\u202cf; | ||
920 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
921 | +int d\u202Ee\u202cf2; | ||
922 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
923 | +int d\u2066e\u2069f; | ||
924 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
925 | +int d\u2067e\u2069f; | ||
926 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
927 | +int d\u2068e\u2069f; | ||
928 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
929 | +int X\u2069; | ||
930 | +/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */ | ||
931 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-6.c b/gcc/testsuite/c-c++-common/Wbidi-chars-6.c | ||
932 | new file mode 100644 | ||
933 | index 00000000000..0ce6fff2dee | ||
934 | --- /dev/null | ||
935 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-6.c | ||
936 | @@ -0,0 +1,155 @@ | ||
937 | +/* PR preprocessor/103026 */ | ||
938 | +/* { dg-do compile } */ | ||
939 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
940 | +/* Test nesting of bidi chars in various contexts. */ | ||
941 | + | ||
942 | +/* Terminated by the wrong char: */ | ||
943 | +/* a b c LRE⪠1 2 3 PDI⩠x y z */ | ||
944 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
945 | +/* a b c RLEâ« 1 2 3 PDIâ© x y z*/ | ||
946 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
947 | +/* a b c LROâ 1 2 3 PDIâ© x y z */ | ||
948 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
949 | +/* a b c RLOâ® 1 2 3 PDIâ© x y z */ | ||
950 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
951 | +/* a b c LRI⦠1 2 3 PDF⬠x y z */ | ||
952 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
953 | +/* a b c RLI⧠1 2 3 PDF⬠x y z */ | ||
954 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
955 | +/* a b c FSI⨠1 2 3 PDF⬠x y z*/ | ||
956 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
957 | + | ||
958 | +/* LRE⪠PDF⬠*/ | ||
959 | +/* LRE⪠LRE⪠PDF⬠PDF⬠*/ | ||
960 | +/* PDF⬠LRE⪠PDF⬠*/ | ||
961 | +/* LRE⪠PDF⬠LRE⪠PDF⬠*/ | ||
962 | +/* LRE⪠LRE⪠PDF⬠*/ | ||
963 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
964 | +/* PDF⬠LRE⪠*/ | ||
965 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
966 | + | ||
967 | +// a b c LRE⪠1 2 3 PDI⩠x y z | ||
968 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
969 | +// a b c RLEâ« 1 2 3 PDIâ© x y z*/ | ||
970 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
971 | +// a b c LROâ 1 2 3 PDIâ© x y z | ||
972 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
973 | +// a b c RLOâ® 1 2 3 PDIâ© x y z | ||
974 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
975 | +// a b c LRI⦠1 2 3 PDF⬠x y z | ||
976 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
977 | +// a b c RLI⧠1 2 3 PDF⬠x y z | ||
978 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
979 | +// a b c FSI⨠1 2 3 PDF⬠x y z | ||
980 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
981 | + | ||
982 | +// LRE⪠PDF⬠| ||
983 | +// LRE⪠LRE⪠PDF⬠PDF⬠| ||
984 | +// PDF⬠LRE⪠PDF⬠| ||
985 | +// LRE⪠PDF⬠LRE⪠PDF⬠| ||
986 | +// LRE⪠LRE⪠PDF⬠| ||
987 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
988 | +// PDF⬠LRE⪠| ||
989 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
990 | + | ||
991 | +void | ||
992 | +g1 () | ||
993 | +{ | ||
994 | + const char *s1 = "a b c LRE⪠1 2 3 PDI⩠x y z"; | ||
995 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
996 | + const char *s2 = "a b c LRE\u202a 1 2 3 PDI\u2069 x y z"; | ||
997 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
998 | + const char *s3 = "a b c RLEâ« 1 2 3 PDIâ© x y "; | ||
999 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1000 | + const char *s4 = "a b c RLE\u202b 1 2 3 PDI\u2069 x y z"; | ||
1001 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1002 | + const char *s5 = "a b c LROâ 1 2 3 PDIâ© x y z"; | ||
1003 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1004 | + const char *s6 = "a b c LRO\u202d 1 2 3 PDI\u2069 x y z"; | ||
1005 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1006 | + const char *s7 = "a b c RLOâ® 1 2 3 PDIâ© x y z"; | ||
1007 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1008 | + const char *s8 = "a b c RLO\u202e 1 2 3 PDI\u2069 x y z"; | ||
1009 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1010 | + const char *s9 = "a b c LRI⦠1 2 3 PDF⬠x y z"; | ||
1011 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1012 | + const char *s10 = "a b c LRI\u2066 1 2 3 PDF\u202c x y z"; | ||
1013 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1014 | + const char *s11 = "a b c RLI⧠1 2 3 PDF⬠x y z\ | ||
1015 | + "; | ||
1016 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
1017 | + const char *s12 = "a b c RLI\u2067 1 2 3 PDF\u202c x y z"; | ||
1018 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1019 | + const char *s13 = "a b c FSI⨠1 2 3 PDF⬠x y z"; | ||
1020 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1021 | + const char *s14 = "a b c FSI\u2068 1 2 3 PDF\u202c x y z"; | ||
1022 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1023 | + const char *s15 = "PDF⬠LREâª"; | ||
1024 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1025 | + const char *s16 = "PDF\u202c LRE\u202a"; | ||
1026 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1027 | + const char *s17 = "LRE⪠PDFâ¬"; | ||
1028 | + const char *s18 = "LRE\u202a PDF\u202c"; | ||
1029 | + const char *s19 = "LRE⪠LRE⪠PDF⬠PDFâ¬"; | ||
1030 | + const char *s20 = "LRE\u202a LRE\u202a PDF\u202c PDF\u202c"; | ||
1031 | + const char *s21 = "PDF⬠LRE⪠PDFâ¬"; | ||
1032 | + const char *s22 = "PDF\u202c LRE\u202a PDF\u202c"; | ||
1033 | + const char *s23 = "LRE⪠LRE⪠PDFâ¬"; | ||
1034 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1035 | + const char *s24 = "LRE\u202a LRE\u202a PDF\u202c"; | ||
1036 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1037 | + const char *s25 = "PDF⬠LREâª"; | ||
1038 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1039 | + const char *s26 = "PDF\u202c LRE\u202a"; | ||
1040 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1041 | + const char *s27 = "PDF⬠LRE\u202a"; | ||
1042 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1043 | + const char *s28 = "PDF\u202c LREâª"; | ||
1044 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1045 | +} | ||
1046 | + | ||
1047 | +int aLREâªbPDIâ©; | ||
1048 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1049 | +int A\u202aB\u2069C; | ||
1050 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1051 | +int aRLEâ«bPDIâ©; | ||
1052 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1053 | +int a\u202bB\u2069c; | ||
1054 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1055 | +int aLROâbPDIâ©; | ||
1056 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1057 | +int a\u202db\u2069c2; | ||
1058 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1059 | +int aRLOâ®bPDIâ©; | ||
1060 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1061 | +int a\u202eb\u2069; | ||
1062 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1063 | +int aLRIâ¦bPDFâ¬; | ||
1064 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1065 | +int a\u2066b\u202c; | ||
1066 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1067 | +int aRLIâ§bPDFâ¬c | ||
1068 | +; | ||
1069 | +/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */ | ||
1070 | +int a\u2067b\u202c; | ||
1071 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1072 | +int aFSIâ¨bPDFâ¬; | ||
1073 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1074 | +int a\u2068b\u202c; | ||
1075 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1076 | +int aFSIâ¨bPD\u202C; | ||
1077 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1078 | +int aFSI\u2068bPDFâ¬_; | ||
1079 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1080 | +int aLREâªbPDFâ¬b; | ||
1081 | +int A\u202aB\u202c; | ||
1082 | +int a_LREâª_LREâª_b_PDFâ¬_PDFâ¬; | ||
1083 | +int A\u202aA\u202aB\u202cB\u202c; | ||
1084 | +int aPDFâ¬bLREadPDFâ¬; | ||
1085 | +int a_\u202C_\u202a_\u202c; | ||
1086 | +int a_LREâª_b_PDFâ¬_c_LREâª_PDFâ¬; | ||
1087 | +int a_\u202a_\u202c_\u202a_\u202c_; | ||
1088 | +int a_LREâª_b_PDFâ¬_c_LREâª; | ||
1089 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1090 | +int a_\u202a_\u202c_\u202a_; | ||
1091 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1092 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-7.c b/gcc/testsuite/c-c++-common/Wbidi-chars-7.c | ||
1093 | new file mode 100644 | ||
1094 | index 00000000000..d012d420ec0 | ||
1095 | --- /dev/null | ||
1096 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-7.c | ||
1097 | @@ -0,0 +1,9 @@ | ||
1098 | +/* PR preprocessor/103026 */ | ||
1099 | +/* { dg-do compile } */ | ||
1100 | +/* { dg-options "-Wbidi-chars=any" } */ | ||
1101 | +/* Test we ignore UCNs in comments. */ | ||
1102 | + | ||
1103 | +// a b c \u202a 1 2 3 | ||
1104 | +// a b c \u202A 1 2 3 | ||
1105 | +/* a b c \u202a 1 2 3 */ | ||
1106 | +/* a b c \u202A 1 2 3 */ | ||
1107 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-8.c b/gcc/testsuite/c-c++-common/Wbidi-chars-8.c | ||
1108 | new file mode 100644 | ||
1109 | index 00000000000..4f54c5092ec | ||
1110 | --- /dev/null | ||
1111 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-8.c | ||
1112 | @@ -0,0 +1,13 @@ | ||
1113 | +/* PR preprocessor/103026 */ | ||
1114 | +/* { dg-do compile } */ | ||
1115 | +/* { dg-options "-Wbidi-chars=any" } */ | ||
1116 | +/* Test \u vs \U. */ | ||
1117 | + | ||
1118 | +int a_\u202A; | ||
1119 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
1120 | +int a_\u202a_2; | ||
1121 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
1122 | +int a_\U0000202A_3; | ||
1123 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
1124 | +int a_\U0000202a_4; | ||
1125 | +/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */ | ||
1126 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-9.c b/gcc/testsuite/c-c++-common/Wbidi-chars-9.c | ||
1127 | new file mode 100644 | ||
1128 | index 00000000000..e2af1b1ca97 | ||
1129 | --- /dev/null | ||
1130 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-9.c | ||
1131 | @@ -0,0 +1,29 @@ | ||
1132 | +/* PR preprocessor/103026 */ | ||
1133 | +/* { dg-do compile } */ | ||
1134 | +/* { dg-options "-Wbidi-chars=unpaired" } */ | ||
1135 | +/* Test that we properly separate bidi contexts (comment/identifier/character | ||
1136 | + constant/string literal). */ | ||
1137 | + | ||
1138 | +/* LRE ->âª<- */ int pdf_\u202c_1; | ||
1139 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1140 | +/* RLE ->â«<- */ int pdf_\u202c_2; | ||
1141 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1142 | +/* LRO ->â<- */ int pdf_\u202c_3; | ||
1143 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1144 | +/* RLO ->â®<- */ int pdf_\u202c_4; | ||
1145 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1146 | +/* LRI ->â¦<-*/ int pdi_\u2069_1; | ||
1147 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1148 | +/* RLI ->â§<- */ int pdi_\u2069_12; | ||
1149 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1150 | +/* FSI ->â¨<- */ int pdi_\u2069_3; | ||
1151 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1152 | + | ||
1153 | +const char *s1 = "LRE\u202a"; /* PDF ->â¬<- */ | ||
1154 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1155 | +/* LRE ->âª<- */ const char *s2 = "PDF\u202c"; | ||
1156 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1157 | +const char *s3 = "LRE\u202a"; int pdf_\u202c_5; | ||
1158 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1159 | +int lre_\u202a; const char *s4 = "PDF\u202c"; | ||
1160 | +/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */ | ||
1161 | diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h | ||
1162 | index 176f8c5bbce..112b9c24751 100644 | ||
1163 | --- a/libcpp/include/cpplib.h | ||
1164 | +++ b/libcpp/include/cpplib.h | ||
1165 | @@ -318,6 +318,17 @@ enum cpp_main_search | ||
1166 | CMS_system, /* Search the system INCLUDE path. */ | ||
1167 | }; | ||
1168 | |||
1169 | +/* The possible bidirectional control characters checking levels, from least | ||
1170 | + restrictive to most. */ | ||
1171 | +enum cpp_bidirectional_level { | ||
1172 | + /* No checking. */ | ||
1173 | + bidirectional_none, | ||
1174 | + /* Only detect unpaired uses of bidirectional control characters. */ | ||
1175 | + bidirectional_unpaired, | ||
1176 | + /* Detect any use of bidirectional control characters. */ | ||
1177 | + bidirectional_any | ||
1178 | +}; | ||
1179 | + | ||
1180 | /* This structure is nested inside struct cpp_reader, and | ||
1181 | carries all the options visible to the command line. */ | ||
1182 | struct cpp_options | ||
1183 | @@ -531,6 +542,10 @@ struct cpp_options | ||
1184 | /* True if warn about differences between C++98 and C++11. */ | ||
1185 | bool cpp_warn_cxx11_compat; | ||
1186 | |||
1187 | + /* Nonzero if bidirectional control characters checking is on. See enum | ||
1188 | + cpp_bidirectional_level. */ | ||
1189 | + unsigned char cpp_warn_bidirectional; | ||
1190 | + | ||
1191 | /* Dependency generation. */ | ||
1192 | struct | ||
1193 | { | ||
1194 | @@ -635,7 +650,8 @@ enum cpp_warning_reason { | ||
1195 | CPP_W_C90_C99_COMPAT, | ||
1196 | CPP_W_C11_C2X_COMPAT, | ||
1197 | CPP_W_CXX11_COMPAT, | ||
1198 | - CPP_W_EXPANSION_TO_DEFINED | ||
1199 | + CPP_W_EXPANSION_TO_DEFINED, | ||
1200 | + CPP_W_BIDIRECTIONAL | ||
1201 | }; | ||
1202 | |||
1203 | /* Callback for header lookup for HEADER, which is the name of a | ||
1204 | diff --git a/libcpp/init.c b/libcpp/init.c | ||
1205 | index 5a424e23553..f9a8f5f088f 100644 | ||
1206 | --- a/libcpp/init.c | ||
1207 | +++ b/libcpp/init.c | ||
1208 | @@ -219,6 +219,7 @@ cpp_create_reader (enum c_lang lang, cpp | ||
1209 | = ENABLE_CANONICAL_SYSTEM_HEADERS; | ||
1210 | CPP_OPTION (pfile, ext_numeric_literals) = 1; | ||
1211 | CPP_OPTION (pfile, warn_date_time) = 0; | ||
1212 | + CPP_OPTION (pfile, cpp_warn_bidirectional) = bidirectional_unpaired; | ||
1213 | |||
1214 | /* Default CPP arithmetic to something sensible for the host for the | ||
1215 | benefit of dumb users like fix-header. */ | ||
1216 | diff --git a/libcpp/internal.h b/libcpp/internal.h | ||
1217 | index 8577cab6c83..0ce0246c5a2 100644 | ||
1218 | --- a/libcpp/internal.h | ||
1219 | +++ b/libcpp/internal.h | ||
1220 | @@ -597,6 +597,13 @@ struct cpp_reader | ||
1221 | /* Location identifying the main source file -- intended to be line | ||
1222 | zero of said file. */ | ||
1223 | location_t main_loc; | ||
1224 | + | ||
1225 | + /* Returns true iff we should warn about UTF-8 bidirectional control | ||
1226 | + characters. */ | ||
1227 | + bool warn_bidi_p () const | ||
1228 | + { | ||
1229 | + return CPP_OPTION (this, cpp_warn_bidirectional) != bidirectional_none; | ||
1230 | + } | ||
1231 | }; | ||
1232 | |||
1233 | /* Character classes. Based on the more primitive macros in safe-ctype.h. | ||
1234 | diff --git a/libcpp/lex.c b/libcpp/lex.c | ||
1235 | index fa2253d41c3..6a4fbce6030 100644 | ||
1236 | --- a/libcpp/lex.c | ||
1237 | +++ b/libcpp/lex.c | ||
1238 | @@ -1164,6 +1164,324 @@ _cpp_process_line_notes (cpp_reader *pfi | ||
1239 | } | ||
1240 | } | ||
1241 | |||
1242 | +namespace bidi { | ||
1243 | + enum class kind { | ||
1244 | + NONE, LRE, RLE, LRO, RLO, LRI, RLI, FSI, PDF, PDI, LTR, RTL | ||
1245 | + }; | ||
1246 | + | ||
1247 | + /* All the UTF-8 encodings of bidi characters start with E2. */ | ||
1248 | + constexpr uchar utf8_start = 0xe2; | ||
1249 | + | ||
1250 | + /* A vector holding currently open bidi contexts. We use a char for | ||
1251 | + each context, its LSB is 1 if it represents a PDF context, 0 if it | ||
1252 | + represents a PDI context. The next bit is 1 if this context was open | ||
1253 | + by a bidi character written as a UCN, and 0 when it was UTF-8. */ | ||
1254 | + semi_embedded_vec <unsigned char, 16> vec; | ||
1255 | + | ||
1256 | + /* Close the whole comment/identifier/string literal/character constant | ||
1257 | + context. */ | ||
1258 | + void on_close () | ||
1259 | + { | ||
1260 | + vec.truncate (0); | ||
1261 | + } | ||
1262 | + | ||
1263 | + /* Pop the last element in the vector. */ | ||
1264 | + void pop () | ||
1265 | + { | ||
1266 | + unsigned int len = vec.count (); | ||
1267 | + gcc_checking_assert (len > 0); | ||
1268 | + vec.truncate (len - 1); | ||
1269 | + } | ||
1270 | + | ||
1271 | + /* Return the context of the Ith element. */ | ||
1272 | + kind ctx_at (unsigned int i) | ||
1273 | + { | ||
1274 | + return (vec[i] & 1) ? kind::PDF : kind::PDI; | ||
1275 | + } | ||
1276 | + | ||
1277 | + /* Return which context is currently opened. */ | ||
1278 | + kind current_ctx () | ||
1279 | + { | ||
1280 | + unsigned int len = vec.count (); | ||
1281 | + if (len == 0) | ||
1282 | + return kind::NONE; | ||
1283 | + return ctx_at (len - 1); | ||
1284 | + } | ||
1285 | + | ||
1286 | + /* Return true if the current context comes from a UCN origin, that is, | ||
1287 | + the bidi char which started this bidi context was written as a UCN. */ | ||
1288 | + bool current_ctx_ucn_p () | ||
1289 | + { | ||
1290 | + unsigned int len = vec.count (); | ||
1291 | + gcc_checking_assert (len > 0); | ||
1292 | + return (vec[len - 1] >> 1) & 1; | ||
1293 | + } | ||
1294 | + | ||
1295 | + /* We've read a bidi char, update the current vector as necessary. */ | ||
1296 | + void on_char (kind k, bool ucn_p) | ||
1297 | + { | ||
1298 | + switch (k) | ||
1299 | + { | ||
1300 | + case kind::LRE: | ||
1301 | + case kind::RLE: | ||
1302 | + case kind::LRO: | ||
1303 | + case kind::RLO: | ||
1304 | + vec.push (ucn_p ? 3u : 1u); | ||
1305 | + break; | ||
1306 | + case kind::LRI: | ||
1307 | + case kind::RLI: | ||
1308 | + case kind::FSI: | ||
1309 | + vec.push (ucn_p ? 2u : 0u); | ||
1310 | + break; | ||
1311 | + /* PDF terminates the scope of the last LRE, RLE, LRO, or RLO | ||
1312 | + whose scope has not yet been terminated. */ | ||
1313 | + case kind::PDF: | ||
1314 | + if (current_ctx () == kind::PDF) | ||
1315 | + pop (); | ||
1316 | + break; | ||
1317 | + /* PDI terminates the scope of the last LRI, RLI, or FSI whose | ||
1318 | + scope has not yet been terminated, as well as the scopes of | ||
1319 | + any subsequent LREs, RLEs, LROs, or RLOs whose scopes have not | ||
1320 | + yet been terminated. */ | ||
1321 | + case kind::PDI: | ||
1322 | + for (int i = vec.count () - 1; i >= 0; --i) | ||
1323 | + if (ctx_at (i) == kind::PDI) | ||
1324 | + { | ||
1325 | + vec.truncate (i); | ||
1326 | + break; | ||
1327 | + } | ||
1328 | + break; | ||
1329 | + case kind::LTR: | ||
1330 | + case kind::RTL: | ||
1331 | + /* These aren't popped by a PDF/PDI. */ | ||
1332 | + break; | ||
1333 | + [[likely]] case kind::NONE: | ||
1334 | + break; | ||
1335 | + default: | ||
1336 | + abort (); | ||
1337 | + } | ||
1338 | + } | ||
1339 | + | ||
1340 | + /* Return a descriptive string for K. */ | ||
1341 | + const char *to_str (kind k) | ||
1342 | + { | ||
1343 | + switch (k) | ||
1344 | + { | ||
1345 | + case kind::LRE: | ||
1346 | + return "U+202A (LEFT-TO-RIGHT EMBEDDING)"; | ||
1347 | + case kind::RLE: | ||
1348 | + return "U+202B (RIGHT-TO-LEFT EMBEDDING)"; | ||
1349 | + case kind::LRO: | ||
1350 | + return "U+202D (LEFT-TO-RIGHT OVERRIDE)"; | ||
1351 | + case kind::RLO: | ||
1352 | + return "U+202E (RIGHT-TO-LEFT OVERRIDE)"; | ||
1353 | + case kind::LRI: | ||
1354 | + return "U+2066 (LEFT-TO-RIGHT ISOLATE)"; | ||
1355 | + case kind::RLI: | ||
1356 | + return "U+2067 (RIGHT-TO-LEFT ISOLATE)"; | ||
1357 | + case kind::FSI: | ||
1358 | + return "U+2068 (FIRST STRONG ISOLATE)"; | ||
1359 | + case kind::PDF: | ||
1360 | + return "U+202C (POP DIRECTIONAL FORMATTING)"; | ||
1361 | + case kind::PDI: | ||
1362 | + return "U+2069 (POP DIRECTIONAL ISOLATE)"; | ||
1363 | + case kind::LTR: | ||
1364 | + return "U+200E (LEFT-TO-RIGHT MARK)"; | ||
1365 | + case kind::RTL: | ||
1366 | + return "U+200F (RIGHT-TO-LEFT MARK)"; | ||
1367 | + default: | ||
1368 | + abort (); | ||
1369 | + } | ||
1370 | + } | ||
1371 | +} | ||
1372 | + | ||
1373 | +/* Parse a sequence of 3 bytes starting with P and return its bidi code. */ | ||
1374 | + | ||
1375 | +static bidi::kind | ||
1376 | +get_bidi_utf8 (const unsigned char *const p) | ||
1377 | +{ | ||
1378 | + gcc_checking_assert (p[0] == bidi::utf8_start); | ||
1379 | + | ||
1380 | + if (p[1] == 0x80) | ||
1381 | + switch (p[2]) | ||
1382 | + { | ||
1383 | + case 0xaa: | ||
1384 | + return bidi::kind::LRE; | ||
1385 | + case 0xab: | ||
1386 | + return bidi::kind::RLE; | ||
1387 | + case 0xac: | ||
1388 | + return bidi::kind::PDF; | ||
1389 | + case 0xad: | ||
1390 | + return bidi::kind::LRO; | ||
1391 | + case 0xae: | ||
1392 | + return bidi::kind::RLO; | ||
1393 | + case 0x8e: | ||
1394 | + return bidi::kind::LTR; | ||
1395 | + case 0x8f: | ||
1396 | + return bidi::kind::RTL; | ||
1397 | + default: | ||
1398 | + break; | ||
1399 | + } | ||
1400 | + else if (p[1] == 0x81) | ||
1401 | + switch (p[2]) | ||
1402 | + { | ||
1403 | + case 0xa6: | ||
1404 | + return bidi::kind::LRI; | ||
1405 | + case 0xa7: | ||
1406 | + return bidi::kind::RLI; | ||
1407 | + case 0xa8: | ||
1408 | + return bidi::kind::FSI; | ||
1409 | + case 0xa9: | ||
1410 | + return bidi::kind::PDI; | ||
1411 | + default: | ||
1412 | + break; | ||
1413 | + } | ||
1414 | + | ||
1415 | + return bidi::kind::NONE; | ||
1416 | +} | ||
1417 | + | ||
1418 | +/* Parse a UCN where P points just past \u or \U and return its bidi code. */ | ||
1419 | + | ||
1420 | +static bidi::kind | ||
1421 | +get_bidi_ucn (const unsigned char *p, bool is_U) | ||
1422 | +{ | ||
1423 | + /* 6.4.3 Universal Character Names | ||
1424 | + \u hex-quad | ||
1425 | + \U hex-quad hex-quad | ||
1426 | + where \unnnn means \U0000nnnn. */ | ||
1427 | + | ||
1428 | + if (is_U) | ||
1429 | + { | ||
1430 | + if (p[0] != '0' || p[1] != '0' || p[2] != '0' || p[3] != '0') | ||
1431 | + return bidi::kind::NONE; | ||
1432 | + /* Skip 4B so we can treat \u and \U the same below. */ | ||
1433 | + p += 4; | ||
1434 | + } | ||
1435 | + | ||
1436 | + /* All code points we are looking for start with 20xx. */ | ||
1437 | + if (p[0] != '2' || p[1] != '0') | ||
1438 | + return bidi::kind::NONE; | ||
1439 | + else if (p[2] == '2') | ||
1440 | + switch (p[3]) | ||
1441 | + { | ||
1442 | + case 'a': | ||
1443 | + case 'A': | ||
1444 | + return bidi::kind::LRE; | ||
1445 | + case 'b': | ||
1446 | + case 'B': | ||
1447 | + return bidi::kind::RLE; | ||
1448 | + case 'c': | ||
1449 | + case 'C': | ||
1450 | + return bidi::kind::PDF; | ||
1451 | + case 'd': | ||
1452 | + case 'D': | ||
1453 | + return bidi::kind::LRO; | ||
1454 | + case 'e': | ||
1455 | + case 'E': | ||
1456 | + return bidi::kind::RLO; | ||
1457 | + default: | ||
1458 | + break; | ||
1459 | + } | ||
1460 | + else if (p[2] == '6') | ||
1461 | + switch (p[3]) | ||
1462 | + { | ||
1463 | + case '6': | ||
1464 | + return bidi::kind::LRI; | ||
1465 | + case '7': | ||
1466 | + return bidi::kind::RLI; | ||
1467 | + case '8': | ||
1468 | + return bidi::kind::FSI; | ||
1469 | + case '9': | ||
1470 | + return bidi::kind::PDI; | ||
1471 | + default: | ||
1472 | + break; | ||
1473 | + } | ||
1474 | + else if (p[2] == '0') | ||
1475 | + switch (p[3]) | ||
1476 | + { | ||
1477 | + case 'e': | ||
1478 | + case 'E': | ||
1479 | + return bidi::kind::LTR; | ||
1480 | + case 'f': | ||
1481 | + case 'F': | ||
1482 | + return bidi::kind::RTL; | ||
1483 | + default: | ||
1484 | + break; | ||
1485 | + } | ||
1486 | + | ||
1487 | + return bidi::kind::NONE; | ||
1488 | +} | ||
1489 | + | ||
1490 | +/* We're closing a bidi context, that is, we've encountered a newline, | ||
1491 | + are closing a C-style comment, or are at the end of a string literal, | ||
1492 | + character constant, or identifier. Warn if this context was not | ||
1493 | + properly terminated by a PDI or PDF. P points to the last character | ||
1494 | + in this context. */ | ||
1495 | + | ||
1496 | +static void | ||
1497 | +maybe_warn_bidi_on_close (cpp_reader *pfile, const uchar *p) | ||
1498 | +{ | ||
1499 | + if (CPP_OPTION (pfile, cpp_warn_bidirectional) == bidirectional_unpaired | ||
1500 | + && bidi::vec.count () > 0) | ||
1501 | + { | ||
1502 | + const location_t loc | ||
1503 | + = linemap_position_for_column (pfile->line_table, | ||
1504 | + CPP_BUF_COLUMN (pfile->buffer, p)); | ||
1505 | + cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
1506 | + "unpaired UTF-8 bidirectional control character " | ||
1507 | + "detected"); | ||
1508 | + } | ||
1509 | + /* We're done with this context. */ | ||
1510 | + bidi::on_close (); | ||
1511 | +} | ||
1512 | + | ||
1513 | +/* We're at the beginning or in the middle of an identifier/comment/string | ||
1514 | + literal/character constant. Warn if we've encountered a bidi character. | ||
1515 | + KIND says which bidi character it was; P points to it in the character | ||
1516 | + stream. UCN_P is true iff this bidi character was written as a UCN. */ | ||
1517 | + | ||
1518 | +static void | ||
1519 | +maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind, | ||
1520 | + bool ucn_p) | ||
1521 | +{ | ||
1522 | + if (__builtin_expect (kind == bidi::kind::NONE, 1)) | ||
1523 | + return; | ||
1524 | + | ||
1525 | + const auto warn_bidi = CPP_OPTION (pfile, cpp_warn_bidirectional); | ||
1526 | + | ||
1527 | + if (warn_bidi != bidirectional_none) | ||
1528 | + { | ||
1529 | + const location_t loc | ||
1530 | + = linemap_position_for_column (pfile->line_table, | ||
1531 | + CPP_BUF_COLUMN (pfile->buffer, p)); | ||
1532 | + /* It seems excessive to warn about a PDI/PDF that is closing | ||
1533 | + an opened context because we've already warned about the | ||
1534 | + opening character. Except warn when we have a UCN x UTF-8 | ||
1535 | + mismatch. */ | ||
1536 | + if (kind == bidi::current_ctx ()) | ||
1537 | + { | ||
1538 | + if (warn_bidi == bidirectional_unpaired | ||
1539 | + && bidi::current_ctx_ucn_p () != ucn_p) | ||
1540 | + cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
1541 | + "UTF-8 vs UCN mismatch when closing " | ||
1542 | + "a context by \"%s\"", bidi::to_str (kind)); | ||
1543 | + } | ||
1544 | + else if (warn_bidi == bidirectional_any) | ||
1545 | + { | ||
1546 | + if (kind == bidi::kind::PDF || kind == bidi::kind::PDI) | ||
1547 | + cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
1548 | + "\"%s\" is closing an unopened context", | ||
1549 | + bidi::to_str (kind)); | ||
1550 | + else | ||
1551 | + cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
1552 | + "found problematic Unicode character \"%s\"", | ||
1553 | + bidi::to_str (kind)); | ||
1554 | + } | ||
1555 | + } | ||
1556 | + /* We're done with this context. */ | ||
1557 | + bidi::on_char (kind, ucn_p); | ||
1558 | +} | ||
1559 | + | ||
1560 | /* Skip a C-style block comment. We find the end of the comment by | ||
1561 | seeing if an asterisk is before every '/' we encounter. Returns | ||
1562 | nonzero if comment terminated by EOF, zero otherwise. | ||
1563 | @@ -1175,6 +1493,7 @@ _cpp_skip_block_comment (cpp_reader *pfi | ||
1564 | cpp_buffer *buffer = pfile->buffer; | ||
1565 | const uchar *cur = buffer->cur; | ||
1566 | uchar c; | ||
1567 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1568 | |||
1569 | cur++; | ||
1570 | if (*cur == '/') | ||
1571 | @@ -1189,7 +1508,11 @@ _cpp_skip_block_comment (cpp_reader *pfi | ||
1572 | if (c == '/') | ||
1573 | { | ||
1574 | if (cur[-2] == '*') | ||
1575 | - break; | ||
1576 | + { | ||
1577 | + if (warn_bidi_p) | ||
1578 | + maybe_warn_bidi_on_close (pfile, cur); | ||
1579 | + break; | ||
1580 | + } | ||
1581 | |||
1582 | /* Warn about potential nested comments, but not if the '/' | ||
1583 | comes immediately before the true comment delimiter. | ||
1584 | @@ -1208,6 +1531,8 @@ _cpp_skip_block_comment (cpp_reader *pfi | ||
1585 | { | ||
1586 | unsigned int cols; | ||
1587 | buffer->cur = cur - 1; | ||
1588 | + if (warn_bidi_p) | ||
1589 | + maybe_warn_bidi_on_close (pfile, cur); | ||
1590 | _cpp_process_line_notes (pfile, true); | ||
1591 | if (buffer->next_line >= buffer->rlimit) | ||
1592 | return true; | ||
1593 | @@ -1218,6 +1543,13 @@ _cpp_skip_block_comment (cpp_reader *pfi | ||
1594 | |||
1595 | cur = buffer->cur; | ||
1596 | } | ||
1597 | + /* If this is a beginning of a UTF-8 encoding, it might be | ||
1598 | + a bidirectional control character. */ | ||
1599 | + else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p) | ||
1600 | + { | ||
1601 | + bidi::kind kind = get_bidi_utf8 (cur - 1); | ||
1602 | + maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/false); | ||
1603 | + } | ||
1604 | } | ||
1605 | |||
1606 | buffer->cur = cur; | ||
1607 | @@ -1233,9 +1565,31 @@ skip_line_comment (cpp_reader *pfile) | ||
1608 | { | ||
1609 | cpp_buffer *buffer = pfile->buffer; | ||
1610 | location_t orig_line = pfile->line_table->highest_line; | ||
1611 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1612 | |||
1613 | - while (*buffer->cur != '\n') | ||
1614 | - buffer->cur++; | ||
1615 | + if (!warn_bidi_p) | ||
1616 | + while (*buffer->cur != '\n') | ||
1617 | + buffer->cur++; | ||
1618 | + else | ||
1619 | + { | ||
1620 | + while (*buffer->cur != '\n' | ||
1621 | + && *buffer->cur != bidi::utf8_start) | ||
1622 | + buffer->cur++; | ||
1623 | + if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0)) | ||
1624 | + { | ||
1625 | + while (*buffer->cur != '\n') | ||
1626 | + { | ||
1627 | + if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0)) | ||
1628 | + { | ||
1629 | + bidi::kind kind = get_bidi_utf8 (buffer->cur); | ||
1630 | + maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
1631 | + /*ucn_p=*/false); | ||
1632 | + } | ||
1633 | + buffer->cur++; | ||
1634 | + } | ||
1635 | + maybe_warn_bidi_on_close (pfile, buffer->cur); | ||
1636 | + } | ||
1637 | + } | ||
1638 | |||
1639 | _cpp_process_line_notes (pfile, true); | ||
1640 | return orig_line != pfile->line_table->highest_line; | ||
1641 | @@ -1317,11 +1671,13 @@ static const cppchar_t utf8_signifier = | ||
1642 | |||
1643 | /* Returns TRUE if the sequence starting at buffer->cur is valid in | ||
1644 | an identifier. FIRST is TRUE if this starts an identifier. */ | ||
1645 | + | ||
1646 | static bool | ||
1647 | forms_identifier_p (cpp_reader *pfile, int first, | ||
1648 | struct normalize_state *state) | ||
1649 | { | ||
1650 | cpp_buffer *buffer = pfile->buffer; | ||
1651 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1652 | |||
1653 | if (*buffer->cur == '$') | ||
1654 | { | ||
1655 | @@ -1344,6 +1700,13 @@ forms_identifier_p (cpp_reader *pfile, i | ||
1656 | cppchar_t s; | ||
1657 | if (*buffer->cur >= utf8_signifier) | ||
1658 | { | ||
1659 | + if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0) | ||
1660 | + && warn_bidi_p) | ||
1661 | + { | ||
1662 | + bidi::kind kind = get_bidi_utf8 (buffer->cur); | ||
1663 | + maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
1664 | + /*ucn_p=*/false); | ||
1665 | + } | ||
1666 | if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first, | ||
1667 | state, &s)) | ||
1668 | return true; | ||
1669 | @@ -1352,6 +1715,13 @@ forms_identifier_p (cpp_reader *pfile, i | ||
1670 | && (buffer->cur[1] == 'u' || buffer->cur[1] == 'U')) | ||
1671 | { | ||
1672 | buffer->cur += 2; | ||
1673 | + if (warn_bidi_p) | ||
1674 | + { | ||
1675 | + bidi::kind kind = get_bidi_ucn (buffer->cur, | ||
1676 | + buffer->cur[-1] == 'U'); | ||
1677 | + maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
1678 | + /*ucn_p=*/true); | ||
1679 | + } | ||
1680 | if (_cpp_valid_ucn (pfile, &buffer->cur, buffer->rlimit, 1 + !first, | ||
1681 | state, &s, NULL, NULL)) | ||
1682 | return true; | ||
1683 | @@ -1460,6 +1830,7 @@ lex_identifier (cpp_reader *pfile, const | ||
1684 | const uchar *cur; | ||
1685 | unsigned int len; | ||
1686 | unsigned int hash = HT_HASHSTEP (0, *base); | ||
1687 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1688 | |||
1689 | cur = pfile->buffer->cur; | ||
1690 | if (! starts_ucn) | ||
1691 | @@ -1483,6 +1854,8 @@ lex_identifier (cpp_reader *pfile, const | ||
1692 | pfile->buffer->cur++; | ||
1693 | } | ||
1694 | } while (forms_identifier_p (pfile, false, nst)); | ||
1695 | + if (warn_bidi_p) | ||
1696 | + maybe_warn_bidi_on_close (pfile, pfile->buffer->cur); | ||
1697 | result = _cpp_interpret_identifier (pfile, base, | ||
1698 | pfile->buffer->cur - base); | ||
1699 | *spelling = cpp_lookup (pfile, base, pfile->buffer->cur - base); | ||
1700 | @@ -1719,6 +2092,7 @@ static void | ||
1701 | lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base) | ||
1702 | { | ||
1703 | const uchar *pos = base; | ||
1704 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1705 | |||
1706 | /* 'tis a pity this information isn't passed down from the lexer's | ||
1707 | initial categorization of the token. */ | ||
1708 | @@ -1955,8 +2329,15 @@ lex_raw_string (cpp_reader *pfile, cpp_t | ||
1709 | pos = base = pfile->buffer->cur; | ||
1710 | note = &pfile->buffer->notes[pfile->buffer->cur_note]; | ||
1711 | } | ||
1712 | + else if (__builtin_expect ((unsigned char) c == bidi::utf8_start, 0) | ||
1713 | + && warn_bidi_p) | ||
1714 | + maybe_warn_bidi_on_char (pfile, pos - 1, get_bidi_utf8 (pos - 1), | ||
1715 | + /*ucn_p=*/false); | ||
1716 | } | ||
1717 | |||
1718 | + if (warn_bidi_p) | ||
1719 | + maybe_warn_bidi_on_close (pfile, pos); | ||
1720 | + | ||
1721 | if (CPP_OPTION (pfile, user_literals)) | ||
1722 | { | ||
1723 | /* If a string format macro, say from inttypes.h, is placed touching | ||
1724 | @@ -2051,15 +2432,27 @@ lex_string (cpp_reader *pfile, cpp_token | ||
1725 | else | ||
1726 | terminator = '>', type = CPP_HEADER_NAME; | ||
1727 | |||
1728 | + const bool warn_bidi_p = pfile->warn_bidi_p (); | ||
1729 | for (;;) | ||
1730 | { | ||
1731 | cppchar_t c = *cur++; | ||
1732 | |||
1733 | /* In #include-style directives, terminators are not escapable. */ | ||
1734 | if (c == '\\' && !pfile->state.angled_headers && *cur != '\n') | ||
1735 | - cur++; | ||
1736 | + { | ||
1737 | + if ((cur[0] == 'u' || cur[0] == 'U') && warn_bidi_p) | ||
1738 | + { | ||
1739 | + bidi::kind kind = get_bidi_ucn (cur + 1, cur[0] == 'U'); | ||
1740 | + maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/true); | ||
1741 | + } | ||
1742 | + cur++; | ||
1743 | + } | ||
1744 | else if (c == terminator) | ||
1745 | - break; | ||
1746 | + { | ||
1747 | + if (warn_bidi_p) | ||
1748 | + maybe_warn_bidi_on_close (pfile, cur - 1); | ||
1749 | + break; | ||
1750 | + } | ||
1751 | else if (c == '\n') | ||
1752 | { | ||
1753 | cur--; | ||
1754 | @@ -2076,6 +2469,11 @@ lex_string (cpp_reader *pfile, cpp_token | ||
1755 | } | ||
1756 | else if (c == '\0') | ||
1757 | saw_NUL = true; | ||
1758 | + else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p) | ||
1759 | + { | ||
1760 | + bidi::kind kind = get_bidi_utf8 (cur - 1); | ||
1761 | + maybe_warn_bidi_on_char (pfile, cur - 1, kind, /*ucn_p=*/false); | ||
1762 | + } | ||
1763 | } | ||
1764 | |||
1765 | if (saw_NUL && !pfile->state.skipping) | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch index d19cefbdf9..5a51ae7d96 100644 --- a/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch +++ b/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 863f1f9dc78839ecd021b2cb01d501e8c9e00ef7 Mon Sep 17 00:00:00 2001 | 1 | From e1dbdcd0ea667bab4b551294354e04c6fe288ab6 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Mon, 8 Mar 2021 16:04:20 -0800 | 3 | Date: Mon, 8 Mar 2021 16:04:20 -0800 |
4 | Subject: [PATCH] gcc: poison-system-directories | 4 | Subject: [PATCH] gcc: poison-system-directories |
@@ -20,15 +20,15 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
20 | gcc/configure | 19 +++++++++++++++++++ | 20 | gcc/configure | 19 +++++++++++++++++++ |
21 | gcc/configure.ac | 16 ++++++++++++++++ | 21 | gcc/configure.ac | 16 ++++++++++++++++ |
22 | gcc/doc/invoke.texi | 9 +++++++++ | 22 | gcc/doc/invoke.texi | 9 +++++++++ |
23 | gcc/gcc.c | 9 +++++++-- | 23 | gcc/gcc.cc | 9 +++++++-- |
24 | gcc/incpath.c | 21 +++++++++++++++++++++ | 24 | gcc/incpath.cc | 21 +++++++++++++++++++++ |
25 | 7 files changed, 86 insertions(+), 2 deletions(-) | 25 | 7 files changed, 86 insertions(+), 2 deletions(-) |
26 | 26 | ||
27 | diff --git a/gcc/common.opt b/gcc/common.opt | 27 | diff --git a/gcc/common.opt b/gcc/common.opt |
28 | index a75b44ee47e..d15105a73f3 100644 | 28 | index 8a0dafc522d..0357868e22c 100644 |
29 | --- a/gcc/common.opt | 29 | --- a/gcc/common.opt |
30 | +++ b/gcc/common.opt | 30 | +++ b/gcc/common.opt |
31 | @@ -683,6 +683,10 @@ Wreturn-local-addr | 31 | @@ -710,6 +710,10 @@ Wreturn-local-addr |
32 | Common Var(warn_return_local_addr) Init(1) Warning | 32 | Common Var(warn_return_local_addr) Init(1) Warning |
33 | Warn about returning a pointer/reference to a local or temporary variable. | 33 | Warn about returning a pointer/reference to a local or temporary variable. |
34 | 34 | ||
@@ -40,7 +40,7 @@ index a75b44ee47e..d15105a73f3 100644 | |||
40 | Common Var(warn_shadow) Warning | 40 | Common Var(warn_shadow) Warning |
41 | Warn when one variable shadows another. Same as -Wshadow=global. | 41 | Warn when one variable shadows another. Same as -Wshadow=global. |
42 | diff --git a/gcc/config.in b/gcc/config.in | 42 | diff --git a/gcc/config.in b/gcc/config.in |
43 | index 048bf52e8c2..4f973f7906a 100644 | 43 | index 64c27c9cfac..a693cb8a886 100644 |
44 | --- a/gcc/config.in | 44 | --- a/gcc/config.in |
45 | +++ b/gcc/config.in | 45 | +++ b/gcc/config.in |
46 | @@ -230,6 +230,16 @@ | 46 | @@ -230,6 +230,16 @@ |
@@ -61,10 +61,10 @@ index 048bf52e8c2..4f973f7906a 100644 | |||
61 | optimizer and back end) to be checked for dynamic type safety at runtime. | 61 | optimizer and back end) to be checked for dynamic type safety at runtime. |
62 | This is quite expensive. */ | 62 | This is quite expensive. */ |
63 | diff --git a/gcc/configure b/gcc/configure | 63 | diff --git a/gcc/configure b/gcc/configure |
64 | index 7218b0c331a..d7445339f9a 100755 | 64 | index 5ce0557719a..dc2d59701ad 100755 |
65 | --- a/gcc/configure | 65 | --- a/gcc/configure |
66 | +++ b/gcc/configure | 66 | +++ b/gcc/configure |
67 | @@ -1019,6 +1019,7 @@ enable_maintainer_mode | 67 | @@ -1023,6 +1023,7 @@ enable_maintainer_mode |
68 | enable_link_mutex | 68 | enable_link_mutex |
69 | enable_link_serialization | 69 | enable_link_serialization |
70 | enable_version_specific_runtime_libs | 70 | enable_version_specific_runtime_libs |
@@ -72,7 +72,7 @@ index 7218b0c331a..d7445339f9a 100755 | |||
72 | enable_plugin | 72 | enable_plugin |
73 | enable_host_shared | 73 | enable_host_shared |
74 | enable_libquadmath_support | 74 | enable_libquadmath_support |
75 | @@ -1781,6 +1782,8 @@ Optional Features: | 75 | @@ -1785,6 +1786,8 @@ Optional Features: |
76 | --enable-version-specific-runtime-libs | 76 | --enable-version-specific-runtime-libs |
77 | specify that runtime libraries should be installed | 77 | specify that runtime libraries should be installed |
78 | in a compiler-specific directory | 78 | in a compiler-specific directory |
@@ -81,7 +81,7 @@ index 7218b0c331a..d7445339f9a 100755 | |||
81 | --enable-plugin enable plugin support | 81 | --enable-plugin enable plugin support |
82 | --enable-host-shared build host code as shared libraries | 82 | --enable-host-shared build host code as shared libraries |
83 | --disable-libquadmath-support | 83 | --disable-libquadmath-support |
84 | @@ -31932,6 +31935,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : | 84 | @@ -31982,6 +31985,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : |
85 | fi | 85 | fi |
86 | 86 | ||
87 | 87 | ||
@@ -105,10 +105,10 @@ index 7218b0c331a..d7445339f9a 100755 | |||
105 | 105 | ||
106 | 106 | ||
107 | diff --git a/gcc/configure.ac b/gcc/configure.ac | 107 | diff --git a/gcc/configure.ac b/gcc/configure.ac |
108 | index 49f043ed29b..fe488f2232b 100644 | 108 | index 23bee7010a3..36ce78924de 100644 |
109 | --- a/gcc/configure.ac | 109 | --- a/gcc/configure.ac |
110 | +++ b/gcc/configure.ac | 110 | +++ b/gcc/configure.ac |
111 | @@ -7393,6 +7393,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs, | 111 | @@ -7421,6 +7421,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs, |
112 | [specify that runtime libraries should be | 112 | [specify that runtime libraries should be |
113 | installed in a compiler-specific directory])]) | 113 | installed in a compiler-specific directory])]) |
114 | 114 | ||
@@ -132,10 +132,10 @@ index 49f043ed29b..fe488f2232b 100644 | |||
132 | AC_SUBST(subdirs) | 132 | AC_SUBST(subdirs) |
133 | AC_SUBST(srcdir) | 133 | AC_SUBST(srcdir) |
134 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi | 134 | diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi |
135 | index 35508efb4ef..40f798eac78 100644 | 135 | index 07b440190c3..b2de464798a 100644 |
136 | --- a/gcc/doc/invoke.texi | 136 | --- a/gcc/doc/invoke.texi |
137 | +++ b/gcc/doc/invoke.texi | 137 | +++ b/gcc/doc/invoke.texi |
138 | @@ -369,6 +369,7 @@ Objective-C and Objective-C++ Dialects}. | 138 | @@ -379,6 +379,7 @@ Objective-C and Objective-C++ Dialects}. |
139 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol | 139 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol |
140 | -Wparentheses -Wno-pedantic-ms-format @gol | 140 | -Wparentheses -Wno-pedantic-ms-format @gol |
141 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol | 141 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol |
@@ -143,7 +143,7 @@ index 35508efb4ef..40f798eac78 100644 | |||
143 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol | 143 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol |
144 | -Wrestrict -Wno-return-local-addr -Wreturn-type @gol | 144 | -Wrestrict -Wno-return-local-addr -Wreturn-type @gol |
145 | -Wno-scalar-storage-order -Wsequence-point @gol | 145 | -Wno-scalar-storage-order -Wsequence-point @gol |
146 | @@ -7728,6 +7729,14 @@ made up of data only and thus requires no special treatment. But, for | 146 | @@ -8029,6 +8030,14 @@ made up of data only and thus requires no special treatment. But, for |
147 | most targets, it is made up of code and thus requires the stack to be | 147 | most targets, it is made up of code and thus requires the stack to be |
148 | made executable in order for the program to work properly. | 148 | made executable in order for the program to work properly. |
149 | 149 | ||
@@ -158,11 +158,11 @@ index 35508efb4ef..40f798eac78 100644 | |||
158 | @item -Wfloat-equal | 158 | @item -Wfloat-equal |
159 | @opindex Wfloat-equal | 159 | @opindex Wfloat-equal |
160 | @opindex Wno-float-equal | 160 | @opindex Wno-float-equal |
161 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 161 | diff --git a/gcc/gcc.cc b/gcc/gcc.cc |
162 | index 0af888c7d78..b047fc31c2f 100644 | 162 | index bb07cc244e3..ce161d3c853 100644 |
163 | --- a/gcc/gcc.c | 163 | --- a/gcc/gcc.cc |
164 | +++ b/gcc/gcc.c | 164 | +++ b/gcc/gcc.cc |
165 | @@ -1152,6 +1152,8 @@ proper position among the other output files. */ | 165 | @@ -1159,6 +1159,8 @@ proper position among the other output files. */ |
166 | "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ | 166 | "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ |
167 | "%X %{o*} %{e*} %{N} %{n} %{r}\ | 167 | "%X %{o*} %{e*} %{N} %{n} %{r}\ |
168 | %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ | 168 | %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ |
@@ -171,7 +171,7 @@ index 0af888c7d78..b047fc31c2f 100644 | |||
171 | %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ | 171 | %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ |
172 | VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ | 172 | VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ |
173 | %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ | 173 | %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ |
174 | @@ -1247,8 +1249,11 @@ static const char *cpp_unique_options = | 174 | @@ -1254,8 +1256,11 @@ static const char *cpp_unique_options = |
175 | static const char *cpp_options = | 175 | static const char *cpp_options = |
176 | "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ | 176 | "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ |
177 | %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\ | 177 | %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\ |
@@ -185,10 +185,10 @@ index 0af888c7d78..b047fc31c2f 100644 | |||
185 | 185 | ||
186 | /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al. | 186 | /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al. |
187 | 187 | ||
188 | diff --git a/gcc/incpath.c b/gcc/incpath.c | 188 | diff --git a/gcc/incpath.cc b/gcc/incpath.cc |
189 | index 446d280321d..fbfc0ce03b8 100644 | 189 | index bd2a97938eb..c80f100f476 100644 |
190 | --- a/gcc/incpath.c | 190 | --- a/gcc/incpath.cc |
191 | +++ b/gcc/incpath.c | 191 | +++ b/gcc/incpath.cc |
192 | @@ -26,6 +26,7 @@ | 192 | @@ -26,6 +26,7 @@ |
193 | #include "intl.h" | 193 | #include "intl.h" |
194 | #include "incpath.h" | 194 | #include "incpath.h" |
@@ -197,7 +197,7 @@ index 446d280321d..fbfc0ce03b8 100644 | |||
197 | 197 | ||
198 | /* Microsoft Windows does not natively support inodes. | 198 | /* Microsoft Windows does not natively support inodes. |
199 | VMS has non-numeric inodes. */ | 199 | VMS has non-numeric inodes. */ |
200 | @@ -395,6 +396,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) | 200 | @@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) |
201 | } | 201 | } |
202 | fprintf (stderr, _("End of search list.\n")); | 202 | fprintf (stderr, _("End of search list.\n")); |
203 | } | 203 | } |
diff --git a/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch b/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch index c0e8cbd4d9..e83f05b8aa 100644 --- a/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch +++ b/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From b87a3ac51df372128be2fda992238c5aab4a719a Mon Sep 17 00:00:00 2001 | 1 | From 34b861e7a4cfd7b1f0d2c0f8cf9bb0b0b81eb61a Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:10:06 +0400 | 3 | Date: Fri, 29 Mar 2013 09:10:06 +0400 |
4 | Subject: [PATCH] 64-bit multilib hack. | 4 | Subject: [PATCH] 64-bit multilib hack. |
@@ -28,6 +28,7 @@ Upstream-Status: Inappropriate [OE-Specific] | |||
28 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 28 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
29 | Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com> | 29 | Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com> |
30 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> | 30 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> |
31 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
31 | --- | 32 | --- |
32 | gcc/config/aarch64/t-aarch64-linux | 8 ++++---- | 33 | gcc/config/aarch64/t-aarch64-linux | 8 ++++---- |
33 | gcc/config/arc/t-multilib-linux | 4 ++-- | 34 | gcc/config/arc/t-multilib-linux | 4 ++-- |
@@ -38,7 +39,7 @@ Signed-off-by: Mark Hatle <mark.hatle@windriver.com> | |||
38 | 6 files changed, 17 insertions(+), 22 deletions(-) | 39 | 6 files changed, 17 insertions(+), 22 deletions(-) |
39 | 40 | ||
40 | diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux | 41 | diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux |
41 | index 241b0ef20b6..a7dadb2d64f 100644 | 42 | index d0cd546002a..f4056d68372 100644 |
42 | --- a/gcc/config/aarch64/t-aarch64-linux | 43 | --- a/gcc/config/aarch64/t-aarch64-linux |
43 | +++ b/gcc/config/aarch64/t-aarch64-linux | 44 | +++ b/gcc/config/aarch64/t-aarch64-linux |
44 | @@ -21,8 +21,8 @@ | 45 | @@ -21,8 +21,8 @@ |
@@ -55,7 +56,7 @@ index 241b0ef20b6..a7dadb2d64f 100644 | |||
55 | -MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) | 56 | -MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) |
56 | +#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) | 57 | +#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) |
57 | diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux | 58 | diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux |
58 | index fc3fff640a2..d58e28f6df8 100644 | 59 | index ecb9ae6859f..12a164028d4 100644 |
59 | --- a/gcc/config/arc/t-multilib-linux | 60 | --- a/gcc/config/arc/t-multilib-linux |
60 | +++ b/gcc/config/arc/t-multilib-linux | 61 | +++ b/gcc/config/arc/t-multilib-linux |
61 | @@ -16,9 +16,9 @@ | 62 | @@ -16,9 +16,9 @@ |
@@ -71,7 +72,7 @@ index fc3fff640a2..d58e28f6df8 100644 | |||
71 | # Aliases: | 72 | # Aliases: |
72 | MULTILIB_MATCHES += mcpu?arc700=mA7 | 73 | MULTILIB_MATCHES += mcpu?arc700=mA7 |
73 | diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 | 74 | diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 |
74 | index d288b093522..7b5980a9d21 100644 | 75 | index 5526ad0e6cc..fa51c88912b 100644 |
75 | --- a/gcc/config/i386/t-linux64 | 76 | --- a/gcc/config/i386/t-linux64 |
76 | +++ b/gcc/config/i386/t-linux64 | 77 | +++ b/gcc/config/i386/t-linux64 |
77 | @@ -32,7 +32,5 @@ | 78 | @@ -32,7 +32,5 @@ |
@@ -85,7 +86,7 @@ index d288b093522..7b5980a9d21 100644 | |||
85 | +MULTILIB_DIRNAMES = . . | 86 | +MULTILIB_DIRNAMES = . . |
86 | +MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) | 87 | +MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) |
87 | diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 | 88 | diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 |
88 | index 130e1f04707..3b7eb6b2a2f 100644 | 89 | index 2fdd8e00407..04f2099250f 100644 |
89 | --- a/gcc/config/mips/t-linux64 | 90 | --- a/gcc/config/mips/t-linux64 |
90 | +++ b/gcc/config/mips/t-linux64 | 91 | +++ b/gcc/config/mips/t-linux64 |
91 | @@ -17,10 +17,6 @@ | 92 | @@ -17,10 +17,6 @@ |
@@ -115,7 +116,7 @@ index 216d2776a18..e4d817621fc 100644 | |||
115 | +#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) | 116 | +#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) |
116 | +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) | 117 | +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) |
117 | diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 | 118 | diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 |
118 | index e11a118cb5f..4eaffb416fe 100644 | 119 | index 47e0efd5764..05f5a3f188e 100644 |
119 | --- a/gcc/config/rs6000/t-linux64 | 120 | --- a/gcc/config/rs6000/t-linux64 |
120 | +++ b/gcc/config/rs6000/t-linux64 | 121 | +++ b/gcc/config/rs6000/t-linux64 |
121 | @@ -26,10 +26,9 @@ | 122 | @@ -26,10 +26,9 @@ |
@@ -129,5 +130,5 @@ index e11a118cb5f..4eaffb416fe 100644 | |||
129 | -MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) | 130 | -MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) |
130 | +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) | 131 | +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) |
131 | 132 | ||
132 | rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c | 133 | rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc |
133 | $(COMPILE) $< | 134 | $(COMPILE) $< |
diff --git a/meta/recipes-devtools/gcc/gcc/0003-CVE-2021-42574.patch b/meta/recipes-devtools/gcc/gcc/0003-CVE-2021-42574.patch deleted file mode 100644 index 2995a6fc61..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0003-CVE-2021-42574.patch +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | From 1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3 Mon Sep 17 00:00:00 2001 | ||
2 | From: David Malcolm <dmalcolm@redhat.com> | ||
3 | Date: Tue, 2 Nov 2021 09:54:32 -0400 | ||
4 | Subject: [PATCH] libcpp: escape non-ASCII source bytes in -Wbidi-chars= | ||
5 | [PR103026] | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=utf8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | This flags rich_locations associated with -Wbidi-chars= so that | ||
11 | non-ASCII bytes will be escaped when printing the source lines | ||
12 | (using the diagnostics support I added in | ||
13 | r12-4825-gbd5e882cf6e0def3dd1bc106075d59a303fe0d1e). | ||
14 | |||
15 | In particular, this ensures that the printed source lines will | ||
16 | be pure ASCII, and thus the visual ordering of the characters | ||
17 | will be the same as the logical ordering. | ||
18 | |||
19 | Before: | ||
20 | |||
21 | Wbidi-chars-1.c: In function âmainâ: | ||
22 | Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
23 | 6 | /*â® } â¦if (isAdmin)⩠⦠begin admins only */ | ||
24 | | ^ | ||
25 | Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
26 | 9 | /* end admins only â® { â¦*/ | ||
27 | | ^ | ||
28 | |||
29 | Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
30 | 6 | int LRE_âª_PDF_\u202c; | ||
31 | | ^ | ||
32 | Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
33 | 8 | int LRE_\u202a_PDF_â¬_; | ||
34 | | ^ | ||
35 | Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
36 | 10 | const char *s1 = "LRE_âª_PDF_\u202c"; | ||
37 | | ^ | ||
38 | Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
39 | 12 | const char *s2 = "LRE_\u202a_PDF_â¬"; | ||
40 | | ^ | ||
41 | |||
42 | After: | ||
43 | |||
44 | Wbidi-chars-1.c: In function âmainâ: | ||
45 | Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
46 | 6 | /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */ | ||
47 | | ^ | ||
48 | Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
49 | 9 | /* end admins only <U+202E> { <U+2066>*/ | ||
50 | | ^ | ||
51 | |||
52 | Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
53 | 6 | int LRE_<U+202A>_PDF_\u202c; | ||
54 | | ^ | ||
55 | Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
56 | 8 | int LRE_\u202a_PDF_<U+202C>_; | ||
57 | | ^ | ||
58 | Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
59 | 10 | const char *s1 = "LRE_<U+202A>_PDF_\u202c"; | ||
60 | | ^ | ||
61 | Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=] | ||
62 | 12 | const char *s2 = "LRE_\u202a_PDF_<U+202C>"; | ||
63 | | ^ | ||
64 | |||
65 | libcpp/ChangeLog: | ||
66 | PR preprocessor/103026 | ||
67 | * lex.c (maybe_warn_bidi_on_close): Use a rich_location | ||
68 | and call set_escape_on_output (true) on it. | ||
69 | (maybe_warn_bidi_on_char): Likewise. | ||
70 | |||
71 | Signed-off-by: David Malcolm <dmalcolm@redhat.com> | ||
72 | |||
73 | CVE: CVE-2021-42574 | ||
74 | Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3] | ||
75 | Signed-off-by: Pgowda <pgowda.cve@gmail.com> | ||
76 | |||
77 | --- | ||
78 | libcpp/lex.c | 29 +++++++++++++++++------------ | ||
79 | 1 file changed, 17 insertions(+), 12 deletions(-) | ||
80 | |||
81 | diff --git a/libcpp/lex.c b/libcpp/lex.c | ||
82 | index 8188e33b07d..2421d6c0f40 100644 | ||
83 | --- a/libcpp/lex.c | ||
84 | +++ b/libcpp/lex.c | ||
85 | @@ -1427,9 +1427,11 @@ maybe_warn_bidi_on_close (cpp_reader *pfile, const uchar *p) | ||
86 | const location_t loc | ||
87 | = linemap_position_for_column (pfile->line_table, | ||
88 | CPP_BUF_COLUMN (pfile->buffer, p)); | ||
89 | - cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
90 | - "unpaired UTF-8 bidirectional control character " | ||
91 | - "detected"); | ||
92 | + rich_location rich_loc (pfile->line_table, loc); | ||
93 | + rich_loc.set_escape_on_output (true); | ||
94 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
95 | + "unpaired UTF-8 bidirectional control character " | ||
96 | + "detected"); | ||
97 | } | ||
98 | /* We're done with this context. */ | ||
99 | bidi::on_close (); | ||
100 | @@ -1454,6 +1456,9 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind, | ||
101 | const location_t loc | ||
102 | = linemap_position_for_column (pfile->line_table, | ||
103 | CPP_BUF_COLUMN (pfile->buffer, p)); | ||
104 | + rich_location rich_loc (pfile->line_table, loc); | ||
105 | + rich_loc.set_escape_on_output (true); | ||
106 | + | ||
107 | /* It seems excessive to warn about a PDI/PDF that is closing | ||
108 | an opened context because we've already warned about the | ||
109 | opening character. Except warn when we have a UCN x UTF-8 | ||
110 | @@ -1462,20 +1467,20 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind, | ||
111 | { | ||
112 | if (warn_bidi == bidirectional_unpaired | ||
113 | && bidi::current_ctx_ucn_p () != ucn_p) | ||
114 | - cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
115 | - "UTF-8 vs UCN mismatch when closing " | ||
116 | - "a context by \"%s\"", bidi::to_str (kind)); | ||
117 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
118 | + "UTF-8 vs UCN mismatch when closing " | ||
119 | + "a context by \"%s\"", bidi::to_str (kind)); | ||
120 | } | ||
121 | else if (warn_bidi == bidirectional_any) | ||
122 | { | ||
123 | if (kind == bidi::kind::PDF || kind == bidi::kind::PDI) | ||
124 | - cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
125 | - "\"%s\" is closing an unopened context", | ||
126 | - bidi::to_str (kind)); | ||
127 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
128 | + "\"%s\" is closing an unopened context", | ||
129 | + bidi::to_str (kind)); | ||
130 | else | ||
131 | - cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0, | ||
132 | - "found problematic Unicode character \"%s\"", | ||
133 | - bidi::to_str (kind)); | ||
134 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
135 | + "found problematic Unicode character \"%s\"", | ||
136 | + bidi::to_str (kind)); | ||
137 | } | ||
138 | } | ||
139 | /* We're done with this context. */ | ||
140 | -- | ||
141 | 2.27.0 | ||
142 | |||
diff --git a/meta/recipes-devtools/gcc/gcc/0004-CVE-2021-42574.patch b/meta/recipes-devtools/gcc/gcc/0004-CVE-2021-42574.patch deleted file mode 100644 index 4999c71b64..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0004-CVE-2021-42574.patch +++ /dev/null | |||
@@ -1,573 +0,0 @@ | |||
1 | From bef32d4a28595e933f24fef378cf052a30b674a7 Mon Sep 17 00:00:00 2001 | ||
2 | From: David Malcolm <dmalcolm@redhat.com> | ||
3 | Date: Tue, 2 Nov 2021 15:45:22 -0400 | ||
4 | Subject: [PATCH] libcpp: capture and underline ranges in -Wbidi-chars= | ||
5 | [PR103026] | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=utf8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | This patch converts the bidi::vec to use a struct so that we can | ||
11 | capture location_t values for the bidirectional control characters. | ||
12 | |||
13 | Before: | ||
14 | |||
15 | Wbidi-chars-1.c: In function âmainâ: | ||
16 | Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
17 | 6 | /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */ | ||
18 | | ^ | ||
19 | Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=] | ||
20 | 9 | /* end admins only <U+202E> { <U+2066>*/ | ||
21 | | ^ | ||
22 | |||
23 | After: | ||
24 | |||
25 | Wbidi-chars-1.c: In function âmainâ: | ||
26 | Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control characters detected [-Wbidi-chars=] | ||
27 | 6 | /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */ | ||
28 | | ~~~~~~~~ ~~~~~~~~ ^ | ||
29 | | | | | | ||
30 | | | | end of bidirectional context | ||
31 | | U+202E (RIGHT-TO-LEFT OVERRIDE) U+2066 (LEFT-TO-RIGHT ISOLATE) | ||
32 | Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control characters detected [-Wbidi-chars=] | ||
33 | 9 | /* end admins only <U+202E> { <U+2066>*/ | ||
34 | | ~~~~~~~~ ~~~~~~~~ ^ | ||
35 | | | | | | ||
36 | | | | end of bidirectional context | ||
37 | | | U+2066 (LEFT-TO-RIGHT ISOLATE) | ||
38 | | U+202E (RIGHT-TO-LEFT OVERRIDE) | ||
39 | |||
40 | Signed-off-by: David Malcolm <dmalcolm@redhat.com> | ||
41 | |||
42 | gcc/testsuite/ChangeLog: | ||
43 | PR preprocessor/103026 | ||
44 | * c-c++-common/Wbidi-chars-ranges.c: New test. | ||
45 | |||
46 | libcpp/ChangeLog: | ||
47 | PR preprocessor/103026 | ||
48 | * lex.c (struct bidi::context): New. | ||
49 | (bidi::vec): Convert to a vec of context rather than unsigned | ||
50 | char. | ||
51 | (bidi::ctx_at): Rename to... | ||
52 | (bidi::pop_kind_at): ...this and reimplement for above change. | ||
53 | (bidi::current_ctx): Update for change to vec. | ||
54 | (bidi::current_ctx_ucn_p): Likewise. | ||
55 | (bidi::current_ctx_loc): New. | ||
56 | (bidi::on_char): Update for usage of context struct. Add "loc" | ||
57 | param and pass it when pushing contexts. | ||
58 | (get_location_for_byte_range_in_cur_line): New. | ||
59 | (get_bidi_utf8): Rename to... | ||
60 | (get_bidi_utf8_1): ...this, reintroducing... | ||
61 | (get_bidi_utf8): ...as a wrapper, setting *OUT when the result is | ||
62 | not NONE. | ||
63 | (get_bidi_ucn): Rename to... | ||
64 | (get_bidi_ucn_1): ...this, reintroducing... | ||
65 | (get_bidi_ucn): ...as a wrapper, setting *OUT when the result is | ||
66 | not NONE. | ||
67 | (class unpaired_bidi_rich_location): New. | ||
68 | (maybe_warn_bidi_on_close): Use unpaired_bidi_rich_location when | ||
69 | reporting on unpaired bidi chars. Split into singular vs plural | ||
70 | spellings. | ||
71 | (maybe_warn_bidi_on_char): Pass in a location_t rather than a | ||
72 | const uchar * and use it when emitting warnings, and when calling | ||
73 | bidi::on_char. | ||
74 | (_cpp_skip_block_comment): Capture location when kind is not NONE | ||
75 | and pass it to maybe_warn_bidi_on_char. | ||
76 | (skip_line_comment): Likewise. | ||
77 | (forms_identifier_p): Likewise. | ||
78 | (lex_raw_string): Likewise. | ||
79 | (lex_string): Likewise. | ||
80 | |||
81 | Signed-off-by: David Malcolm <dmalcolm@redhat.com> | ||
82 | |||
83 | CVE: CVE-2021-42574 | ||
84 | Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=bef32d4a28595e933f24fef378cf052a30b674a7] | ||
85 | Signed-off-by: Pgowda <pgowda.cve@gmail.com> | ||
86 | |||
87 | --- | ||
88 | .../c-c++-common/Wbidi-chars-ranges.c | 54 ++++ | ||
89 | libcpp/lex.c | 251 ++++++++++++++---- | ||
90 | 2 files changed, 257 insertions(+), 48 deletions(-) | ||
91 | create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c | ||
92 | |||
93 | diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c b/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c | ||
94 | new file mode 100644 | ||
95 | index 00000000000..298750a2a64 | ||
96 | --- /dev/null | ||
97 | +++ b/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c | ||
98 | @@ -0,0 +1,54 @@ | ||
99 | +/* PR preprocessor/103026 */ | ||
100 | +/* { dg-do compile } */ | ||
101 | +/* { dg-options "-Wbidi-chars=unpaired -fdiagnostics-show-caret" } */ | ||
102 | +/* Verify that we escape and underline pertinent bidirectional | ||
103 | + control characters when quoting the source. */ | ||
104 | + | ||
105 | +int test_unpaired_bidi () { | ||
106 | + int isAdmin = 0; | ||
107 | + /*â® } â¦if (isAdmin)⩠⦠begin admins only */ | ||
108 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
109 | +#if 0 | ||
110 | + { dg-begin-multiline-output "" } | ||
111 | + /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */ | ||
112 | + ~~~~~~~~ ~~~~~~~~ ^ | ||
113 | + | | | | ||
114 | + | | end of bidirectional context | ||
115 | + U+202E (RIGHT-TO-LEFT OVERRIDE) U+2066 (LEFT-TO-RIGHT ISOLATE) | ||
116 | + { dg-end-multiline-output "" } | ||
117 | +#endif | ||
118 | + | ||
119 | + __builtin_printf("You are an admin.\n"); | ||
120 | + /* end admins only â® { â¦*/ | ||
121 | +/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */ | ||
122 | +#if 0 | ||
123 | + { dg-begin-multiline-output "" } | ||
124 | + /* end admins only <U+202E> { <U+2066>*/ | ||
125 | + ~~~~~~~~ ~~~~~~~~ ^ | ||
126 | + | | | | ||
127 | + | | end of bidirectional context | ||
128 | + | U+2066 (LEFT-TO-RIGHT ISOLATE) | ||
129 | + U+202E (RIGHT-TO-LEFT OVERRIDE) | ||
130 | + { dg-end-multiline-output "" } | ||
131 | +#endif | ||
132 | + | ||
133 | + return 0; | ||
134 | +} | ||
135 | + | ||
136 | +int LRE_âª_PDF_\u202c; | ||
137 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
138 | +#if 0 | ||
139 | + { dg-begin-multiline-output "" } | ||
140 | + int LRE_<U+202A>_PDF_\u202c; | ||
141 | + ~~~~~~~~ ^~~~~~ | ||
142 | + { dg-end-multiline-output "" } | ||
143 | +#endif | ||
144 | + | ||
145 | +const char *s1 = "LRE_âª_PDF_\u202c"; | ||
146 | +/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */ | ||
147 | +#if 0 | ||
148 | + { dg-begin-multiline-output "" } | ||
149 | + const char *s1 = "LRE_<U+202A>_PDF_\u202c"; | ||
150 | + ~~~~~~~~ ^~~~~~ | ||
151 | + { dg-end-multiline-output "" } | ||
152 | +#endif | ||
153 | diff --git a/libcpp/lex.c b/libcpp/lex.c | ||
154 | index 2421d6c0f40..94c36f0d014 100644 | ||
155 | --- a/libcpp/lex.c | ||
156 | +++ b/libcpp/lex.c | ||
157 | @@ -1172,11 +1172,34 @@ namespace bidi { | ||
158 | /* All the UTF-8 encodings of bidi characters start with E2. */ | ||
159 | constexpr uchar utf8_start = 0xe2; | ||
160 | |||
161 | + struct context | ||
162 | + { | ||
163 | + context () {} | ||
164 | + context (location_t loc, kind k, bool pdf, bool ucn) | ||
165 | + : m_loc (loc), m_kind (k), m_pdf (pdf), m_ucn (ucn) | ||
166 | + { | ||
167 | + } | ||
168 | + | ||
169 | + kind get_pop_kind () const | ||
170 | + { | ||
171 | + return m_pdf ? kind::PDF : kind::PDI; | ||
172 | + } | ||
173 | + bool ucn_p () const | ||
174 | + { | ||
175 | + return m_ucn; | ||
176 | + } | ||
177 | + | ||
178 | + location_t m_loc; | ||
179 | + kind m_kind; | ||
180 | + unsigned m_pdf : 1; | ||
181 | + unsigned m_ucn : 1; | ||
182 | + }; | ||
183 | + | ||
184 | /* A vector holding currently open bidi contexts. We use a char for | ||
185 | each context, its LSB is 1 if it represents a PDF context, 0 if it | ||
186 | represents a PDI context. The next bit is 1 if this context was open | ||
187 | by a bidi character written as a UCN, and 0 when it was UTF-8. */ | ||
188 | - semi_embedded_vec <unsigned char, 16> vec; | ||
189 | + semi_embedded_vec <context, 16> vec; | ||
190 | |||
191 | /* Close the whole comment/identifier/string literal/character constant | ||
192 | context. */ | ||
193 | @@ -1193,19 +1216,19 @@ namespace bidi { | ||
194 | vec.truncate (len - 1); | ||
195 | } | ||
196 | |||
197 | - /* Return the context of the Ith element. */ | ||
198 | - kind ctx_at (unsigned int i) | ||
199 | + /* Return the pop kind of the context of the Ith element. */ | ||
200 | + kind pop_kind_at (unsigned int i) | ||
201 | { | ||
202 | - return (vec[i] & 1) ? kind::PDF : kind::PDI; | ||
203 | + return vec[i].get_pop_kind (); | ||
204 | } | ||
205 | |||
206 | - /* Return which context is currently opened. */ | ||
207 | + /* Return the pop kind of the context that is currently opened. */ | ||
208 | kind current_ctx () | ||
209 | { | ||
210 | unsigned int len = vec.count (); | ||
211 | if (len == 0) | ||
212 | return kind::NONE; | ||
213 | - return ctx_at (len - 1); | ||
214 | + return vec[len - 1].get_pop_kind (); | ||
215 | } | ||
216 | |||
217 | /* Return true if the current context comes from a UCN origin, that is, | ||
218 | @@ -1214,11 +1237,19 @@ namespace bidi { | ||
219 | { | ||
220 | unsigned int len = vec.count (); | ||
221 | gcc_checking_assert (len > 0); | ||
222 | - return (vec[len - 1] >> 1) & 1; | ||
223 | + return vec[len - 1].m_ucn; | ||
224 | } | ||
225 | |||
226 | - /* We've read a bidi char, update the current vector as necessary. */ | ||
227 | - void on_char (kind k, bool ucn_p) | ||
228 | + location_t current_ctx_loc () | ||
229 | + { | ||
230 | + unsigned int len = vec.count (); | ||
231 | + gcc_checking_assert (len > 0); | ||
232 | + return vec[len - 1].m_loc; | ||
233 | + } | ||
234 | + | ||
235 | + /* We've read a bidi char, update the current vector as necessary. | ||
236 | + LOC is only valid when K is not kind::NONE. */ | ||
237 | + void on_char (kind k, bool ucn_p, location_t loc) | ||
238 | { | ||
239 | switch (k) | ||
240 | { | ||
241 | @@ -1226,12 +1257,12 @@ namespace bidi { | ||
242 | case kind::RLE: | ||
243 | case kind::LRO: | ||
244 | case kind::RLO: | ||
245 | - vec.push (ucn_p ? 3u : 1u); | ||
246 | + vec.push (context (loc, k, true, ucn_p)); | ||
247 | break; | ||
248 | case kind::LRI: | ||
249 | case kind::RLI: | ||
250 | case kind::FSI: | ||
251 | - vec.push (ucn_p ? 2u : 0u); | ||
252 | + vec.push (context (loc, k, false, ucn_p)); | ||
253 | break; | ||
254 | /* PDF terminates the scope of the last LRE, RLE, LRO, or RLO | ||
255 | whose scope has not yet been terminated. */ | ||
256 | @@ -1245,7 +1276,7 @@ namespace bidi { | ||
257 | yet been terminated. */ | ||
258 | case kind::PDI: | ||
259 | for (int i = vec.count () - 1; i >= 0; --i) | ||
260 | - if (ctx_at (i) == kind::PDI) | ||
261 | + if (pop_kind_at (i) == kind::PDI) | ||
262 | { | ||
263 | vec.truncate (i); | ||
264 | break; | ||
265 | @@ -1295,10 +1326,47 @@ namespace bidi { | ||
266 | } | ||
267 | } | ||
268 | |||
269 | +/* Get location_t for the range of bytes [START, START + NUM_BYTES) | ||
270 | + within the current line in FILE, with the caret at START. */ | ||
271 | + | ||
272 | +static location_t | ||
273 | +get_location_for_byte_range_in_cur_line (cpp_reader *pfile, | ||
274 | + const unsigned char *const start, | ||
275 | + size_t num_bytes) | ||
276 | +{ | ||
277 | + gcc_checking_assert (num_bytes > 0); | ||
278 | + | ||
279 | + /* CPP_BUF_COLUMN and linemap_position_for_column both refer | ||
280 | + to offsets in bytes, but CPP_BUF_COLUMN is 0-based, | ||
281 | + whereas linemap_position_for_column is 1-based. */ | ||
282 | + | ||
283 | + /* Get 0-based offsets within the line. */ | ||
284 | + size_t start_offset = CPP_BUF_COLUMN (pfile->buffer, start); | ||
285 | + size_t end_offset = start_offset + num_bytes - 1; | ||
286 | + | ||
287 | + /* Now convert to location_t, where "columns" are 1-based byte offsets. */ | ||
288 | + location_t start_loc = linemap_position_for_column (pfile->line_table, | ||
289 | + start_offset + 1); | ||
290 | + location_t end_loc = linemap_position_for_column (pfile->line_table, | ||
291 | + end_offset + 1); | ||
292 | + | ||
293 | + if (start_loc == end_loc) | ||
294 | + return start_loc; | ||
295 | + | ||
296 | + source_range src_range; | ||
297 | + src_range.m_start = start_loc; | ||
298 | + src_range.m_finish = end_loc; | ||
299 | + location_t combined_loc = COMBINE_LOCATION_DATA (pfile->line_table, | ||
300 | + start_loc, | ||
301 | + src_range, | ||
302 | + NULL); | ||
303 | + return combined_loc; | ||
304 | +} | ||
305 | + | ||
306 | /* Parse a sequence of 3 bytes starting with P and return its bidi code. */ | ||
307 | |||
308 | static bidi::kind | ||
309 | -get_bidi_utf8 (const unsigned char *const p) | ||
310 | +get_bidi_utf8_1 (const unsigned char *const p) | ||
311 | { | ||
312 | gcc_checking_assert (p[0] == bidi::utf8_start); | ||
313 | |||
314 | @@ -1340,10 +1408,25 @@ get_bidi_utf8 (const unsigned char *cons | ||
315 | return bidi::kind::NONE; | ||
316 | } | ||
317 | |||
318 | +/* Parse a sequence of 3 bytes starting with P and return its bidi code. | ||
319 | + If the kind is not NONE, write the location to *OUT.*/ | ||
320 | + | ||
321 | +static bidi::kind | ||
322 | +get_bidi_utf8 (cpp_reader *pfile, const unsigned char *const p, location_t *out) | ||
323 | +{ | ||
324 | + bidi::kind result = get_bidi_utf8_1 (p); | ||
325 | + if (result != bidi::kind::NONE) | ||
326 | + { | ||
327 | + /* We have a sequence of 3 bytes starting at P. */ | ||
328 | + *out = get_location_for_byte_range_in_cur_line (pfile, p, 3); | ||
329 | + } | ||
330 | + return result; | ||
331 | +} | ||
332 | + | ||
333 | /* Parse a UCN where P points just past \u or \U and return its bidi code. */ | ||
334 | |||
335 | static bidi::kind | ||
336 | -get_bidi_ucn (const unsigned char *p, bool is_U) | ||
337 | +get_bidi_ucn_1 (const unsigned char *p, bool is_U) | ||
338 | { | ||
339 | /* 6.4.3 Universal Character Names | ||
340 | \u hex-quad | ||
341 | @@ -1412,6 +1495,62 @@ get_bidi_ucn (const unsigned char *p, bo | ||
342 | return bidi::kind::NONE; | ||
343 | } | ||
344 | |||
345 | +/* Parse a UCN where P points just past \u or \U and return its bidi code. | ||
346 | + If the kind is not NONE, write the location to *OUT.*/ | ||
347 | + | ||
348 | +static bidi::kind | ||
349 | +get_bidi_ucn (cpp_reader *pfile, const unsigned char *p, bool is_U, | ||
350 | + location_t *out) | ||
351 | +{ | ||
352 | + bidi::kind result = get_bidi_ucn_1 (p, is_U); | ||
353 | + if (result != bidi::kind::NONE) | ||
354 | + { | ||
355 | + const unsigned char *start = p - 2; | ||
356 | + size_t num_bytes = 2 + (is_U ? 8 : 4); | ||
357 | + *out = get_location_for_byte_range_in_cur_line (pfile, start, num_bytes); | ||
358 | + } | ||
359 | + return result; | ||
360 | +} | ||
361 | + | ||
362 | +/* Subclass of rich_location for reporting on unpaired UTF-8 | ||
363 | + bidirectional control character(s). | ||
364 | + Escape the source lines on output, and show all unclosed | ||
365 | + bidi context, labelling everything. */ | ||
366 | + | ||
367 | +class unpaired_bidi_rich_location : public rich_location | ||
368 | +{ | ||
369 | + public: | ||
370 | + class custom_range_label : public range_label | ||
371 | + { | ||
372 | + public: | ||
373 | + label_text get_text (unsigned range_idx) const FINAL OVERRIDE | ||
374 | + { | ||
375 | + /* range 0 is the primary location; each subsequent range i + 1 | ||
376 | + is for bidi::vec[i]. */ | ||
377 | + if (range_idx > 0) | ||
378 | + { | ||
379 | + const bidi::context &ctxt (bidi::vec[range_idx - 1]); | ||
380 | + return label_text::borrow (bidi::to_str (ctxt.m_kind)); | ||
381 | + } | ||
382 | + else | ||
383 | + return label_text::borrow (_("end of bidirectional context")); | ||
384 | + } | ||
385 | + }; | ||
386 | + | ||
387 | + unpaired_bidi_rich_location (cpp_reader *pfile, location_t loc) | ||
388 | + : rich_location (pfile->line_table, loc, &m_custom_label) | ||
389 | + { | ||
390 | + set_escape_on_output (true); | ||
391 | + for (unsigned i = 0; i < bidi::vec.count (); i++) | ||
392 | + add_range (bidi::vec[i].m_loc, | ||
393 | + SHOW_RANGE_WITHOUT_CARET, | ||
394 | + &m_custom_label); | ||
395 | + } | ||
396 | + | ||
397 | + private: | ||
398 | + custom_range_label m_custom_label; | ||
399 | +}; | ||
400 | + | ||
401 | /* We're closing a bidi context, that is, we've encountered a newline, | ||
402 | are closing a C-style comment, or are at the end of a string literal, | ||
403 | character constant, or identifier. Warn if this context was not | ||
404 | @@ -1427,11 +1566,17 @@ maybe_warn_bidi_on_close (cpp_reader *pf | ||
405 | const location_t loc | ||
406 | = linemap_position_for_column (pfile->line_table, | ||
407 | CPP_BUF_COLUMN (pfile->buffer, p)); | ||
408 | - rich_location rich_loc (pfile->line_table, loc); | ||
409 | - rich_loc.set_escape_on_output (true); | ||
410 | - cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
411 | - "unpaired UTF-8 bidirectional control character " | ||
412 | - "detected"); | ||
413 | + unpaired_bidi_rich_location rich_loc (pfile, loc); | ||
414 | + /* cpp_callbacks doesn't yet have a way to handle singular vs plural | ||
415 | + forms of a diagnostic, so fake it for now. */ | ||
416 | + if (bidi::vec.count () > 1) | ||
417 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
418 | + "unpaired UTF-8 bidirectional control characters " | ||
419 | + "detected"); | ||
420 | + else | ||
421 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
422 | + "unpaired UTF-8 bidirectional control character " | ||
423 | + "detected"); | ||
424 | } | ||
425 | /* We're done with this context. */ | ||
426 | bidi::on_close (); | ||
427 | @@ -1439,12 +1584,13 @@ maybe_warn_bidi_on_close (cpp_reader *pf | ||
428 | |||
429 | /* We're at the beginning or in the middle of an identifier/comment/string | ||
430 | literal/character constant. Warn if we've encountered a bidi character. | ||
431 | - KIND says which bidi character it was; P points to it in the character | ||
432 | - stream. UCN_P is true iff this bidi character was written as a UCN. */ | ||
433 | + KIND says which bidi control character it was; UCN_P is true iff this bidi | ||
434 | + control character was written as a UCN. LOC is the location of the | ||
435 | + character, but is only valid if KIND != bidi::kind::NONE. */ | ||
436 | |||
437 | static void | ||
438 | -maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind, | ||
439 | - bool ucn_p) | ||
440 | +maybe_warn_bidi_on_char (cpp_reader *pfile, bidi::kind kind, | ||
441 | + bool ucn_p, location_t loc) | ||
442 | { | ||
443 | if (__builtin_expect (kind == bidi::kind::NONE, 1)) | ||
444 | return; | ||
445 | @@ -1453,9 +1599,6 @@ maybe_warn_bidi_on_char (cpp_reader *pfi | ||
446 | |||
447 | if (warn_bidi != bidirectional_none) | ||
448 | { | ||
449 | - const location_t loc | ||
450 | - = linemap_position_for_column (pfile->line_table, | ||
451 | - CPP_BUF_COLUMN (pfile->buffer, p)); | ||
452 | rich_location rich_loc (pfile->line_table, loc); | ||
453 | rich_loc.set_escape_on_output (true); | ||
454 | |||
455 | @@ -1467,9 +1610,12 @@ maybe_warn_bidi_on_char (cpp_reader *pfi | ||
456 | { | ||
457 | if (warn_bidi == bidirectional_unpaired | ||
458 | && bidi::current_ctx_ucn_p () != ucn_p) | ||
459 | - cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
460 | - "UTF-8 vs UCN mismatch when closing " | ||
461 | - "a context by \"%s\"", bidi::to_str (kind)); | ||
462 | + { | ||
463 | + rich_loc.add_range (bidi::current_ctx_loc ()); | ||
464 | + cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc, | ||
465 | + "UTF-8 vs UCN mismatch when closing " | ||
466 | + "a context by \"%s\"", bidi::to_str (kind)); | ||
467 | + } | ||
468 | } | ||
469 | else if (warn_bidi == bidirectional_any) | ||
470 | { | ||
471 | @@ -1484,7 +1630,7 @@ maybe_warn_bidi_on_char (cpp_reader *pfi | ||
472 | } | ||
473 | } | ||
474 | /* We're done with this context. */ | ||
475 | - bidi::on_char (kind, ucn_p); | ||
476 | + bidi::on_char (kind, ucn_p, loc); | ||
477 | } | ||
478 | |||
479 | /* Skip a C-style block comment. We find the end of the comment by | ||
480 | @@ -1552,8 +1698,9 @@ _cpp_skip_block_comment (cpp_reader *pfi | ||
481 | a bidirectional control character. */ | ||
482 | else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p) | ||
483 | { | ||
484 | - bidi::kind kind = get_bidi_utf8 (cur - 1); | ||
485 | - maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/false); | ||
486 | + location_t loc; | ||
487 | + bidi::kind kind = get_bidi_utf8 (pfile, cur - 1, &loc); | ||
488 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc); | ||
489 | } | ||
490 | } | ||
491 | |||
492 | @@ -1586,9 +1733,9 @@ skip_line_comment (cpp_reader *pfile) | ||
493 | { | ||
494 | if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0)) | ||
495 | { | ||
496 | - bidi::kind kind = get_bidi_utf8 (buffer->cur); | ||
497 | - maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
498 | - /*ucn_p=*/false); | ||
499 | + location_t loc; | ||
500 | + bidi::kind kind = get_bidi_utf8 (pfile, buffer->cur, &loc); | ||
501 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc); | ||
502 | } | ||
503 | buffer->cur++; | ||
504 | } | ||
505 | @@ -1708,9 +1855,9 @@ forms_identifier_p (cpp_reader *pfile, i | ||
506 | if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0) | ||
507 | && warn_bidi_p) | ||
508 | { | ||
509 | - bidi::kind kind = get_bidi_utf8 (buffer->cur); | ||
510 | - maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
511 | - /*ucn_p=*/false); | ||
512 | + location_t loc; | ||
513 | + bidi::kind kind = get_bidi_utf8 (pfile, buffer->cur, &loc); | ||
514 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc); | ||
515 | } | ||
516 | if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first, | ||
517 | state, &s)) | ||
518 | @@ -1722,10 +1869,12 @@ forms_identifier_p (cpp_reader *pfile, i | ||
519 | buffer->cur += 2; | ||
520 | if (warn_bidi_p) | ||
521 | { | ||
522 | - bidi::kind kind = get_bidi_ucn (buffer->cur, | ||
523 | - buffer->cur[-1] == 'U'); | ||
524 | - maybe_warn_bidi_on_char (pfile, buffer->cur, kind, | ||
525 | - /*ucn_p=*/true); | ||
526 | + location_t loc; | ||
527 | + bidi::kind kind = get_bidi_ucn (pfile, | ||
528 | + buffer->cur, | ||
529 | + buffer->cur[-1] == 'U', | ||
530 | + &loc); | ||
531 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/true, loc); | ||
532 | } | ||
533 | if (_cpp_valid_ucn (pfile, &buffer->cur, buffer->rlimit, 1 + !first, | ||
534 | state, &s, NULL, NULL)) | ||
535 | @@ -2336,8 +2485,11 @@ lex_raw_string (cpp_reader *pfile, cpp_t | ||
536 | } | ||
537 | else if (__builtin_expect ((unsigned char) c == bidi::utf8_start, 0) | ||
538 | && warn_bidi_p) | ||
539 | - maybe_warn_bidi_on_char (pfile, pos - 1, get_bidi_utf8 (pos - 1), | ||
540 | - /*ucn_p=*/false); | ||
541 | + { | ||
542 | + location_t loc; | ||
543 | + bidi::kind kind = get_bidi_utf8 (pfile, pos - 1, &loc); | ||
544 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc); | ||
545 | + } | ||
546 | } | ||
547 | |||
548 | if (warn_bidi_p) | ||
549 | @@ -2447,8 +2599,10 @@ lex_string (cpp_reader *pfile, cpp_token | ||
550 | { | ||
551 | if ((cur[0] == 'u' || cur[0] == 'U') && warn_bidi_p) | ||
552 | { | ||
553 | - bidi::kind kind = get_bidi_ucn (cur + 1, cur[0] == 'U'); | ||
554 | - maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/true); | ||
555 | + location_t loc; | ||
556 | + bidi::kind kind = get_bidi_ucn (pfile, cur + 1, cur[0] == 'U', | ||
557 | + &loc); | ||
558 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/true, loc); | ||
559 | } | ||
560 | cur++; | ||
561 | } | ||
562 | @@ -2476,8 +2630,9 @@ lex_string (cpp_reader *pfile, cpp_token | ||
563 | saw_NUL = true; | ||
564 | else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p) | ||
565 | { | ||
566 | - bidi::kind kind = get_bidi_utf8 (cur - 1); | ||
567 | - maybe_warn_bidi_on_char (pfile, cur - 1, kind, /*ucn_p=*/false); | ||
568 | + location_t loc; | ||
569 | + bidi::kind kind = get_bidi_utf8 (pfile, cur - 1, &loc); | ||
570 | + maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc); | ||
571 | } | ||
572 | } | ||
573 | |||
diff --git a/meta/recipes-devtools/gcc/gcc/0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch b/meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch index 7f807a991c..e8f2163476 100644 --- a/meta/recipes-devtools/gcc/gcc/0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch +++ b/meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch | |||
@@ -1,10 +1,10 @@ | |||
1 | From 2c2a92573598ddbc33c023fe5d499191491fb523 Mon Sep 17 00:00:00 2001 | 1 | From 7f40f8321fb999e9b34d948724517d3fb0d26820 Mon Sep 17 00:00:00 2001 |
2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> | 2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
3 | Date: Thu, 28 Oct 2021 11:33:40 +0100 | 3 | Date: Thu, 28 Oct 2021 11:33:40 +0100 |
4 | Subject: [PATCH] If CXXFLAGS contains something unsupported by the build CXX, | 4 | Subject: [PATCH] Pass CXXFLAGS_FOR_BUILD in a couple of places to avoid these |
5 | we see build failures (e.g. using -fmacro-prefix-map for the target). | 5 | errors. |
6 | 6 | ||
7 | Pass CXXFLAGS_FOR_BUILD in a couple of places to avoid these errors. | 7 | If CXXFLAGS contains something unsupported by the build CXX, we see build failures (e.g. using -fmacro-prefix-map for the target). |
8 | 8 | ||
9 | 2021-10-28 Richard Purdie <richard.purdie@linuxfoundation.org> | 9 | 2021-10-28 Richard Purdie <richard.purdie@linuxfoundation.org> |
10 | 10 | ||
@@ -23,7 +23,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
23 | 2 files changed, 4 insertions(+) | 23 | 2 files changed, 4 insertions(+) |
24 | 24 | ||
25 | diff --git a/Makefile.in b/Makefile.in | 25 | diff --git a/Makefile.in b/Makefile.in |
26 | index 33476d53327..b949dffee0e 100644 | 26 | index 593495e1650..1d9c83cc566 100644 |
27 | --- a/Makefile.in | 27 | --- a/Makefile.in |
28 | +++ b/Makefile.in | 28 | +++ b/Makefile.in |
29 | @@ -176,6 +176,7 @@ BUILD_EXPORTS = \ | 29 | @@ -176,6 +176,7 @@ BUILD_EXPORTS = \ |
@@ -43,7 +43,7 @@ index 33476d53327..b949dffee0e 100644 | |||
43 | DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ | 43 | DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ |
44 | LD="$(LD)"; export LD; \ | 44 | LD="$(LD)"; export LD; \ |
45 | diff --git a/Makefile.tpl b/Makefile.tpl | 45 | diff --git a/Makefile.tpl b/Makefile.tpl |
46 | index e39d85d1109..d8520cbb164 100644 | 46 | index ef58fac2b9a..bab04f335c2 100644 |
47 | --- a/Makefile.tpl | 47 | --- a/Makefile.tpl |
48 | +++ b/Makefile.tpl | 48 | +++ b/Makefile.tpl |
49 | @@ -179,6 +179,7 @@ BUILD_EXPORTS = \ | 49 | @@ -179,6 +179,7 @@ BUILD_EXPORTS = \ |
diff --git a/meta/recipes-devtools/gcc/gcc/0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta/recipes-devtools/gcc/gcc/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch index 55a58851dc..e34eb2cf3f 100644 --- a/meta/recipes-devtools/gcc/gcc/0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch +++ b/meta/recipes-devtools/gcc/gcc/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 1766cf28fd7d917df510b1c262c47211b9ea70fa Mon Sep 17 00:00:00 2001 | 1 | From 5455fc1de74897a27c1199dc5611ec02243e24af Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:17:25 +0400 | 3 | Date: Fri, 29 Mar 2013 09:17:25 +0400 |
4 | Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B} | 4 | Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B} |
@@ -26,10 +26,10 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | |||
26 | 4 files changed, 7 insertions(+), 7 deletions(-) | 26 | 4 files changed, 7 insertions(+), 7 deletions(-) |
27 | 27 | ||
28 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in | 28 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in |
29 | index 7bfd6ce653f..95962ae37b6 100644 | 29 | index 31ff95500c9..a8277254696 100644 |
30 | --- a/gcc/Makefile.in | 30 | --- a/gcc/Makefile.in |
31 | +++ b/gcc/Makefile.in | 31 | +++ b/gcc/Makefile.in |
32 | @@ -552,7 +552,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ | 32 | @@ -553,7 +553,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ |
33 | TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ | 33 | TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ |
34 | 34 | ||
35 | xmake_file=@xmake_file@ | 35 | xmake_file=@xmake_file@ |
@@ -39,10 +39,10 @@ index 7bfd6ce653f..95962ae37b6 100644 | |||
39 | TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@ | 39 | TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@ |
40 | TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@ | 40 | TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@ |
41 | diff --git a/gcc/configure b/gcc/configure | 41 | diff --git a/gcc/configure b/gcc/configure |
42 | index d7445339f9a..f5b99d1cf7d 100755 | 42 | index dc2d59701ad..3fc0e2f5813 100755 |
43 | --- a/gcc/configure | 43 | --- a/gcc/configure |
44 | +++ b/gcc/configure | 44 | +++ b/gcc/configure |
45 | @@ -13131,8 +13131,8 @@ for f in $tm_file; do | 45 | @@ -13381,8 +13381,8 @@ for f in $tm_file; do |
46 | tm_include_list="${tm_include_list} $f" | 46 | tm_include_list="${tm_include_list} $f" |
47 | ;; | 47 | ;; |
48 | defaults.h ) | 48 | defaults.h ) |
@@ -54,10 +54,10 @@ index d7445339f9a..f5b99d1cf7d 100755 | |||
54 | * ) | 54 | * ) |
55 | tm_file_list="${tm_file_list} \$(srcdir)/config/$f" | 55 | tm_file_list="${tm_file_list} \$(srcdir)/config/$f" |
56 | diff --git a/gcc/configure.ac b/gcc/configure.ac | 56 | diff --git a/gcc/configure.ac b/gcc/configure.ac |
57 | index fe488f2232b..29005f6d18f 100644 | 57 | index 36ce78924de..46de496b256 100644 |
58 | --- a/gcc/configure.ac | 58 | --- a/gcc/configure.ac |
59 | +++ b/gcc/configure.ac | 59 | +++ b/gcc/configure.ac |
60 | @@ -2294,8 +2294,8 @@ for f in $tm_file; do | 60 | @@ -2332,8 +2332,8 @@ for f in $tm_file; do |
61 | tm_include_list="${tm_include_list} $f" | 61 | tm_include_list="${tm_include_list} $f" |
62 | ;; | 62 | ;; |
63 | defaults.h ) | 63 | defaults.h ) |
@@ -69,7 +69,7 @@ index fe488f2232b..29005f6d18f 100644 | |||
69 | * ) | 69 | * ) |
70 | tm_file_list="${tm_file_list} \$(srcdir)/config/$f" | 70 | tm_file_list="${tm_file_list} \$(srcdir)/config/$f" |
71 | diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh | 71 | diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh |
72 | index c49acd8f7e4..a0a657bdbb9 100644 | 72 | index 91cc43f69ff..8de33713cd8 100644 |
73 | --- a/gcc/mkconfig.sh | 73 | --- a/gcc/mkconfig.sh |
74 | +++ b/gcc/mkconfig.sh | 74 | +++ b/gcc/mkconfig.sh |
75 | @@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then | 75 | @@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then |
diff --git a/meta/recipes-devtools/gcc/gcc/0005-cpp-honor-sysroot.patch b/meta/recipes-devtools/gcc/gcc/0006-cpp-honor-sysroot.patch index f2883fe074..b08aecc736 100644 --- a/meta/recipes-devtools/gcc/gcc/0005-cpp-honor-sysroot.patch +++ b/meta/recipes-devtools/gcc/gcc/0006-cpp-honor-sysroot.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From e6a820a19c4cd115d8af7c235c5f9700c7a24730 Mon Sep 17 00:00:00 2001 | 1 | From abc3b82ab24169277f2090e9df1ceac3573142be Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:22:00 +0400 | 3 | Date: Fri, 29 Mar 2013 09:22:00 +0400 |
4 | Subject: [PATCH] cpp: honor sysroot. | 4 | Subject: [PATCH] cpp: honor sysroot. |
@@ -19,14 +19,14 @@ RP 2012/04/13 | |||
19 | 19 | ||
20 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 20 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
21 | 21 | ||
22 | Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582725.html] | 22 | Upstream-Status: Pending |
23 | --- | 23 | --- |
24 | gcc/cp/lang-specs.h | 2 +- | 24 | gcc/cp/lang-specs.h | 2 +- |
25 | gcc/gcc.c | 2 +- | 25 | gcc/gcc.cc | 2 +- |
26 | 2 files changed, 2 insertions(+), 2 deletions(-) | 26 | 2 files changed, 2 insertions(+), 2 deletions(-) |
27 | 27 | ||
28 | diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h | 28 | diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h |
29 | index 8902ae1d2ed..e99e2fcd6ad 100644 | 29 | index f35c9fab76b..19ddc98ce7f 100644 |
30 | --- a/gcc/cp/lang-specs.h | 30 | --- a/gcc/cp/lang-specs.h |
31 | +++ b/gcc/cp/lang-specs.h | 31 | +++ b/gcc/cp/lang-specs.h |
32 | @@ -116,7 +116,7 @@ along with GCC; see the file COPYING3. If not see | 32 | @@ -116,7 +116,7 @@ along with GCC; see the file COPYING3. If not see |
@@ -38,11 +38,11 @@ index 8902ae1d2ed..e99e2fcd6ad 100644 | |||
38 | " %{!fsyntax-only:" | 38 | " %{!fsyntax-only:" |
39 | " %{fmodule-only:%{!S:-o %g.s%V}}" | 39 | " %{fmodule-only:%{!S:-o %g.s%V}}" |
40 | " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}" | 40 | " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}" |
41 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 41 | diff --git a/gcc/gcc.cc b/gcc/gcc.cc |
42 | index b047fc31c2f..bdee2671532 100644 | 42 | index ce161d3c853..aa4cf92fb78 100644 |
43 | --- a/gcc/gcc.c | 43 | --- a/gcc/gcc.cc |
44 | +++ b/gcc/gcc.c | 44 | +++ b/gcc/gcc.cc |
45 | @@ -1469,7 +1469,7 @@ static const struct compiler default_compilers[] = | 45 | @@ -1476,7 +1476,7 @@ static const struct compiler default_compilers[] = |
46 | %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, | 46 | %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, |
47 | {".i", "@cpp-output", 0, 0, 0}, | 47 | {".i", "@cpp-output", 0, 0, 0}, |
48 | {"@cpp-output", | 48 | {"@cpp-output", |
diff --git a/meta/recipes-devtools/gcc/gcc/0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch index ef19eef822..b59eed57e9 100644 --- a/meta/recipes-devtools/gcc/gcc/0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch +++ b/meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 84dd8ea4c982fc2c82af642293d29e9c1880de5b Mon Sep 17 00:00:00 2001 | 1 | From 4de00af67b57b5440bdf61ab364ad959ad0aeee7 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:24:50 +0400 | 3 | Date: Fri, 29 Mar 2013 09:24:50 +0400 |
4 | Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER | 4 | Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER |
@@ -12,26 +12,33 @@ SH, sparc, alpha for possible future support (if any) | |||
12 | 12 | ||
13 | Removes the do_headerfix task in metadata | 13 | Removes the do_headerfix task in metadata |
14 | 14 | ||
15 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
16 | |||
15 | Upstream-Status: Inappropriate [OE configuration] | 17 | Upstream-Status: Inappropriate [OE configuration] |
16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
17 | --- | 19 | --- |
18 | gcc/config/aarch64/aarch64-linux.h | 4 ++-- | 20 | gcc/config/aarch64/aarch64-linux.h | 4 ++-- |
19 | gcc/config/alpha/linux-elf.h | 4 ++-- | 21 | gcc/config/alpha/linux-elf.h | 4 ++-- |
20 | gcc/config/arm/linux-eabi.h | 4 ++-- | 22 | gcc/config/arm/linux-eabi.h | 6 +++--- |
21 | gcc/config/arm/linux-elf.h | 2 +- | 23 | gcc/config/arm/linux-elf.h | 2 +- |
22 | gcc/config/i386/linux.h | 2 +- | 24 | gcc/config/i386/linux.h | 4 ++-- |
23 | gcc/config/i386/linux64.h | 6 +++--- | 25 | gcc/config/i386/linux64.h | 12 ++++++------ |
24 | gcc/config/linux.h | 8 ++++---- | 26 | gcc/config/linux.h | 8 ++++---- |
25 | gcc/config/mips/linux.h | 12 ++++++------ | 27 | gcc/config/loongarch/gnu-user.h | 4 ++-- |
26 | gcc/config/riscv/linux.h | 2 +- | 28 | gcc/config/microblaze/linux.h | 4 ++-- |
29 | gcc/config/mips/linux.h | 18 +++++++++--------- | ||
30 | gcc/config/nios2/linux.h | 4 ++-- | ||
31 | gcc/config/riscv/linux.h | 4 ++-- | ||
27 | gcc/config/rs6000/linux64.h | 15 +++++---------- | 32 | gcc/config/rs6000/linux64.h | 15 +++++---------- |
28 | gcc/config/sh/linux.h | 2 +- | 33 | gcc/config/rs6000/sysv4.h | 4 ++-- |
34 | gcc/config/s390/linux.h | 8 ++++---- | ||
35 | gcc/config/sh/linux.h | 4 ++-- | ||
29 | gcc/config/sparc/linux.h | 2 +- | 36 | gcc/config/sparc/linux.h | 2 +- |
30 | gcc/config/sparc/linux64.h | 4 ++-- | 37 | gcc/config/sparc/linux64.h | 4 ++-- |
31 | 13 files changed, 31 insertions(+), 36 deletions(-) | 38 | 18 files changed, 53 insertions(+), 58 deletions(-) |
32 | 39 | ||
33 | diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h | 40 | diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h |
34 | index 7f2529a2a1d..4bcae7f3110 100644 | 41 | index 5e4553d79f5..877e8841eb2 100644 |
35 | --- a/gcc/config/aarch64/aarch64-linux.h | 42 | --- a/gcc/config/aarch64/aarch64-linux.h |
36 | +++ b/gcc/config/aarch64/aarch64-linux.h | 43 | +++ b/gcc/config/aarch64/aarch64-linux.h |
37 | @@ -21,10 +21,10 @@ | 44 | @@ -21,10 +21,10 @@ |
@@ -48,7 +55,7 @@ index 7f2529a2a1d..4bcae7f3110 100644 | |||
48 | #undef ASAN_CC1_SPEC | 55 | #undef ASAN_CC1_SPEC |
49 | #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" | 56 | #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" |
50 | diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h | 57 | diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h |
51 | index c1dae8ca2cf..3ce2b76c1a4 100644 | 58 | index 17f16a55910..0a7be38fa63 100644 |
52 | --- a/gcc/config/alpha/linux-elf.h | 59 | --- a/gcc/config/alpha/linux-elf.h |
53 | +++ b/gcc/config/alpha/linux-elf.h | 60 | +++ b/gcc/config/alpha/linux-elf.h |
54 | @@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see | 61 | @@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see |
@@ -63,7 +70,7 @@ index c1dae8ca2cf..3ce2b76c1a4 100644 | |||
63 | #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" | 70 | #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" |
64 | #elif DEFAULT_LIBC == LIBC_GLIBC | 71 | #elif DEFAULT_LIBC == LIBC_GLIBC |
65 | diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h | 72 | diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h |
66 | index 85d0136e76e..6bd95855827 100644 | 73 | index 50cc0bc6d08..17c18b27145 100644 |
67 | --- a/gcc/config/arm/linux-eabi.h | 74 | --- a/gcc/config/arm/linux-eabi.h |
68 | +++ b/gcc/config/arm/linux-eabi.h | 75 | +++ b/gcc/config/arm/linux-eabi.h |
69 | @@ -65,8 +65,8 @@ | 76 | @@ -65,8 +65,8 @@ |
@@ -77,8 +84,17 @@ index 85d0136e76e..6bd95855827 100644 | |||
77 | #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT | 84 | #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT |
78 | 85 | ||
79 | #define GLIBC_DYNAMIC_LINKER \ | 86 | #define GLIBC_DYNAMIC_LINKER \ |
87 | @@ -89,7 +89,7 @@ | ||
88 | #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}" | ||
89 | #endif | ||
90 | #define MUSL_DYNAMIC_LINKER \ | ||
91 | - "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" | ||
92 | + SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" | ||
93 | |||
94 | /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to | ||
95 | use the GNU/Linux version, not the generic BPABI version. */ | ||
80 | diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h | 96 | diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h |
81 | index 0c1c4e70b6b..6bd643ade11 100644 | 97 | index df3da67c4f0..37456e9d5a4 100644 |
82 | --- a/gcc/config/arm/linux-elf.h | 98 | --- a/gcc/config/arm/linux-elf.h |
83 | +++ b/gcc/config/arm/linux-elf.h | 99 | +++ b/gcc/config/arm/linux-elf.h |
84 | @@ -60,7 +60,7 @@ | 100 | @@ -60,7 +60,7 @@ |
@@ -91,7 +107,7 @@ index 0c1c4e70b6b..6bd643ade11 100644 | |||
91 | #define LINUX_TARGET_LINK_SPEC "%{h*} \ | 107 | #define LINUX_TARGET_LINK_SPEC "%{h*} \ |
92 | %{static:-Bstatic} \ | 108 | %{static:-Bstatic} \ |
93 | diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h | 109 | diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h |
94 | index 04b274f1654..7aafcf3ac2d 100644 | 110 | index 5d99ee56d5b..a76022c9ccc 100644 |
95 | --- a/gcc/config/i386/linux.h | 111 | --- a/gcc/config/i386/linux.h |
96 | +++ b/gcc/config/i386/linux.h | 112 | +++ b/gcc/config/i386/linux.h |
97 | @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see | 113 | @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see |
@@ -102,12 +118,13 @@ index 04b274f1654..7aafcf3ac2d 100644 | |||
102 | +#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" | 118 | +#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" |
103 | 119 | ||
104 | #undef MUSL_DYNAMIC_LINKER | 120 | #undef MUSL_DYNAMIC_LINKER |
105 | #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" | 121 | -#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" |
122 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1" | ||
106 | diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h | 123 | diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h |
107 | index b3822ced528..92d303e80d6 100644 | 124 | index 8681e36f10d..ddce49b6b60 100644 |
108 | --- a/gcc/config/i386/linux64.h | 125 | --- a/gcc/config/i386/linux64.h |
109 | +++ b/gcc/config/i386/linux64.h | 126 | +++ b/gcc/config/i386/linux64.h |
110 | @@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 127 | @@ -27,13 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
111 | #define GNU_USER_LINK_EMULATION64 "elf_x86_64" | 128 | #define GNU_USER_LINK_EMULATION64 "elf_x86_64" |
112 | #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" | 129 | #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" |
113 | 130 | ||
@@ -119,12 +136,19 @@ index b3822ced528..92d303e80d6 100644 | |||
119 | +#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" | 136 | +#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" |
120 | 137 | ||
121 | #undef MUSL_DYNAMIC_LINKER32 | 138 | #undef MUSL_DYNAMIC_LINKER32 |
122 | #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" | 139 | -#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" |
140 | +#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1" | ||
141 | #undef MUSL_DYNAMIC_LINKER64 | ||
142 | -#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1" | ||
143 | +#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1" | ||
144 | #undef MUSL_DYNAMIC_LINKERX32 | ||
145 | -#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1" | ||
146 | +#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1" | ||
123 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | 147 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h |
124 | index 4e1db60fced..87efc5f69fe 100644 | 148 | index 74f70793d90..4ce173384ef 100644 |
125 | --- a/gcc/config/linux.h | 149 | --- a/gcc/config/linux.h |
126 | +++ b/gcc/config/linux.h | 150 | +++ b/gcc/config/linux.h |
127 | @@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 151 | @@ -99,10 +99,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
128 | GLIBC_DYNAMIC_LINKER must be defined for each target using them, or | 152 | GLIBC_DYNAMIC_LINKER must be defined for each target using them, or |
129 | GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets | 153 | GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets |
130 | supporting both 32-bit and 64-bit compilation. */ | 154 | supporting both 32-bit and 64-bit compilation. */ |
@@ -139,11 +163,51 @@ index 4e1db60fced..87efc5f69fe 100644 | |||
139 | #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" | 163 | #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" |
140 | #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" | 164 | #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" |
141 | #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" | 165 | #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" |
166 | diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h | ||
167 | index 664dc9206ad..082bd7cfc6f 100644 | ||
168 | --- a/gcc/config/loongarch/gnu-user.h | ||
169 | +++ b/gcc/config/loongarch/gnu-user.h | ||
170 | @@ -31,11 +31,11 @@ along with GCC; see the file COPYING3. If not see | ||
171 | |||
172 | #undef GLIBC_DYNAMIC_LINKER | ||
173 | #define GLIBC_DYNAMIC_LINKER \ | ||
174 | - "/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1" | ||
175 | + SYSTEMLIBS_DIR "ld-linux-loongarch-" ABI_SPEC ".so.1" | ||
176 | |||
177 | #undef MUSL_DYNAMIC_LINKER | ||
178 | #define MUSL_DYNAMIC_LINKER \ | ||
179 | - "/lib" ABI_GRLEN_SPEC "/ld-musl-loongarch-" ABI_SPEC ".so.1" | ||
180 | + SYSTEMLIBS_DIR "ld-musl-loongarch-" ABI_SPEC ".so.1" | ||
181 | |||
182 | #undef GNU_USER_TARGET_LINK_SPEC | ||
183 | #define GNU_USER_TARGET_LINK_SPEC \ | ||
184 | diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h | ||
185 | index 5b1a365eda4..2e63df1ae9c 100644 | ||
186 | --- a/gcc/config/microblaze/linux.h | ||
187 | +++ b/gcc/config/microblaze/linux.h | ||
188 | @@ -28,7 +28,7 @@ | ||
189 | #undef TLS_NEEDS_GOT | ||
190 | #define TLS_NEEDS_GOT 1 | ||
191 | |||
192 | -#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" | ||
193 | +#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "/ld.so.1" | ||
194 | #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" | ||
195 | |||
196 | #if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */ | ||
197 | @@ -38,7 +38,7 @@ | ||
198 | #endif | ||
199 | |||
200 | #undef MUSL_DYNAMIC_LINKER | ||
201 | -#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1" | ||
202 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1" | ||
203 | |||
204 | #undef SUBTARGET_EXTRA_SPECS | ||
205 | #define SUBTARGET_EXTRA_SPECS \ | ||
142 | diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h | 206 | diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h |
143 | index 44a85e410d9..8d41b5574f6 100644 | 207 | index 230b7789bb8..d96d134bfcf 100644 |
144 | --- a/gcc/config/mips/linux.h | 208 | --- a/gcc/config/mips/linux.h |
145 | +++ b/gcc/config/mips/linux.h | 209 | +++ b/gcc/config/mips/linux.h |
146 | @@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see | 210 | @@ -22,29 +22,29 @@ along with GCC; see the file COPYING3. If not see |
147 | #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32" | 211 | #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32" |
148 | 212 | ||
149 | #define GLIBC_DYNAMIC_LINKER32 \ | 213 | #define GLIBC_DYNAMIC_LINKER32 \ |
@@ -170,8 +234,35 @@ index 44a85e410d9..8d41b5574f6 100644 | |||
170 | 234 | ||
171 | #undef MUSL_DYNAMIC_LINKER32 | 235 | #undef MUSL_DYNAMIC_LINKER32 |
172 | #define MUSL_DYNAMIC_LINKER32 \ | 236 | #define MUSL_DYNAMIC_LINKER32 \ |
237 | - "/lib/ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
238 | + SYSTEMLIBS_DIR "ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
239 | #undef MUSL_DYNAMIC_LINKER64 | ||
240 | #define MUSL_DYNAMIC_LINKER64 \ | ||
241 | - "/lib/ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
242 | + SYSTEMLIBS_DIR "ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
243 | #define MUSL_DYNAMIC_LINKERN32 \ | ||
244 | - "/lib/ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
245 | + SYSTEMLIBS_DIR "ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1" | ||
246 | |||
247 | #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32" | ||
248 | #define GNU_USER_DYNAMIC_LINKERN32 \ | ||
249 | diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h | ||
250 | index f5dd813acad..7a13e1c9799 100644 | ||
251 | --- a/gcc/config/nios2/linux.h | ||
252 | +++ b/gcc/config/nios2/linux.h | ||
253 | @@ -29,8 +29,8 @@ | ||
254 | #undef CPP_SPEC | ||
255 | #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" | ||
256 | |||
257 | -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1" | ||
258 | -#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1" | ||
259 | +#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-nios2.so.1" | ||
260 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-nios2.so.1" | ||
261 | |||
262 | #undef LINK_SPEC | ||
263 | #define LINK_SPEC LINK_SPEC_ENDIAN \ | ||
173 | diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h | 264 | diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h |
174 | index fce5b896e6e..03aa55cb5ab 100644 | 265 | index 38803723ba9..d5ef8a96a19 100644 |
175 | --- a/gcc/config/riscv/linux.h | 266 | --- a/gcc/config/riscv/linux.h |
176 | +++ b/gcc/config/riscv/linux.h | 267 | +++ b/gcc/config/riscv/linux.h |
177 | @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see | 268 | @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see |
@@ -183,11 +274,20 @@ index fce5b896e6e..03aa55cb5ab 100644 | |||
183 | 274 | ||
184 | #define MUSL_ABI_SUFFIX \ | 275 | #define MUSL_ABI_SUFFIX \ |
185 | "%{mabi=ilp32:-sf}" \ | 276 | "%{mabi=ilp32:-sf}" \ |
277 | @@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see | ||
278 | "%{mabi=lp64d:}" | ||
279 | |||
280 | #undef MUSL_DYNAMIC_LINKER | ||
281 | -#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1" | ||
282 | +#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1" | ||
283 | |||
284 | /* Because RISC-V only has word-sized atomics, it requries libatomic where | ||
285 | others do not. So link libatomic by default, as needed. */ | ||
186 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h | 286 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h |
187 | index e3f2cd254f6..a11e01faa3d 100644 | 287 | index b2a7afabc73..364c1a5b155 100644 |
188 | --- a/gcc/config/rs6000/linux64.h | 288 | --- a/gcc/config/rs6000/linux64.h |
189 | +++ b/gcc/config/rs6000/linux64.h | 289 | +++ b/gcc/config/rs6000/linux64.h |
190 | @@ -336,24 +336,19 @@ extern int dot_symbols; | 290 | @@ -339,24 +339,19 @@ extern int dot_symbols; |
191 | #undef LINK_OS_DEFAULT_SPEC | 291 | #undef LINK_OS_DEFAULT_SPEC |
192 | #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" | 292 | #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" |
193 | 293 | ||
@@ -217,12 +317,55 @@ index e3f2cd254f6..a11e01faa3d 100644 | |||
217 | 317 | ||
218 | #undef DEFAULT_ASM_ENDIAN | 318 | #undef DEFAULT_ASM_ENDIAN |
219 | #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) | 319 | #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) |
320 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h | ||
321 | index 7e2519de5d4..a73954d9de5 100644 | ||
322 | --- a/gcc/config/rs6000/sysv4.h | ||
323 | +++ b/gcc/config/rs6000/sysv4.h | ||
324 | @@ -779,10 +779,10 @@ GNU_USER_TARGET_CC1_SPEC | ||
325 | |||
326 | #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","") | ||
327 | |||
328 | -#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" | ||
329 | +#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1" | ||
330 | #undef MUSL_DYNAMIC_LINKER | ||
331 | #define MUSL_DYNAMIC_LINKER \ | ||
332 | - "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" | ||
333 | + SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1" | ||
334 | |||
335 | #ifndef GNU_USER_DYNAMIC_LINKER | ||
336 | #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER | ||
337 | diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h | ||
338 | index d7b7e7a7b02..0139b4d06ca 100644 | ||
339 | --- a/gcc/config/s390/linux.h | ||
340 | +++ b/gcc/config/s390/linux.h | ||
341 | @@ -72,13 +72,13 @@ along with GCC; see the file COPYING3. If not see | ||
342 | #define MULTILIB_DEFAULTS { "m31" } | ||
343 | #endif | ||
344 | |||
345 | -#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" | ||
346 | -#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1" | ||
347 | +#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1" | ||
348 | +#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64.so.1" | ||
349 | |||
350 | #undef MUSL_DYNAMIC_LINKER32 | ||
351 | -#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1" | ||
352 | +#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-s390.so.1" | ||
353 | #undef MUSL_DYNAMIC_LINKER64 | ||
354 | -#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1" | ||
355 | +#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-s390x.so.1" | ||
356 | |||
357 | #undef LINK_SPEC | ||
358 | #define LINK_SPEC \ | ||
220 | diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h | 359 | diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h |
221 | index 7558d2f7195..3aaa6c3a078 100644 | 360 | index d96d077c99e..7d27f9893ee 100644 |
222 | --- a/gcc/config/sh/linux.h | 361 | --- a/gcc/config/sh/linux.h |
223 | +++ b/gcc/config/sh/linux.h | 362 | +++ b/gcc/config/sh/linux.h |
224 | @@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see | 363 | @@ -61,10 +61,10 @@ along with GCC; see the file COPYING3. If not see |
225 | "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ | 364 | |
365 | #undef MUSL_DYNAMIC_LINKER | ||
366 | #define MUSL_DYNAMIC_LINKER \ | ||
367 | - "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ | ||
368 | + SYSTEMLIBS_DIR "ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ | ||
226 | "%{mfdpic:-fdpic}.so.1" | 369 | "%{mfdpic:-fdpic}.so.1" |
227 | 370 | ||
228 | -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" | 371 | -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" |
@@ -231,7 +374,7 @@ index 7558d2f7195..3aaa6c3a078 100644 | |||
231 | #undef SUBTARGET_LINK_EMUL_SUFFIX | 374 | #undef SUBTARGET_LINK_EMUL_SUFFIX |
232 | #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" | 375 | #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" |
233 | diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h | 376 | diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h |
234 | index 2550d7ee8f0..a94f4cd8ba2 100644 | 377 | index 6a809e9092d..60603765ad6 100644 |
235 | --- a/gcc/config/sparc/linux.h | 378 | --- a/gcc/config/sparc/linux.h |
236 | +++ b/gcc/config/sparc/linux.h | 379 | +++ b/gcc/config/sparc/linux.h |
237 | @@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); | 380 | @@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); |
@@ -244,7 +387,7 @@ index 2550d7ee8f0..a94f4cd8ba2 100644 | |||
244 | #undef LINK_SPEC | 387 | #undef LINK_SPEC |
245 | #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ | 388 | #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ |
246 | diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h | 389 | diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h |
247 | index 95af8afa9b5..63127afb074 100644 | 390 | index d08a2ef96fe..e6955da0a5b 100644 |
248 | --- a/gcc/config/sparc/linux64.h | 391 | --- a/gcc/config/sparc/linux64.h |
249 | +++ b/gcc/config/sparc/linux64.h | 392 | +++ b/gcc/config/sparc/linux64.h |
250 | @@ -78,8 +78,8 @@ along with GCC; see the file COPYING3. If not see | 393 | @@ -78,8 +78,8 @@ along with GCC; see the file COPYING3. If not see |
diff --git a/meta/recipes-devtools/gcc/gcc/0007-gcc-Fix-argument-list-too-long-error.patch b/meta/recipes-devtools/gcc/gcc/0007-gcc-Fix-argument-list-too-long-error.patch deleted file mode 100644 index 9f9f8cc856..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0007-gcc-Fix-argument-list-too-long-error.patch +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | From 768e9075e88d811b00207d991123438bb996e4ea Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 29 Mar 2013 09:26:37 +0400 | ||
4 | Subject: [PATCH] gcc: Fix argument list too long error. | ||
5 | |||
6 | There would be an "Argument list too long" error when the | ||
7 | build directory is longer than 200, this is caused by: | ||
8 | |||
9 | headers=`echo $(PLUGIN_HEADERS) | tr ' ' '\012' | sort -u` | ||
10 | |||
11 | The PLUGIN_HEADERS is too long before sort, so the "echo" can't handle | ||
12 | it, use the $(sort list) of GNU make which can handle the too long list | ||
13 | would fix the problem, the header would be short enough after sorted. | ||
14 | The "tr ' ' '\012'" was used for translating the space to "\n", the | ||
15 | $(sort list) doesn't need this. | ||
16 | |||
17 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
19 | |||
20 | RP: gcc then added *.h and *.def additions to this list, breaking the original | ||
21 | fix. Add the sort to the original gcc code, leaving the tr+sort to fix the original | ||
22 | issue but include the new files too as reported by Zhuang <qiuguang.zqg@alibaba-inc.com> | ||
23 | |||
24 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=66e157188bd2f789809e17e85f917534c9381599] | ||
25 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
26 | --- | ||
27 | gcc/Makefile.in | 2 +- | ||
28 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
29 | |||
30 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in | ||
31 | index 95962ae37b6..d1d4512bba3 100644 | ||
32 | --- a/gcc/Makefile.in | ||
33 | +++ b/gcc/Makefile.in | ||
34 | @@ -3671,7 +3671,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype | ||
35 | # We keep the directory structure for files in config, common/config or | ||
36 | # c-family and .def files. All other files are flattened to a single directory. | ||
37 | $(mkinstalldirs) $(DESTDIR)$(plugin_includedir) | ||
38 | - headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \ | ||
39 | + headers=`echo $(sort $(PLUGIN_HEADERS)) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \ | ||
40 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \ | ||
41 | for file in $$headers; do \ | ||
42 | if [ -f $$file ] ; then \ | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0008-libtool.patch b/meta/recipes-devtools/gcc/gcc/0008-libtool.patch index 358e1d7b3c..c9bc38ccf0 100644 --- a/meta/recipes-devtools/gcc/gcc/0008-libtool.patch +++ b/meta/recipes-devtools/gcc/gcc/0008-libtool.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From b19700ef0103f9414416b9a779a64d6138c58b1f Mon Sep 17 00:00:00 2001 | 1 | From 5117519c1897a49b09fe7fff213b9c2ea15d37f5 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:29:11 +0400 | 3 | Date: Fri, 29 Mar 2013 09:29:11 +0400 |
4 | Subject: [PATCH] libtool | 4 | Subject: [PATCH] libtool |
diff --git a/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch index ac139542f1..dd67b115f0 100644 --- a/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch +++ b/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 10d23d93697167396e223711bf6210e1642ee926 Mon Sep 17 00:00:00 2001 | 1 | From 32129f9682d0d27fc67af10f077ad2768935cbe6 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:30:32 +0400 | 3 | Date: Fri, 29 Mar 2013 09:30:32 +0400 |
4 | Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI. | 4 | Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI. |
@@ -19,12 +19,12 @@ Upstream-Status: Pending | |||
19 | 1 file changed, 5 insertions(+), 1 deletion(-) | 19 | 1 file changed, 5 insertions(+), 1 deletion(-) |
20 | 20 | ||
21 | diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h | 21 | diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h |
22 | index 6bd95855827..77befab5da8 100644 | 22 | index 17c18b27145..8eacb099317 100644 |
23 | --- a/gcc/config/arm/linux-eabi.h | 23 | --- a/gcc/config/arm/linux-eabi.h |
24 | +++ b/gcc/config/arm/linux-eabi.h | 24 | +++ b/gcc/config/arm/linux-eabi.h |
25 | @@ -91,10 +91,14 @@ | 25 | @@ -91,10 +91,14 @@ |
26 | #define MUSL_DYNAMIC_LINKER \ | 26 | #define MUSL_DYNAMIC_LINKER \ |
27 | "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" | 27 | SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" |
28 | 28 | ||
29 | +/* For armv4 we pass --fix-v4bx to linker to support EABI */ | 29 | +/* For armv4 we pass --fix-v4bx to linker to support EABI */ |
30 | +#undef TARGET_FIX_V4BX_SPEC | 30 | +#undef TARGET_FIX_V4BX_SPEC |
diff --git a/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch index 4912fa9dce..45edc62eb5 100644 --- a/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch +++ b/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 5970fb3fadccd8c43f7f7030e6ff51e0295731ef Mon Sep 17 00:00:00 2001 | 1 | From bf85b8bbcb4b77725d4c22c1bb25a29f6ff21038 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 29 Mar 2013 09:33:04 +0400 | 3 | Date: Fri, 29 Mar 2013 09:33:04 +0400 |
4 | Subject: [PATCH] Use the multilib config files from ${B} instead of using the | 4 | Subject: [PATCH] Use the multilib config files from ${B} instead of using the |
@@ -18,10 +18,10 @@ Upstream-Status: Inappropriate [configuration] | |||
18 | 2 files changed, 36 insertions(+), 8 deletions(-) | 18 | 2 files changed, 36 insertions(+), 8 deletions(-) |
19 | 19 | ||
20 | diff --git a/gcc/configure b/gcc/configure | 20 | diff --git a/gcc/configure b/gcc/configure |
21 | index f5b99d1cf7d..ec3c24482df 100755 | 21 | index 3fc0e2f5813..2f0f0e057a9 100755 |
22 | --- a/gcc/configure | 22 | --- a/gcc/configure |
23 | +++ b/gcc/configure | 23 | +++ b/gcc/configure |
24 | @@ -13111,10 +13111,20 @@ done | 24 | @@ -13361,10 +13361,20 @@ done |
25 | tmake_file_= | 25 | tmake_file_= |
26 | for f in ${tmake_file} | 26 | for f in ${tmake_file} |
27 | do | 27 | do |
@@ -46,7 +46,7 @@ index f5b99d1cf7d..ec3c24482df 100755 | |||
46 | done | 46 | done |
47 | tmake_file="${tmake_file_}${omp_device_property_tmake_file}" | 47 | tmake_file="${tmake_file_}${omp_device_property_tmake_file}" |
48 | 48 | ||
49 | @@ -13125,6 +13135,10 @@ tm_file_list="options.h" | 49 | @@ -13375,6 +13385,10 @@ tm_file_list="options.h" |
50 | tm_include_list="options.h insn-constants.h" | 50 | tm_include_list="options.h insn-constants.h" |
51 | for f in $tm_file; do | 51 | for f in $tm_file; do |
52 | case $f in | 52 | case $f in |
@@ -58,10 +58,10 @@ index f5b99d1cf7d..ec3c24482df 100755 | |||
58 | f=`echo $f | sed 's/^..//'` | 58 | f=`echo $f | sed 's/^..//'` |
59 | tm_file_list="${tm_file_list} $f" | 59 | tm_file_list="${tm_file_list} $f" |
60 | diff --git a/gcc/configure.ac b/gcc/configure.ac | 60 | diff --git a/gcc/configure.ac b/gcc/configure.ac |
61 | index 29005f6d18f..ea794cd1763 100644 | 61 | index 46de496b256..6155b83a732 100644 |
62 | --- a/gcc/configure.ac | 62 | --- a/gcc/configure.ac |
63 | +++ b/gcc/configure.ac | 63 | +++ b/gcc/configure.ac |
64 | @@ -2274,10 +2274,20 @@ done | 64 | @@ -2312,10 +2312,20 @@ done |
65 | tmake_file_= | 65 | tmake_file_= |
66 | for f in ${tmake_file} | 66 | for f in ${tmake_file} |
67 | do | 67 | do |
@@ -86,7 +86,7 @@ index 29005f6d18f..ea794cd1763 100644 | |||
86 | done | 86 | done |
87 | tmake_file="${tmake_file_}${omp_device_property_tmake_file}" | 87 | tmake_file="${tmake_file_}${omp_device_property_tmake_file}" |
88 | 88 | ||
89 | @@ -2288,6 +2298,10 @@ tm_file_list="options.h" | 89 | @@ -2326,6 +2336,10 @@ tm_file_list="options.h" |
90 | tm_include_list="options.h insn-constants.h" | 90 | tm_include_list="options.h insn-constants.h" |
91 | for f in $tm_file; do | 91 | for f in $tm_file; do |
92 | case $f in | 92 | case $f in |
diff --git a/meta/recipes-devtools/gcc/gcc/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta/recipes-devtools/gcc/gcc/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch index e3e35942e6..352c6eec29 100644 --- a/meta/recipes-devtools/gcc/gcc/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch +++ b/meta/recipes-devtools/gcc/gcc/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 2af537b9ff0018945a27a7f89efad736a0f647d4 Mon Sep 17 00:00:00 2001 | 1 | From e5463727ff028cee5e452da38f5b4c44d52e412e Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 20 Feb 2015 09:39:38 +0000 | 3 | Date: Fri, 20 Feb 2015 09:39:38 +0000 |
4 | Subject: [PATCH] Avoid using libdir from .la which usually points to a host | 4 | Subject: [PATCH] Avoid using libdir from .la which usually points to a host |
diff --git a/meta/recipes-devtools/gcc/gcc/0012-export-CPP.patch b/meta/recipes-devtools/gcc/gcc/0012-export-CPP.patch new file mode 100644 index 0000000000..7e1ebef463 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/0012-export-CPP.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | From 20afebc61199cd74481b0b831c1b56465cd37fa0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 20 Feb 2015 09:40:59 +0000 | ||
4 | Subject: [PATCH] export CPP | ||
5 | |||
6 | The OE environment sets and exports CPP as being the target gcc. When | ||
7 | building gcc-cross-canadian for a mingw targetted sdk, the following can be found | ||
8 | in build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log: | ||
9 | |||
10 | configure:3641: checking for _FILE_OFFSET_BITS value needed for large files | ||
11 | configure:3666: gcc -c -isystem/media/build1/poky/build/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe conftest.c >&5 | ||
12 | configure:3666: $? = 0 | ||
13 | configure:3698: result: no | ||
14 | configure:3786: checking how to run the C preprocessor | ||
15 | configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 | ||
16 | configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c | ||
17 | configure:3876: $? = 0 | ||
18 | |||
19 | Note this is a *build* target (in build-x86_64-linux) so it should be | ||
20 | using the host "gcc", not x86_64-pokysdk-mingw32-gcc. Since the mingw32 | ||
21 | headers are very different, using the wrong cpp is a real problem. It is leaking | ||
22 | into configure through the CPP variable. Ultimately this leads to build | ||
23 | failures related to not being able to include a process.h file for pem-unix.c. | ||
24 | |||
25 | The fix is to ensure we export a sane CPP value into the build | ||
26 | environment when using build targets. We could define a CPP_FOR_BUILD value which may be | ||
27 | the version which needs to be upstreamed but for now, this fix is good enough to | ||
28 | avoid the problem. | ||
29 | |||
30 | RP 22/08/2013 | ||
31 | |||
32 | Upstream-Status: Pending | ||
33 | |||
34 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
35 | --- | ||
36 | Makefile.in | 1 + | ||
37 | 1 file changed, 1 insertion(+) | ||
38 | |||
39 | diff --git a/Makefile.in b/Makefile.in | ||
40 | index 1d9c83cc566..11819667751 100644 | ||
41 | --- a/Makefile.in | ||
42 | +++ b/Makefile.in | ||
43 | @@ -152,6 +152,7 @@ BUILD_EXPORTS = \ | ||
44 | AR="$(AR_FOR_BUILD)"; export AR; \ | ||
45 | AS="$(AS_FOR_BUILD)"; export AS; \ | ||
46 | CC="$(CC_FOR_BUILD)"; export CC; \ | ||
47 | + CPP="$(CC_FOR_BUILD) -E"; export CPP; \ | ||
48 | CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ | ||
49 | CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ | ||
50 | CPP="$(CPP_FOR_BUILD)"; export CPP; \ | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0012-Ensure-target-gcc-headers-can-be-included.patch b/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch index d33925eb40..61e61ecc6e 100644 --- a/meta/recipes-devtools/gcc/gcc/0012-Ensure-target-gcc-headers-can-be-included.patch +++ b/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 9427c6cedf88e15f747c48cb4fcf9eda6f5c4555 Mon Sep 17 00:00:00 2001 | 1 | From 612801d426e75ff997cfabda380dbe52c2cbc532 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 20 Feb 2015 10:25:11 +0000 | 3 | Date: Fri, 20 Feb 2015 10:25:11 +0000 |
4 | Subject: [PATCH] Ensure target gcc headers can be included | 4 | Subject: [PATCH] Ensure target gcc headers can be included |
@@ -21,14 +21,14 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
21 | gcc/Makefile.in | 2 ++ | 21 | gcc/Makefile.in | 2 ++ |
22 | gcc/config/linux.h | 8 ++++++++ | 22 | gcc/config/linux.h | 8 ++++++++ |
23 | gcc/config/rs6000/sysv4.h | 8 ++++++++ | 23 | gcc/config/rs6000/sysv4.h | 8 ++++++++ |
24 | gcc/cppdefault.c | 4 ++++ | 24 | gcc/cppdefault.cc | 4 ++++ |
25 | 4 files changed, 22 insertions(+) | 25 | 4 files changed, 22 insertions(+) |
26 | 26 | ||
27 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in | 27 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in |
28 | index d1d4512bba3..06eb0d27a28 100644 | 28 | index a8277254696..07fa63b6640 100644 |
29 | --- a/gcc/Makefile.in | 29 | --- a/gcc/Makefile.in |
30 | +++ b/gcc/Makefile.in | 30 | +++ b/gcc/Makefile.in |
31 | @@ -630,6 +630,7 @@ libexecdir = @libexecdir@ | 31 | @@ -632,6 +632,7 @@ libexecdir = @libexecdir@ |
32 | 32 | ||
33 | # Directory in which the compiler finds libraries etc. | 33 | # Directory in which the compiler finds libraries etc. |
34 | libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) | 34 | libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) |
@@ -36,7 +36,7 @@ index d1d4512bba3..06eb0d27a28 100644 | |||
36 | # Directory in which the compiler finds executables | 36 | # Directory in which the compiler finds executables |
37 | libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) | 37 | libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix) |
38 | # Directory in which all plugin resources are installed | 38 | # Directory in which all plugin resources are installed |
39 | @@ -3009,6 +3010,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" | 39 | @@ -3024,6 +3025,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\" |
40 | 40 | ||
41 | PREPROCESSOR_DEFINES = \ | 41 | PREPROCESSOR_DEFINES = \ |
42 | -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ | 42 | -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ |
@@ -45,10 +45,10 @@ index d1d4512bba3..06eb0d27a28 100644 | |||
45 | -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ | 45 | -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ |
46 | -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ | 46 | -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ |
47 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | 47 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h |
48 | index 87efc5f69fe..b525bcd56b3 100644 | 48 | index 4ce173384ef..8a3cd4f2d34 100644 |
49 | --- a/gcc/config/linux.h | 49 | --- a/gcc/config/linux.h |
50 | +++ b/gcc/config/linux.h | 50 | +++ b/gcc/config/linux.h |
51 | @@ -165,6 +165,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 51 | @@ -170,6 +170,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
52 | #define INCLUDE_DEFAULTS_MUSL_TOOL | 52 | #define INCLUDE_DEFAULTS_MUSL_TOOL |
53 | #endif | 53 | #endif |
54 | 54 | ||
@@ -62,7 +62,7 @@ index 87efc5f69fe..b525bcd56b3 100644 | |||
62 | #ifdef NATIVE_SYSTEM_HEADER_DIR | 62 | #ifdef NATIVE_SYSTEM_HEADER_DIR |
63 | #define INCLUDE_DEFAULTS_MUSL_NATIVE \ | 63 | #define INCLUDE_DEFAULTS_MUSL_NATIVE \ |
64 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ | 64 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ |
65 | @@ -191,6 +198,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 65 | @@ -196,6 +203,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
66 | INCLUDE_DEFAULTS_MUSL_PREFIX \ | 66 | INCLUDE_DEFAULTS_MUSL_PREFIX \ |
67 | INCLUDE_DEFAULTS_MUSL_CROSS \ | 67 | INCLUDE_DEFAULTS_MUSL_CROSS \ |
68 | INCLUDE_DEFAULTS_MUSL_TOOL \ | 68 | INCLUDE_DEFAULTS_MUSL_TOOL \ |
@@ -71,10 +71,10 @@ index 87efc5f69fe..b525bcd56b3 100644 | |||
71 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | 71 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ |
72 | { 0, 0, 0, 0, 0, 0 } \ | 72 | { 0, 0, 0, 0, 0, 0 } \ |
73 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h | 73 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h |
74 | index 510abe169c5..0c2bba5ea32 100644 | 74 | index a73954d9de5..e5dd6538358 100644 |
75 | --- a/gcc/config/rs6000/sysv4.h | 75 | --- a/gcc/config/rs6000/sysv4.h |
76 | +++ b/gcc/config/rs6000/sysv4.h | 76 | +++ b/gcc/config/rs6000/sysv4.h |
77 | @@ -995,6 +995,13 @@ ncrtn.o%s" | 77 | @@ -994,6 +994,13 @@ ncrtn.o%s" |
78 | #define INCLUDE_DEFAULTS_MUSL_TOOL | 78 | #define INCLUDE_DEFAULTS_MUSL_TOOL |
79 | #endif | 79 | #endif |
80 | 80 | ||
@@ -88,7 +88,7 @@ index 510abe169c5..0c2bba5ea32 100644 | |||
88 | #ifdef NATIVE_SYSTEM_HEADER_DIR | 88 | #ifdef NATIVE_SYSTEM_HEADER_DIR |
89 | #define INCLUDE_DEFAULTS_MUSL_NATIVE \ | 89 | #define INCLUDE_DEFAULTS_MUSL_NATIVE \ |
90 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ | 90 | { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ |
91 | @@ -1021,6 +1028,7 @@ ncrtn.o%s" | 91 | @@ -1020,6 +1027,7 @@ ncrtn.o%s" |
92 | INCLUDE_DEFAULTS_MUSL_PREFIX \ | 92 | INCLUDE_DEFAULTS_MUSL_PREFIX \ |
93 | INCLUDE_DEFAULTS_MUSL_CROSS \ | 93 | INCLUDE_DEFAULTS_MUSL_CROSS \ |
94 | INCLUDE_DEFAULTS_MUSL_TOOL \ | 94 | INCLUDE_DEFAULTS_MUSL_TOOL \ |
@@ -96,10 +96,10 @@ index 510abe169c5..0c2bba5ea32 100644 | |||
96 | INCLUDE_DEFAULTS_MUSL_NATIVE \ | 96 | INCLUDE_DEFAULTS_MUSL_NATIVE \ |
97 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | 97 | { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ |
98 | { 0, 0, 0, 0, 0, 0 } \ | 98 | { 0, 0, 0, 0, 0, 0 } \ |
99 | diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c | 99 | diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc |
100 | index c503d14fc3f..d54d6ce0076 100644 | 100 | index 7888300f277..52cf14e92f8 100644 |
101 | --- a/gcc/cppdefault.c | 101 | --- a/gcc/cppdefault.cc |
102 | +++ b/gcc/cppdefault.c | 102 | +++ b/gcc/cppdefault.cc |
103 | @@ -64,6 +64,10 @@ const struct default_include cpp_include_defaults[] | 103 | @@ -64,6 +64,10 @@ const struct default_include cpp_include_defaults[] |
104 | /* This is the dir for gcc's private headers. */ | 104 | /* This is the dir for gcc's private headers. */ |
105 | { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, | 105 | { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, |
diff --git a/meta/recipes-devtools/gcc/gcc/0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta/recipes-devtools/gcc/gcc/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch index 5b5d229eff..94308b2aca 100644 --- a/meta/recipes-devtools/gcc/gcc/0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch +++ b/meta/recipes-devtools/gcc/gcc/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From ab6e6af5deca6f4b35b089a6b197776df38780e6 Mon Sep 17 00:00:00 2001 | 1 | From 9ae49e7b88c208ab79ec9c2fc4a2fa8a3f1e85bb Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Tue, 3 Mar 2015 08:21:19 +0000 | 3 | Date: Tue, 3 Mar 2015 08:21:19 +0000 |
4 | Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix | 4 | Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix |
diff --git a/meta/recipes-devtools/gcc/gcc/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch b/meta/recipes-devtools/gcc/gcc/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch deleted file mode 100644 index 45953f861d..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | From 667b302f637be0a4b6ef714b5eb0026c54425386 Mon Sep 17 00:00:00 2001 | ||
2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
3 | Date: Sun, 31 Oct 2021 17:40:12 -0700 | ||
4 | Subject: [PATCH] Makefile.in: Ensure build CPP/CPPFLAGS is used for build | ||
5 | targets | ||
6 | |||
7 | During cross compiling, CPP is being set to the target compiler even for | ||
8 | build targets. As an example, when building a cross compiler targetting | ||
9 | mingw, the config.log for libiberty in | ||
10 | build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log | ||
11 | shows: | ||
12 | |||
13 | configure:3786: checking how to run the C preprocessor | ||
14 | configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 | ||
15 | configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c | ||
16 | configure:3876: $? = 0 | ||
17 | |||
18 | This is libiberty being built for the build environment, not the target one | ||
19 | (i.e. in build-x86_64-linux). As such it should be using the build environment's | ||
20 | gcc and not the target one. In the mingw case the system headers are quite | ||
21 | different leading to build failures related to not being able to include a | ||
22 | process.h file for pem-unix.c. | ||
23 | |||
24 | Further analysis shows the same issue occuring for CPPFLAGS too. | ||
25 | |||
26 | Fix this by adding support for CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD which | ||
27 | for example, avoids mixing the mingw headers for host binaries on linux | ||
28 | systems. | ||
29 | |||
30 | 2021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org> | ||
31 | |||
32 | ChangeLog: | ||
33 | |||
34 | * Makefile.tpl: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support | ||
35 | * Makefile.in: Regenerate. | ||
36 | * configure: Regenerate. | ||
37 | * configure.ac: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support | ||
38 | |||
39 | gcc/ChangeLog: | ||
40 | |||
41 | * configure: Regenerate. | ||
42 | * configure.ac: Use CPPFLAGS_FOR_BUILD for GMPINC | ||
43 | |||
44 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
45 | |||
46 | Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582727.html] | ||
47 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=84401ce5fb4ecab55decb472b168100e7593e01f] | ||
48 | |||
49 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
50 | --- | ||
51 | Makefile.in | 6 ++++++ | ||
52 | Makefile.tpl | 6 ++++++ | ||
53 | configure | 4 ++++ | ||
54 | configure.ac | 4 ++++ | ||
55 | gcc/configure | 2 +- | ||
56 | gcc/configure.ac | 2 +- | ||
57 | 6 files changed, 22 insertions(+), 2 deletions(-) | ||
58 | |||
59 | diff --git a/Makefile.in b/Makefile.in | ||
60 | index 20cbbe2906d..33476d53327 100644 | ||
61 | --- a/Makefile.in | ||
62 | +++ b/Makefile.in | ||
63 | @@ -154,6 +154,8 @@ BUILD_EXPORTS = \ | ||
64 | CC="$(CC_FOR_BUILD)"; export CC; \ | ||
65 | CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ | ||
66 | CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ | ||
67 | + CPP="$(CPP_FOR_BUILD)"; export CPP; \ | ||
68 | + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ | ||
69 | CXX="$(CXX_FOR_BUILD)"; export CXX; \ | ||
70 | CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ | ||
71 | GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ | ||
72 | @@ -202,6 +204,8 @@ HOST_EXPORTS = \ | ||
73 | AR="$(AR)"; export AR; \ | ||
74 | AS="$(AS)"; export AS; \ | ||
75 | CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ | ||
76 | + CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ | ||
77 | + CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ | ||
78 | CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ | ||
79 | DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ | ||
80 | DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ | ||
81 | @@ -360,6 +364,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@ | ||
82 | AS_FOR_BUILD = @AS_FOR_BUILD@ | ||
83 | CC_FOR_BUILD = @CC_FOR_BUILD@ | ||
84 | CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ | ||
85 | +CPP_FOR_BUILD = @CPP_FOR_BUILD@ | ||
86 | +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ | ||
87 | CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ | ||
88 | CXX_FOR_BUILD = @CXX_FOR_BUILD@ | ||
89 | DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ | ||
90 | diff --git a/Makefile.tpl b/Makefile.tpl | ||
91 | index 9adf4f94728..e39d85d1109 100644 | ||
92 | --- a/Makefile.tpl | ||
93 | +++ b/Makefile.tpl | ||
94 | @@ -157,6 +157,8 @@ BUILD_EXPORTS = \ | ||
95 | CC="$(CC_FOR_BUILD)"; export CC; \ | ||
96 | CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ | ||
97 | CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ | ||
98 | + CPP="$(CPP_FOR_BUILD)"; export CPP; \ | ||
99 | + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ | ||
100 | CXX="$(CXX_FOR_BUILD)"; export CXX; \ | ||
101 | CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ | ||
102 | GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ | ||
103 | @@ -205,6 +207,8 @@ HOST_EXPORTS = \ | ||
104 | AR="$(AR)"; export AR; \ | ||
105 | AS="$(AS)"; export AS; \ | ||
106 | CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ | ||
107 | + CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ | ||
108 | + CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ | ||
109 | CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ | ||
110 | DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ | ||
111 | DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \ | ||
112 | @@ -363,6 +367,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@ | ||
113 | AS_FOR_BUILD = @AS_FOR_BUILD@ | ||
114 | CC_FOR_BUILD = @CC_FOR_BUILD@ | ||
115 | CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ | ||
116 | +CPP_FOR_BUILD = @CPP_FOR_BUILD@ | ||
117 | +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ | ||
118 | CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ | ||
119 | CXX_FOR_BUILD = @CXX_FOR_BUILD@ | ||
120 | DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ | ||
121 | diff --git a/configure b/configure | ||
122 | index 45744e6e471..ff0de8a68b4 100755 | ||
123 | --- a/configure | ||
124 | +++ b/configure | ||
125 | @@ -655,6 +655,8 @@ DSYMUTIL_FOR_BUILD | ||
126 | DLLTOOL_FOR_BUILD | ||
127 | CXX_FOR_BUILD | ||
128 | CXXFLAGS_FOR_BUILD | ||
129 | +CPPFLAGS_FOR_BUILD | ||
130 | +CPP_FOR_BUILD | ||
131 | CFLAGS_FOR_BUILD | ||
132 | CC_FOR_BUILD | ||
133 | AS_FOR_BUILD | ||
134 | @@ -4100,6 +4102,7 @@ if test "${build}" != "${host}" ; then | ||
135 | AR_FOR_BUILD=${AR_FOR_BUILD-ar} | ||
136 | AS_FOR_BUILD=${AS_FOR_BUILD-as} | ||
137 | CC_FOR_BUILD=${CC_FOR_BUILD-gcc} | ||
138 | + CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}" | ||
139 | CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} | ||
140 | DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil} | ||
141 | GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} | ||
142 | @@ -9831,6 +9834,7 @@ esac | ||
143 | # our build compiler if desired. | ||
144 | if test x"${build}" = x"${host}" ; then | ||
145 | CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} | ||
146 | + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}} | ||
147 | CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}} | ||
148 | LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} | ||
149 | fi | ||
150 | diff --git a/configure.ac b/configure.ac | ||
151 | index bf66b51373c..09fa3896dc7 100644 | ||
152 | --- a/configure.ac | ||
153 | +++ b/configure.ac | ||
154 | @@ -1347,6 +1347,7 @@ if test "${build}" != "${host}" ; then | ||
155 | AR_FOR_BUILD=${AR_FOR_BUILD-ar} | ||
156 | AS_FOR_BUILD=${AS_FOR_BUILD-as} | ||
157 | CC_FOR_BUILD=${CC_FOR_BUILD-gcc} | ||
158 | + CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}" | ||
159 | CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} | ||
160 | DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil} | ||
161 | GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} | ||
162 | @@ -3336,6 +3337,7 @@ esac | ||
163 | # our build compiler if desired. | ||
164 | if test x"${build}" = x"${host}" ; then | ||
165 | CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} | ||
166 | + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}} | ||
167 | CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}} | ||
168 | LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} | ||
169 | fi | ||
170 | @@ -3402,6 +3404,8 @@ AC_SUBST(AR_FOR_BUILD) | ||
171 | AC_SUBST(AS_FOR_BUILD) | ||
172 | AC_SUBST(CC_FOR_BUILD) | ||
173 | AC_SUBST(CFLAGS_FOR_BUILD) | ||
174 | +AC_SUBST(CPP_FOR_BUILD) | ||
175 | +AC_SUBST(CPPFLAGS_FOR_BUILD) | ||
176 | AC_SUBST(CXXFLAGS_FOR_BUILD) | ||
177 | AC_SUBST(CXX_FOR_BUILD) | ||
178 | AC_SUBST(DLLTOOL_FOR_BUILD) | ||
179 | diff --git a/gcc/configure b/gcc/configure | ||
180 | index ec3c24482df..31a460dc9d0 100755 | ||
181 | --- a/gcc/configure | ||
182 | +++ b/gcc/configure | ||
183 | @@ -12740,7 +12740,7 @@ else | ||
184 | CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ | ||
185 | CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ | ||
186 | LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ | ||
187 | - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ | ||
188 | + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ | ||
189 | ${realsrcdir}/configure \ | ||
190 | --enable-languages=${enable_languages-all} \ | ||
191 | ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ | ||
192 | diff --git a/gcc/configure.ac b/gcc/configure.ac | ||
193 | index ea794cd1763..b965eb036bc 100644 | ||
194 | --- a/gcc/configure.ac | ||
195 | +++ b/gcc/configure.ac | ||
196 | @@ -2054,7 +2054,7 @@ else | ||
197 | CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ | ||
198 | CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ | ||
199 | LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ | ||
200 | - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ | ||
201 | + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ | ||
202 | ${realsrcdir}/configure \ | ||
203 | --enable-languages=${enable_languages-all} \ | ||
204 | ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta/recipes-devtools/gcc/gcc/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch index b82277cc4b..ce9635ce4d 100644 --- a/meta/recipes-devtools/gcc/gcc/0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch +++ b/meta/recipes-devtools/gcc/gcc/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From fd862c8c112067d8613d921ae89c99056aca54a1 Mon Sep 17 00:00:00 2001 | 1 | From bf918db7117f41d3c04162095641165ca241707d Mon Sep 17 00:00:00 2001 |
2 | From: Robert Yang <liezhi.yang@windriver.com> | 2 | From: Robert Yang <liezhi.yang@windriver.com> |
3 | Date: Sun, 5 Jul 2015 20:25:18 -0700 | 3 | Date: Sun, 5 Jul 2015 20:25:18 -0700 |
4 | Subject: [PATCH] libcc1: fix libcc1's install path and rpath | 4 | Subject: [PATCH] libcc1: fix libcc1's install path and rpath |
@@ -20,10 +20,10 @@ Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | |||
20 | 2 files changed, 4 insertions(+), 4 deletions(-) | 20 | 2 files changed, 4 insertions(+), 4 deletions(-) |
21 | 21 | ||
22 | diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am | 22 | diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am |
23 | index 3b75e7d9290..d3a4c4f9ddf 100644 | 23 | index 6e3a34ff7e2..3f3f6391aba 100644 |
24 | --- a/libcc1/Makefile.am | 24 | --- a/libcc1/Makefile.am |
25 | +++ b/libcc1/Makefile.am | 25 | +++ b/libcc1/Makefile.am |
26 | @@ -41,8 +41,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ | 26 | @@ -40,8 +40,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ |
27 | $(Wc)$(libiberty_normal))) | 27 | $(Wc)$(libiberty_normal))) |
28 | libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) | 28 | libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) |
29 | 29 | ||
@@ -35,10 +35,10 @@ index 3b75e7d9290..d3a4c4f9ddf 100644 | |||
35 | if ENABLE_PLUGIN | 35 | if ENABLE_PLUGIN |
36 | plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la | 36 | plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la |
37 | diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in | 37 | diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in |
38 | index 07fa9d94c83..a9f737d78f2 100644 | 38 | index f8f590d71e9..56462492045 100644 |
39 | --- a/libcc1/Makefile.in | 39 | --- a/libcc1/Makefile.in |
40 | +++ b/libcc1/Makefile.in | 40 | +++ b/libcc1/Makefile.in |
41 | @@ -398,8 +398,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ | 41 | @@ -396,8 +396,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ |
42 | $(Wc)$(libiberty_normal))) | 42 | $(Wc)$(libiberty_normal))) |
43 | 43 | ||
44 | libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) | 44 | libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) |
diff --git a/meta/recipes-devtools/gcc/gcc/0017-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch index 5d86e4c12d..3b54719536 100644 --- a/meta/recipes-devtools/gcc/gcc/0017-handle-sysroot-support-for-nativesdk-gcc.patch +++ b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 68802ca536b01ab21cfa58e11ef332e30d9a3c5e Mon Sep 17 00:00:00 2001 | 1 | From 4fbbd40d7db89cdbeaf93df1e1da692b1f80a5bc Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Mon, 7 Dec 2015 23:39:54 +0000 | 3 | Date: Mon, 7 Dec 2015 23:39:54 +0000 |
4 | Subject: [PATCH] handle sysroot support for nativesdk-gcc | 4 | Subject: [PATCH] handle sysroot support for nativesdk-gcc |
@@ -35,21 +35,21 @@ implementation.) | |||
35 | 35 | ||
36 | Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> | 36 | Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> |
37 | --- | 37 | --- |
38 | gcc/c-family/c-opts.c | 4 +-- | 38 | gcc/c-family/c-opts.cc | 4 +-- |
39 | gcc/config/linux.h | 24 +++++++-------- | 39 | gcc/config/linux.h | 24 +++++++-------- |
40 | gcc/config/rs6000/sysv4.h | 24 +++++++-------- | 40 | gcc/config/rs6000/sysv4.h | 24 +++++++-------- |
41 | gcc/cppdefault.c | 63 ++++++++++++++++++++++++--------------- | 41 | gcc/cppdefault.cc | 63 ++++++++++++++++++++++++--------------- |
42 | gcc/cppdefault.h | 13 ++++---- | 42 | gcc/cppdefault.h | 13 ++++---- |
43 | gcc/gcc.c | 20 +++++++++---- | 43 | gcc/gcc.cc | 20 +++++++++---- |
44 | gcc/incpath.c | 12 ++++---- | 44 | gcc/incpath.cc | 12 ++++---- |
45 | gcc/prefix.c | 6 ++-- | 45 | gcc/prefix.cc | 6 ++-- |
46 | 8 files changed, 94 insertions(+), 72 deletions(-) | 46 | 8 files changed, 94 insertions(+), 72 deletions(-) |
47 | 47 | ||
48 | diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c | 48 | diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc |
49 | index 6f001e0bb6c..55ab07c278f 100644 | 49 | index a341a061758..83b0bef4dbb 100644 |
50 | --- a/gcc/c-family/c-opts.c | 50 | --- a/gcc/c-family/c-opts.cc |
51 | +++ b/gcc/c-family/c-opts.c | 51 | +++ b/gcc/c-family/c-opts.cc |
52 | @@ -1438,8 +1438,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain) | 52 | @@ -1458,8 +1458,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain) |
53 | size_t prefix_len, suffix_len; | 53 | size_t prefix_len, suffix_len; |
54 | 54 | ||
55 | suffix_len = strlen (suffix); | 55 | suffix_len = strlen (suffix); |
@@ -61,11 +61,11 @@ index 6f001e0bb6c..55ab07c278f 100644 | |||
61 | path = (char *) xmalloc (prefix_len + suffix_len + 1); | 61 | path = (char *) xmalloc (prefix_len + suffix_len + 1); |
62 | memcpy (path, prefix, prefix_len); | 62 | memcpy (path, prefix, prefix_len); |
63 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | 63 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h |
64 | index b525bcd56b3..ba02c013e30 100644 | 64 | index 8a3cd4f2d34..58143dff731 100644 |
65 | --- a/gcc/config/linux.h | 65 | --- a/gcc/config/linux.h |
66 | +++ b/gcc/config/linux.h | 66 | +++ b/gcc/config/linux.h |
67 | @@ -129,53 +129,53 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 67 | @@ -134,53 +134,53 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
68 | * Unfortunately, this is mostly duplicated from cppdefault.c */ | 68 | * Unfortunately, this is mostly duplicated from cppdefault.cc */ |
69 | #if DEFAULT_LIBC == LIBC_MUSL | 69 | #if DEFAULT_LIBC == LIBC_MUSL |
70 | #define INCLUDE_DEFAULTS_MUSL_GPP \ | 70 | #define INCLUDE_DEFAULTS_MUSL_GPP \ |
71 | - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ | 71 | - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ |
@@ -129,7 +129,7 @@ index b525bcd56b3..ba02c013e30 100644 | |||
129 | #else | 129 | #else |
130 | #define INCLUDE_DEFAULTS_MUSL_NATIVE | 130 | #define INCLUDE_DEFAULTS_MUSL_NATIVE |
131 | #endif | 131 | #endif |
132 | @@ -200,7 +200,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 132 | @@ -205,7 +205,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
133 | INCLUDE_DEFAULTS_MUSL_TOOL \ | 133 | INCLUDE_DEFAULTS_MUSL_TOOL \ |
134 | INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \ | 134 | INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \ |
135 | INCLUDE_DEFAULTS_MUSL_NATIVE \ | 135 | INCLUDE_DEFAULTS_MUSL_NATIVE \ |
@@ -139,10 +139,10 @@ index b525bcd56b3..ba02c013e30 100644 | |||
139 | } | 139 | } |
140 | #endif | 140 | #endif |
141 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h | 141 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h |
142 | index 0c2bba5ea32..313a8de4417 100644 | 142 | index e5dd6538358..b496849b792 100644 |
143 | --- a/gcc/config/rs6000/sysv4.h | 143 | --- a/gcc/config/rs6000/sysv4.h |
144 | +++ b/gcc/config/rs6000/sysv4.h | 144 | +++ b/gcc/config/rs6000/sysv4.h |
145 | @@ -959,53 +959,53 @@ ncrtn.o%s" | 145 | @@ -958,53 +958,53 @@ ncrtn.o%s" |
146 | /* Include order changes for musl, same as in generic linux.h. */ | 146 | /* Include order changes for musl, same as in generic linux.h. */ |
147 | #if DEFAULT_LIBC == LIBC_MUSL | 147 | #if DEFAULT_LIBC == LIBC_MUSL |
148 | #define INCLUDE_DEFAULTS_MUSL_GPP \ | 148 | #define INCLUDE_DEFAULTS_MUSL_GPP \ |
@@ -207,7 +207,7 @@ index 0c2bba5ea32..313a8de4417 100644 | |||
207 | #else | 207 | #else |
208 | #define INCLUDE_DEFAULTS_MUSL_NATIVE | 208 | #define INCLUDE_DEFAULTS_MUSL_NATIVE |
209 | #endif | 209 | #endif |
210 | @@ -1030,7 +1030,7 @@ ncrtn.o%s" | 210 | @@ -1029,7 +1029,7 @@ ncrtn.o%s" |
211 | INCLUDE_DEFAULTS_MUSL_TOOL \ | 211 | INCLUDE_DEFAULTS_MUSL_TOOL \ |
212 | INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \ | 212 | INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \ |
213 | INCLUDE_DEFAULTS_MUSL_NATIVE \ | 213 | INCLUDE_DEFAULTS_MUSL_NATIVE \ |
@@ -216,10 +216,10 @@ index 0c2bba5ea32..313a8de4417 100644 | |||
216 | { 0, 0, 0, 0, 0, 0 } \ | 216 | { 0, 0, 0, 0, 0, 0 } \ |
217 | } | 217 | } |
218 | #endif | 218 | #endif |
219 | diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c | 219 | diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc |
220 | index d54d6ce0076..784a92a0c24 100644 | 220 | index 52cf14e92f8..d8977afc05e 100644 |
221 | --- a/gcc/cppdefault.c | 221 | --- a/gcc/cppdefault.cc |
222 | +++ b/gcc/cppdefault.c | 222 | +++ b/gcc/cppdefault.cc |
223 | @@ -35,6 +35,30 @@ | 223 | @@ -35,6 +35,30 @@ |
224 | # undef CROSS_INCLUDE_DIR | 224 | # undef CROSS_INCLUDE_DIR |
225 | #endif | 225 | #endif |
@@ -343,7 +343,7 @@ index d54d6ce0076..784a92a0c24 100644 | |||
343 | /* This value is set by cpp_relocated at runtime */ | 343 | /* This value is set by cpp_relocated at runtime */ |
344 | const char *gcc_exec_prefix; | 344 | const char *gcc_exec_prefix; |
345 | diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h | 345 | diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h |
346 | index fd3c655db1c..20669ac427d 100644 | 346 | index fb97c0b5814..6267150facc 100644 |
347 | --- a/gcc/cppdefault.h | 347 | --- a/gcc/cppdefault.h |
348 | +++ b/gcc/cppdefault.h | 348 | +++ b/gcc/cppdefault.h |
349 | @@ -33,7 +33,8 @@ | 349 | @@ -33,7 +33,8 @@ |
@@ -354,7 +354,7 @@ index fd3c655db1c..20669ac427d 100644 | |||
354 | + const char *fname; /* The name of the directory. */ | 354 | + const char *fname; /* The name of the directory. */ |
355 | + | 355 | + |
356 | const char *const component; /* The component containing the directory | 356 | const char *const component; /* The component containing the directory |
357 | (see update_path in prefix.c) */ | 357 | (see update_path in prefix.cc) */ |
358 | const char cplusplus; /* When this is non-zero, we should only | 358 | const char cplusplus; /* When this is non-zero, we should only |
359 | @@ -55,17 +56,13 @@ struct default_include | 359 | @@ -55,17 +56,13 @@ struct default_include |
360 | }; | 360 | }; |
@@ -377,10 +377,10 @@ index fd3c655db1c..20669ac427d 100644 | |||
377 | /* The run-time execution prefix. This is typically the lib/gcc | 377 | /* The run-time execution prefix. This is typically the lib/gcc |
378 | subdirectory of the actual installation. */ | 378 | subdirectory of the actual installation. */ |
379 | extern const char *gcc_exec_prefix; | 379 | extern const char *gcc_exec_prefix; |
380 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 380 | diff --git a/gcc/gcc.cc b/gcc/gcc.cc |
381 | index bdee2671532..36e8af38630 100644 | 381 | index aa4cf92fb78..5569a39a14a 100644 |
382 | --- a/gcc/gcc.c | 382 | --- a/gcc/gcc.cc |
383 | +++ b/gcc/gcc.c | 383 | +++ b/gcc/gcc.cc |
384 | @@ -252,6 +252,8 @@ FILE *report_times_to_file = NULL; | 384 | @@ -252,6 +252,8 @@ FILE *report_times_to_file = NULL; |
385 | #endif | 385 | #endif |
386 | static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; | 386 | static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; |
@@ -390,7 +390,7 @@ index bdee2671532..36e8af38630 100644 | |||
390 | /* Nonzero means pass the updated target_system_root to the compiler. */ | 390 | /* Nonzero means pass the updated target_system_root to the compiler. */ |
391 | 391 | ||
392 | static int target_system_root_changed; | 392 | static int target_system_root_changed; |
393 | @@ -568,6 +570,7 @@ or with constant text in a single argument. | 393 | @@ -575,6 +577,7 @@ or with constant text in a single argument. |
394 | %G process LIBGCC_SPEC as a spec. | 394 | %G process LIBGCC_SPEC as a spec. |
395 | %R Output the concatenation of target_system_root and | 395 | %R Output the concatenation of target_system_root and |
396 | target_sysroot_suffix. | 396 | target_sysroot_suffix. |
@@ -398,7 +398,7 @@ index bdee2671532..36e8af38630 100644 | |||
398 | %S process STARTFILE_SPEC as a spec. A capital S is actually used here. | 398 | %S process STARTFILE_SPEC as a spec. A capital S is actually used here. |
399 | %E process ENDFILE_SPEC as a spec. A capital E is actually used here. | 399 | %E process ENDFILE_SPEC as a spec. A capital E is actually used here. |
400 | %C process CPP_SPEC as a spec. | 400 | %C process CPP_SPEC as a spec. |
401 | @@ -1620,10 +1623,10 @@ static const char *gcc_libexec_prefix; | 401 | @@ -1627,10 +1630,10 @@ static const char *gcc_libexec_prefix; |
402 | gcc_exec_prefix is set because, in that case, we know where the | 402 | gcc_exec_prefix is set because, in that case, we know where the |
403 | compiler has been installed, and use paths relative to that | 403 | compiler has been installed, and use paths relative to that |
404 | location instead. */ | 404 | location instead. */ |
@@ -413,7 +413,7 @@ index bdee2671532..36e8af38630 100644 | |||
413 | 413 | ||
414 | /* For native compilers, these are well-known paths containing | 414 | /* For native compilers, these are well-known paths containing |
415 | components that may be provided by the system. For cross | 415 | components that may be provided by the system. For cross |
416 | @@ -1631,9 +1634,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; | 416 | @@ -1638,9 +1641,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; |
417 | static const char *md_exec_prefix = MD_EXEC_PREFIX; | 417 | static const char *md_exec_prefix = MD_EXEC_PREFIX; |
418 | static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; | 418 | static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; |
419 | static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; | 419 | static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; |
@@ -425,7 +425,7 @@ index bdee2671532..36e8af38630 100644 | |||
425 | = STANDARD_STARTFILE_PREFIX_2; | 425 | = STANDARD_STARTFILE_PREFIX_2; |
426 | 426 | ||
427 | /* A relative path to be used in finding the location of tools | 427 | /* A relative path to be used in finding the location of tools |
428 | @@ -6570,6 +6573,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) | 428 | @@ -6676,6 +6679,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) |
429 | } | 429 | } |
430 | break; | 430 | break; |
431 | 431 | ||
@@ -437,11 +437,11 @@ index bdee2671532..36e8af38630 100644 | |||
437 | case 'S': | 437 | case 'S': |
438 | value = do_spec_1 (startfile_spec, 0, NULL); | 438 | value = do_spec_1 (startfile_spec, 0, NULL); |
439 | if (value != 0) | 439 | if (value != 0) |
440 | diff --git a/gcc/incpath.c b/gcc/incpath.c | 440 | diff --git a/gcc/incpath.cc b/gcc/incpath.cc |
441 | index fbfc0ce03b8..a82e543428b 100644 | 441 | index c80f100f476..5ac03c08693 100644 |
442 | --- a/gcc/incpath.c | 442 | --- a/gcc/incpath.cc |
443 | +++ b/gcc/incpath.c | 443 | +++ b/gcc/incpath.cc |
444 | @@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, | 444 | @@ -135,7 +135,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, |
445 | int relocated = cpp_relocated (); | 445 | int relocated = cpp_relocated (); |
446 | size_t len; | 446 | size_t len; |
447 | 447 | ||
@@ -450,7 +450,7 @@ index fbfc0ce03b8..a82e543428b 100644 | |||
450 | { | 450 | { |
451 | /* Look for directories that start with the standard prefix. | 451 | /* Look for directories that start with the standard prefix. |
452 | "Translate" them, i.e. replace /usr/local/lib/gcc... with | 452 | "Translate" them, i.e. replace /usr/local/lib/gcc... with |
453 | @@ -146,7 +146,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, | 453 | @@ -150,7 +150,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, |
454 | now. */ | 454 | now. */ |
455 | if (sysroot && p->add_sysroot) | 455 | if (sysroot && p->add_sysroot) |
456 | continue; | 456 | continue; |
@@ -459,7 +459,7 @@ index fbfc0ce03b8..a82e543428b 100644 | |||
459 | { | 459 | { |
460 | char *str = concat (iprefix, p->fname + len, NULL); | 460 | char *str = concat (iprefix, p->fname + len, NULL); |
461 | if (p->multilib == 1 && imultilib) | 461 | if (p->multilib == 1 && imultilib) |
462 | @@ -187,7 +187,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, | 462 | @@ -191,7 +191,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, |
463 | free (sysroot_no_trailing_dir_separator); | 463 | free (sysroot_no_trailing_dir_separator); |
464 | } | 464 | } |
465 | else if (!p->add_sysroot && relocated | 465 | else if (!p->add_sysroot && relocated |
@@ -468,7 +468,7 @@ index fbfc0ce03b8..a82e543428b 100644 | |||
468 | { | 468 | { |
469 | static const char *relocated_prefix; | 469 | static const char *relocated_prefix; |
470 | char *ostr; | 470 | char *ostr; |
471 | @@ -204,12 +204,12 @@ add_standard_paths (const char *sysroot, const char *iprefix, | 471 | @@ -208,12 +208,12 @@ add_standard_paths (const char *sysroot, const char *iprefix, |
472 | dummy = concat (gcc_exec_prefix, "dummy", NULL); | 472 | dummy = concat (gcc_exec_prefix, "dummy", NULL); |
473 | relocated_prefix | 473 | relocated_prefix |
474 | = make_relative_prefix (dummy, | 474 | = make_relative_prefix (dummy, |
@@ -484,10 +484,10 @@ index fbfc0ce03b8..a82e543428b 100644 | |||
484 | NULL); | 484 | NULL); |
485 | str = update_path (ostr, p->component); | 485 | str = update_path (ostr, p->component); |
486 | free (ostr); | 486 | free (ostr); |
487 | diff --git a/gcc/prefix.c b/gcc/prefix.c | 487 | diff --git a/gcc/prefix.cc b/gcc/prefix.cc |
488 | index 747c09de638..f728638dc65 100644 | 488 | index 096ed5afa3d..2526f0ecc39 100644 |
489 | --- a/gcc/prefix.c | 489 | --- a/gcc/prefix.cc |
490 | +++ b/gcc/prefix.c | 490 | +++ b/gcc/prefix.cc |
491 | @@ -72,7 +72,9 @@ License along with GCC; see the file COPYING3. If not see | 491 | @@ -72,7 +72,9 @@ License along with GCC; see the file COPYING3. If not see |
492 | #include "prefix.h" | 492 | #include "prefix.h" |
493 | #include "common/common-target.h" | 493 | #include "common/common-target.h" |
diff --git a/meta/recipes-devtools/gcc/gcc/0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta/recipes-devtools/gcc/gcc/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch index 0f43e985cf..9b05da64a7 100644 --- a/meta/recipes-devtools/gcc/gcc/0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch +++ b/meta/recipes-devtools/gcc/gcc/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 14291076874b133e7fb67ef1714b768a2c48ea44 Mon Sep 17 00:00:00 2001 | 1 | From 33a1f07a4417247dc24819d4e583ca09f56d5a7b Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Mon, 7 Dec 2015 23:41:45 +0000 | 3 | Date: Mon, 7 Dec 2015 23:41:45 +0000 |
4 | Subject: [PATCH] Search target sysroot gcc version specific dirs with | 4 | Subject: [PATCH] Search target sysroot gcc version specific dirs with |
@@ -47,14 +47,14 @@ RP 2015/7/31 | |||
47 | 47 | ||
48 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 48 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
49 | --- | 49 | --- |
50 | gcc/gcc.c | 29 ++++++++++++++++++++++++++++- | 50 | gcc/gcc.cc | 29 ++++++++++++++++++++++++++++- |
51 | 1 file changed, 28 insertions(+), 1 deletion(-) | 51 | 1 file changed, 28 insertions(+), 1 deletion(-) |
52 | 52 | ||
53 | diff --git a/gcc/gcc.c b/gcc/gcc.c | 53 | diff --git a/gcc/gcc.cc b/gcc/gcc.cc |
54 | index 36e8af38630..d1faa788d60 100644 | 54 | index 5569a39a14a..4598f6cd7c9 100644 |
55 | --- a/gcc/gcc.c | 55 | --- a/gcc/gcc.cc |
56 | +++ b/gcc/gcc.c | 56 | +++ b/gcc/gcc.cc |
57 | @@ -2810,7 +2810,7 @@ for_each_path (const struct path_prefix *paths, | 57 | @@ -2817,7 +2817,7 @@ for_each_path (const struct path_prefix *paths, |
58 | if (path == NULL) | 58 | if (path == NULL) |
59 | { | 59 | { |
60 | len = paths->max_len + extra_space + 1; | 60 | len = paths->max_len + extra_space + 1; |
@@ -63,7 +63,7 @@ index 36e8af38630..d1faa788d60 100644 | |||
63 | path = XNEWVEC (char, len); | 63 | path = XNEWVEC (char, len); |
64 | } | 64 | } |
65 | 65 | ||
66 | @@ -2822,6 +2822,33 @@ for_each_path (const struct path_prefix *paths, | 66 | @@ -2829,6 +2829,33 @@ for_each_path (const struct path_prefix *paths, |
67 | /* Look first in MACHINE/VERSION subdirectory. */ | 67 | /* Look first in MACHINE/VERSION subdirectory. */ |
68 | if (!skip_multi_dir) | 68 | if (!skip_multi_dir) |
69 | { | 69 | { |
diff --git a/meta/recipes-devtools/gcc/gcc/0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta/recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch index b82fa44537..56793e03a3 100644 --- a/meta/recipes-devtools/gcc/gcc/0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch +++ b/meta/recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From af72a47a677ce98c08cb73444bdd741ca8e28422 Mon Sep 17 00:00:00 2001 | 1 | From d7dc2861840e88a4592817a398a054a886c3f3ee Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Tue, 27 Jun 2017 18:10:54 -0700 | 3 | Date: Tue, 27 Jun 2017 18:10:54 -0700 |
4 | Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets | 4 | Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets |
@@ -23,10 +23,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
23 | 3 files changed, 27 insertions(+) | 23 | 3 files changed, 27 insertions(+) |
24 | 24 | ||
25 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | 25 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h |
26 | index ba02c013e30..8fcaa0c9faf 100644 | 26 | index 58143dff731..d2409ccac26 100644 |
27 | --- a/gcc/config/linux.h | 27 | --- a/gcc/config/linux.h |
28 | +++ b/gcc/config/linux.h | 28 | +++ b/gcc/config/linux.h |
29 | @@ -203,6 +203,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 29 | @@ -208,6 +208,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
30 | { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 }, \ | 30 | { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 }, \ |
31 | { 0, 0, 0, 0, 0, 0 } \ | 31 | { 0, 0, 0, 0, 0, 0 } \ |
32 | } | 32 | } |
@@ -41,10 +41,10 @@ index ba02c013e30..8fcaa0c9faf 100644 | |||
41 | 41 | ||
42 | #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ | 42 | #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ |
43 | diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h | 43 | diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h |
44 | index 47c9d9ac0b6..d065f88b377 100644 | 44 | index 8c9039ac1e5..259cd485973 100644 |
45 | --- a/gcc/config/rs6000/linux.h | 45 | --- a/gcc/config/rs6000/linux.h |
46 | +++ b/gcc/config/rs6000/linux.h | 46 | +++ b/gcc/config/rs6000/linux.h |
47 | @@ -94,6 +94,16 @@ | 47 | @@ -99,6 +99,16 @@ |
48 | " -m elf32ppclinux") | 48 | " -m elf32ppclinux") |
49 | #endif | 49 | #endif |
50 | 50 | ||
@@ -62,10 +62,10 @@ index 47c9d9ac0b6..d065f88b377 100644 | |||
62 | #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ | 62 | #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ |
63 | %{!static-pie: \ | 63 | %{!static-pie: \ |
64 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h | 64 | diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h |
65 | index a11e01faa3d..ce464f3626b 100644 | 65 | index 364c1a5b155..e33d9ae98e0 100644 |
66 | --- a/gcc/config/rs6000/linux64.h | 66 | --- a/gcc/config/rs6000/linux64.h |
67 | +++ b/gcc/config/rs6000/linux64.h | 67 | +++ b/gcc/config/rs6000/linux64.h |
68 | @@ -369,6 +369,16 @@ extern int dot_symbols; | 68 | @@ -372,6 +372,16 @@ extern int dot_symbols; |
69 | " -m elf64ppc") | 69 | " -m elf64ppc") |
70 | #endif | 70 | #endif |
71 | 71 | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0023-Re-introduce-spe-commandline-options.patch b/meta/recipes-devtools/gcc/gcc/0019-Re-introduce-spe-commandline-options.patch index 23cf02a6e4..bb1699be25 100644 --- a/meta/recipes-devtools/gcc/gcc/0023-Re-introduce-spe-commandline-options.patch +++ b/meta/recipes-devtools/gcc/gcc/0019-Re-introduce-spe-commandline-options.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From ca73043041c3c7aa86af9a3d4f316abc87eb3254 Mon Sep 17 00:00:00 2001 | 1 | From bf0d7c463e1fab62804556099b56319fe94be1eb Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Wed, 6 Jun 2018 12:10:22 -0700 | 3 | Date: Wed, 6 Jun 2018 12:10:22 -0700 |
4 | Subject: [PATCH] Re-introduce spe commandline options | 4 | Subject: [PATCH] Re-introduce spe commandline options |
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
14 | 1 file changed, 13 insertions(+) | 14 | 1 file changed, 13 insertions(+) |
15 | 15 | ||
16 | diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt | 16 | diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt |
17 | index 6b0a3e27529..1bd2e356ac9 100644 | 17 | index 4931d781c4e..3fb87b6f7d5 100644 |
18 | --- a/gcc/config/rs6000/rs6000.opt | 18 | --- a/gcc/config/rs6000/rs6000.opt |
19 | +++ b/gcc/config/rs6000/rs6000.opt | 19 | +++ b/gcc/config/rs6000/rs6000.opt |
20 | @@ -352,6 +352,19 @@ mdebug= | 20 | @@ -348,6 +348,19 @@ mdebug= |
21 | Target RejectNegative Joined | 21 | Target RejectNegative Joined |
22 | -mdebug= Enable debug output. | 22 | -mdebug= Enable debug output. |
23 | 23 | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta/recipes-devtools/gcc/gcc/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch deleted file mode 100644 index 76ebfd7f77..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | From 9ec4db8e910d9a51ae43f6b20d4bf1dac2d8cca8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Tue, 2 Feb 2016 10:26:10 -0800 | ||
4 | Subject: [PATCH] nios2: Define MUSL_DYNAMIC_LINKER | ||
5 | |||
6 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e5ddbbf992b909d8e38851bd3179d29389e6ac97] | ||
7 | |||
8 | Signed-off-by: Marek Vasut <marex@denx.de> | ||
9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
10 | --- | ||
11 | gcc/config/nios2/linux.h | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h | ||
15 | index 08edf1521f6..15696d86241 100644 | ||
16 | --- a/gcc/config/nios2/linux.h | ||
17 | +++ b/gcc/config/nios2/linux.h | ||
18 | @@ -30,6 +30,7 @@ | ||
19 | #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" | ||
20 | |||
21 | #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1" | ||
22 | +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1" | ||
23 | |||
24 | #undef LINK_SPEC | ||
25 | #define LINK_SPEC LINK_SPEC_ENDIAN \ | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta/recipes-devtools/gcc/gcc/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch index f915f284ea..f37092089f 100644 --- a/meta/recipes-devtools/gcc/gcc/0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch +++ b/meta/recipes-devtools/gcc/gcc/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From b3957bc1fd52ec427a1b71b10055905cab4bbc7c Mon Sep 17 00:00:00 2001 | 1 | From a32c75b37209d6836eaaa943dc6b1207acba5d27 Mon Sep 17 00:00:00 2001 |
2 | From: Szabolcs Nagy <nsz@port70.net> | 2 | From: Szabolcs Nagy <nsz@port70.net> |
3 | Date: Sat, 24 Oct 2015 20:09:53 +0000 | 3 | Date: Sat, 24 Oct 2015 20:09:53 +0000 |
4 | Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of | 4 | Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of |
@@ -33,30 +33,30 @@ Upstream-Status: Pending | |||
33 | 33 | ||
34 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 34 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
35 | --- | 35 | --- |
36 | gcc/config/i386/i386-expand.c | 4 ++-- | 36 | gcc/config/i386/i386-expand.cc | 4 ++-- |
37 | libgcc/config/i386/cpuinfo.c | 6 +++--- | 37 | libgcc/config/i386/cpuinfo.c | 6 +++--- |
38 | libgcc/config/i386/t-linux | 2 +- | 38 | libgcc/config/i386/t-linux | 2 +- |
39 | 3 files changed, 6 insertions(+), 6 deletions(-) | 39 | 3 files changed, 6 insertions(+), 6 deletions(-) |
40 | 40 | ||
41 | diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c | 41 | diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc |
42 | index 31eae75d277..ec7e858ec83 100644 | 42 | index 68978ef8dc2..0c71f36b572 100644 |
43 | --- a/gcc/config/i386/i386-expand.c | 43 | --- a/gcc/config/i386/i386-expand.cc |
44 | +++ b/gcc/config/i386/i386-expand.c | 44 | +++ b/gcc/config/i386/i386-expand.cc |
45 | @@ -11066,10 +11066,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, | 45 | @@ -12321,10 +12321,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, |
46 | { | 46 | { |
47 | case IX86_BUILTIN_CPU_INIT: | 47 | case IX86_BUILTIN_CPU_INIT: |
48 | { | 48 | { |
49 | - /* Make it call __cpu_indicator_init in libgcc. */ | 49 | - /* Make it call __cpu_indicator_init in libgcc. */ |
50 | + /* Make it call __cpu_indicator_init_local in libgcc.a. */ | 50 | + /* Make it call __cpu_indicator_init_local in libgcc.a. */ |
51 | tree call_expr, fndecl, type; | 51 | tree call_expr, fndecl, type; |
52 | type = build_function_type_list (integer_type_node, NULL_TREE); | 52 | type = build_function_type_list (integer_type_node, NULL_TREE); |
53 | - fndecl = build_fn_decl ("__cpu_indicator_init", type); | 53 | - fndecl = build_fn_decl ("__cpu_indicator_init", type); |
54 | + fndecl = build_fn_decl ("__cpu_indicator_init_local", type); | 54 | + fndecl = build_fn_decl ("__cpu_indicator_init_local", type); |
55 | call_expr = build_call_expr (fndecl, 0); | 55 | call_expr = build_call_expr (fndecl, 0); |
56 | return expand_expr (call_expr, target, mode, EXPAND_NORMAL); | 56 | return expand_expr (call_expr, target, mode, EXPAND_NORMAL); |
57 | } | 57 | } |
58 | diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c | 58 | diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c |
59 | index ef463848f9d..1a3de052c80 100644 | 59 | index dab1d98060f..cf824b4114a 100644 |
60 | --- a/libgcc/config/i386/cpuinfo.c | 60 | --- a/libgcc/config/i386/cpuinfo.c |
61 | +++ b/libgcc/config/i386/cpuinfo.c | 61 | +++ b/libgcc/config/i386/cpuinfo.c |
62 | @@ -63,7 +63,7 @@ __cpu_indicator_init (void) | 62 | @@ -63,7 +63,7 @@ __cpu_indicator_init (void) |
diff --git a/meta/recipes-devtools/gcc/gcc/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta/recipes-devtools/gcc/gcc/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch deleted file mode 100644 index 9b7c5c5642..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | From 79a568dec47baa264eb6290fed3df3244450a92e Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Wed, 4 May 2016 21:11:34 -0700 | ||
4 | Subject: [PATCH] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Christopher Larson <chris_larson@mentor.com> | ||
9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
10 | --- | ||
11 | libgcc/config/t-slibgcc | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc | ||
15 | index c59b43b7b69..ca4c141f526 100644 | ||
16 | --- a/libgcc/config/t-slibgcc | ||
17 | +++ b/libgcc/config/t-slibgcc | ||
18 | @@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \ | ||
19 | $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK) | ||
20 | |||
21 | SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \ | ||
22 | - $(SHLIB_LDFLAGS) \ | ||
23 | + $(LDFLAGS) $(SHLIB_LDFLAGS) \ | ||
24 | -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \ | ||
25 | $(SHLIB_OBJS) $(SHLIB_LC) && \ | ||
26 | rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \ | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch b/meta/recipes-devtools/gcc/gcc/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch index f33193ebcf..f5f04ae314 100644 --- a/meta/recipes-devtools/gcc/gcc/0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch +++ b/meta/recipes-devtools/gcc/gcc/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 5fd90d243ae14034a4699443110070dafc0d4d30 Mon Sep 17 00:00:00 2001 | 1 | From 4efc42b99c96b026f560b0918de7e237ac3dc8d1 Mon Sep 17 00:00:00 2001 |
2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> | 2 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
3 | Date: Tue, 10 Mar 2020 08:26:53 -0700 | 3 | Date: Tue, 10 Mar 2020 08:26:53 -0700 |
4 | Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining | 4 | Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining |
@@ -12,15 +12,15 @@ Upstream-Status: Inappropriate [OE Reproducibility specific] | |||
12 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | 12 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> |
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | 13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
14 | --- | 14 | --- |
15 | gcc/gengtype.c | 6 +++--- | 15 | gcc/gengtype.cc | 6 +++--- |
16 | gcc/genmodes.c | 32 ++++++++++++++++---------------- | 16 | gcc/genmodes.cc | 32 ++++++++++++++++---------------- |
17 | 2 files changed, 19 insertions(+), 19 deletions(-) | 17 | 2 files changed, 19 insertions(+), 19 deletions(-) |
18 | 18 | ||
19 | diff --git a/gcc/gengtype.c b/gcc/gengtype.c | 19 | diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc |
20 | index 98d4626f87e..f602da8b501 100644 | 20 | index 386ae1b0506..9762e914296 100644 |
21 | --- a/gcc/gengtype.c | 21 | --- a/gcc/gengtype.cc |
22 | +++ b/gcc/gengtype.c | 22 | +++ b/gcc/gengtype.cc |
23 | @@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt, | 23 | @@ -1006,7 +1006,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt, |
24 | /* Create a fake field with the given type and name. NEXT is the next | 24 | /* Create a fake field with the given type and name. NEXT is the next |
25 | field in the chain. */ | 25 | field in the chain. */ |
26 | #define create_field(next,type,name) \ | 26 | #define create_field(next,type,name) \ |
@@ -29,7 +29,7 @@ index 98d4626f87e..f602da8b501 100644 | |||
29 | 29 | ||
30 | /* Like create_field, but the field is only valid when condition COND | 30 | /* Like create_field, but the field is only valid when condition COND |
31 | is true. */ | 31 | is true. */ |
32 | @@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name, | 32 | @@ -1039,7 +1039,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name, |
33 | } | 33 | } |
34 | 34 | ||
35 | #define create_optional_field(next,type,name,cond) \ | 35 | #define create_optional_field(next,type,name,cond) \ |
@@ -38,7 +38,7 @@ index 98d4626f87e..f602da8b501 100644 | |||
38 | 38 | ||
39 | /* Reverse a linked list of 'struct pair's in place. */ | 39 | /* Reverse a linked list of 'struct pair's in place. */ |
40 | pair_p | 40 | pair_p |
41 | @@ -5189,7 +5189,7 @@ main (int argc, char **argv) | 41 | @@ -5238,7 +5238,7 @@ main (int argc, char **argv) |
42 | /* These types are set up with #define or else outside of where | 42 | /* These types are set up with #define or else outside of where |
43 | we can see them. We should initialize them before calling | 43 | we can see them. We should initialize them before calling |
44 | read_input_list. */ | 44 | read_input_list. */ |
@@ -47,11 +47,11 @@ index 98d4626f87e..f602da8b501 100644 | |||
47 | Call;} while (0) | 47 | Call;} while (0) |
48 | POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos)); | 48 | POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos)); |
49 | POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); | 49 | POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); |
50 | diff --git a/gcc/genmodes.c b/gcc/genmodes.c | 50 | diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc |
51 | index c268ebc4c6e..4361f3f1563 100644 | 51 | index 59850bb070a..e187f8542a1 100644 |
52 | --- a/gcc/genmodes.c | 52 | --- a/gcc/genmodes.cc |
53 | +++ b/gcc/genmodes.c | 53 | +++ b/gcc/genmodes.cc |
54 | @@ -438,7 +438,7 @@ complete_all_modes (void) | 54 | @@ -440,7 +440,7 @@ complete_all_modes (void) |
55 | } | 55 | } |
56 | 56 | ||
57 | /* For each mode in class CLASS, construct a corresponding complex mode. */ | 57 | /* For each mode in class CLASS, construct a corresponding complex mode. */ |
@@ -60,7 +60,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
60 | static void | 60 | static void |
61 | make_complex_modes (enum mode_class cl, | 61 | make_complex_modes (enum mode_class cl, |
62 | const char *file, unsigned int line) | 62 | const char *file, unsigned int line) |
63 | @@ -497,7 +497,7 @@ make_complex_modes (enum mode_class cl, | 63 | @@ -499,7 +499,7 @@ make_complex_modes (enum mode_class cl, |
64 | having as many components as necessary. ORDER is the sorting order | 64 | having as many components as necessary. ORDER is the sorting order |
65 | of the mode, with smaller numbers indicating a higher priority. */ | 65 | of the mode, with smaller numbers indicating a higher priority. */ |
66 | #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \ | 66 | #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \ |
@@ -69,16 +69,16 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
69 | #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0) | 69 | #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0) |
70 | static void ATTRIBUTE_UNUSED | 70 | static void ATTRIBUTE_UNUSED |
71 | make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, | 71 | make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, |
72 | @@ -549,7 +549,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, | 72 | @@ -552,7 +552,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, |
73 | /* Create a vector of booleans called NAME with COUNT elements and | ||
74 | BYTESIZE bytes in total. */ | 73 | BYTESIZE bytes in total. */ |
75 | #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \ | 74 | #define VECTOR_BOOL_MODE(NAME, COUNT, COMPONENT, BYTESIZE) \ |
76 | - make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__) | 75 | make_vector_bool_mode (#NAME, COUNT, #COMPONENT, BYTESIZE, \ |
77 | + make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0) | 76 | - __FILE__, __LINE__) |
77 | + __FILE__, 0) | ||
78 | static void ATTRIBUTE_UNUSED | 78 | static void ATTRIBUTE_UNUSED |
79 | make_vector_bool_mode (const char *name, unsigned int count, | 79 | make_vector_bool_mode (const char *name, unsigned int count, |
80 | unsigned int bytesize, const char *file, | 80 | const char *component, unsigned int bytesize, |
81 | @@ -571,7 +571,7 @@ make_vector_bool_mode (const char *name, unsigned int count, | 81 | @@ -574,7 +574,7 @@ make_vector_bool_mode (const char *name, unsigned int count, |
82 | /* Input. */ | 82 | /* Input. */ |
83 | 83 | ||
84 | #define _SPECIAL_MODE(C, N) \ | 84 | #define _SPECIAL_MODE(C, N) \ |
@@ -87,7 +87,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
87 | #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N) | 87 | #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N) |
88 | #define CC_MODE(N) _SPECIAL_MODE (CC, N) | 88 | #define CC_MODE(N) _SPECIAL_MODE (CC, N) |
89 | 89 | ||
90 | @@ -584,7 +584,7 @@ make_special_mode (enum mode_class cl, const char *name, | 90 | @@ -587,7 +587,7 @@ make_special_mode (enum mode_class cl, const char *name, |
91 | 91 | ||
92 | #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y) | 92 | #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y) |
93 | #define FRACTIONAL_INT_MODE(N, B, Y) \ | 93 | #define FRACTIONAL_INT_MODE(N, B, Y) \ |
@@ -96,7 +96,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
96 | 96 | ||
97 | static void | 97 | static void |
98 | make_int_mode (const char *name, | 98 | make_int_mode (const char *name, |
99 | @@ -611,16 +611,16 @@ make_opaque_mode (const char *name, | 99 | @@ -628,16 +628,16 @@ make_opaque_mode (const char *name, |
100 | } | 100 | } |
101 | 101 | ||
102 | #define FRACT_MODE(N, Y, F) \ | 102 | #define FRACT_MODE(N, Y, F) \ |
@@ -117,7 +117,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
117 | 117 | ||
118 | /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT, | 118 | /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT, |
119 | FILE, and LINE. */ | 119 | FILE, and LINE. */ |
120 | @@ -641,7 +641,7 @@ make_fixed_point_mode (enum mode_class cl, | 120 | @@ -658,7 +658,7 @@ make_fixed_point_mode (enum mode_class cl, |
121 | 121 | ||
122 | #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F) | 122 | #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F) |
123 | #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \ | 123 | #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \ |
@@ -126,7 +126,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
126 | 126 | ||
127 | static void | 127 | static void |
128 | make_float_mode (const char *name, | 128 | make_float_mode (const char *name, |
129 | @@ -658,7 +658,7 @@ make_float_mode (const char *name, | 129 | @@ -675,7 +675,7 @@ make_float_mode (const char *name, |
130 | #define DECIMAL_FLOAT_MODE(N, Y, F) \ | 130 | #define DECIMAL_FLOAT_MODE(N, Y, F) \ |
131 | FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F) | 131 | FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F) |
132 | #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \ | 132 | #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \ |
@@ -135,7 +135,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
135 | 135 | ||
136 | static void | 136 | static void |
137 | make_decimal_float_mode (const char *name, | 137 | make_decimal_float_mode (const char *name, |
138 | @@ -673,7 +673,7 @@ make_decimal_float_mode (const char *name, | 138 | @@ -690,7 +690,7 @@ make_decimal_float_mode (const char *name, |
139 | } | 139 | } |
140 | 140 | ||
141 | #define RESET_FLOAT_FORMAT(N, F) \ | 141 | #define RESET_FLOAT_FORMAT(N, F) \ |
@@ -144,7 +144,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
144 | static void ATTRIBUTE_UNUSED | 144 | static void ATTRIBUTE_UNUSED |
145 | reset_float_format (const char *name, const char *format, | 145 | reset_float_format (const char *name, const char *format, |
146 | const char *file, unsigned int line) | 146 | const char *file, unsigned int line) |
147 | @@ -694,7 +694,7 @@ reset_float_format (const char *name, const char *format, | 147 | @@ -711,7 +711,7 @@ reset_float_format (const char *name, const char *format, |
148 | 148 | ||
149 | /* __intN support. */ | 149 | /* __intN support. */ |
150 | #define INT_N(M,PREC) \ | 150 | #define INT_N(M,PREC) \ |
@@ -153,7 +153,7 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
153 | static void ATTRIBUTE_UNUSED | 153 | static void ATTRIBUTE_UNUSED |
154 | make_int_n (const char *m, int bitsize, | 154 | make_int_n (const char *m, int bitsize, |
155 | const char *file, unsigned int line) | 155 | const char *file, unsigned int line) |
156 | @@ -723,7 +723,7 @@ make_int_n (const char *m, int bitsize, | 156 | @@ -740,7 +740,7 @@ make_int_n (const char *m, int bitsize, |
157 | /* Partial integer modes are specified by relation to a full integer | 157 | /* Partial integer modes are specified by relation to a full integer |
158 | mode. */ | 158 | mode. */ |
159 | #define PARTIAL_INT_MODE(M,PREC,NAME) \ | 159 | #define PARTIAL_INT_MODE(M,PREC,NAME) \ |
@@ -162,16 +162,16 @@ index c268ebc4c6e..4361f3f1563 100644 | |||
162 | static void ATTRIBUTE_UNUSED | 162 | static void ATTRIBUTE_UNUSED |
163 | make_partial_integer_mode (const char *base, const char *name, | 163 | make_partial_integer_mode (const char *base, const char *name, |
164 | unsigned int precision, | 164 | unsigned int precision, |
165 | @@ -750,7 +750,7 @@ make_partial_integer_mode (const char *base, const char *name, | 165 | @@ -767,7 +767,7 @@ make_partial_integer_mode (const char *base, const char *name, |
166 | /* A single vector mode can be specified by naming its component | 166 | /* A single vector mode can be specified by naming its component |
167 | mode and the number of components. */ | 167 | mode and the number of components. */ |
168 | #define VECTOR_MODE(C, M, N) \ | 168 | #define VECTOR_MODE_WITH_PREFIX(PREFIX, C, M, N, ORDER) \ |
169 | - make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__); | 169 | - make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, __LINE__); |
170 | + make_vector_mode (MODE_##C, #M, N, __FILE__, 0); | 170 | + make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, 0); |
171 | #define VECTOR_MODE(C, M, N) VECTOR_MODE_WITH_PREFIX(V, C, M, N, 0); | ||
171 | static void ATTRIBUTE_UNUSED | 172 | static void ATTRIBUTE_UNUSED |
172 | make_vector_mode (enum mode_class bclass, | 173 | make_vector_mode (enum mode_class bclass, |
173 | const char *base, | 174 | @@ -814,7 +814,7 @@ make_vector_mode (enum mode_class bclass, |
174 | @@ -793,7 +793,7 @@ make_vector_mode (enum mode_class bclass, | ||
175 | 175 | ||
176 | /* Adjustability. */ | 176 | /* Adjustability. */ |
177 | #define _ADD_ADJUST(A, M, X, C1, C2) \ | 177 | #define _ADD_ADJUST(A, M, X, C1, C2) \ |
diff --git a/meta/recipes-devtools/gcc/gcc/0026-mingw32-Enable-operation_not_supported.patch b/meta/recipes-devtools/gcc/gcc/0022-mingw32-Enable-operation_not_supported.patch index b46bde1eda..f88ad51ee8 100644 --- a/meta/recipes-devtools/gcc/gcc/0026-mingw32-Enable-operation_not_supported.patch +++ b/meta/recipes-devtools/gcc/gcc/0022-mingw32-Enable-operation_not_supported.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 7bc34769f0b055e25286576e4ba6d211e8159834 Mon Sep 17 00:00:00 2001 | 1 | From 061cf79e7b6e89fdf0f2630ddaebbf1d7b271ac3 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Tue, 12 May 2020 10:39:09 -0700 | 3 | Date: Tue, 12 May 2020 10:39:09 -0700 |
4 | Subject: [PATCH] mingw32: Enable operation_not_supported | 4 | Subject: [PATCH] mingw32: Enable operation_not_supported |
@@ -12,7 +12,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 13 | ||
14 | diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h | 14 | diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h |
15 | index eca06a97014..933cfab49cf 100644 | 15 | index da5f4c2ac85..e855c86267c 100644 |
16 | --- a/libstdc++-v3/config/os/mingw32/error_constants.h | 16 | --- a/libstdc++-v3/config/os/mingw32/error_constants.h |
17 | +++ b/libstdc++-v3/config/os/mingw32/error_constants.h | 17 | +++ b/libstdc++-v3/config/os/mingw32/error_constants.h |
18 | @@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION | 18 | @@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION |
diff --git a/meta/recipes-devtools/gcc/gcc/0022-sync-gcc-stddef.h-with-musl.patch b/meta/recipes-devtools/gcc/gcc/0022-sync-gcc-stddef.h-with-musl.patch deleted file mode 100644 index 86fb22ffd3..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0022-sync-gcc-stddef.h-with-musl.patch +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | From 07a06aa8e8285c1bb06d0bebeaa9ad04eb76f2e2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Fri, 3 Feb 2017 12:56:00 -0800 | ||
4 | Subject: [PATCH] sync gcc stddef.h with musl | ||
5 | |||
6 | musl defines ptrdiff_t size_t and wchar_t | ||
7 | so dont define them here if musl is definining them | ||
8 | |||
9 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=85a438fc78dd12249ca854a3e5c577fefeb1a5cd] | ||
10 | |||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
12 | --- | ||
13 | gcc/ginclude/stddef.h | 9 +++++++++ | ||
14 | 1 file changed, 9 insertions(+) | ||
15 | |||
16 | diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h | ||
17 | index 66619fe43b1..3f843d6f365 100644 | ||
18 | --- a/gcc/ginclude/stddef.h | ||
19 | +++ b/gcc/ginclude/stddef.h | ||
20 | @@ -128,6 +128,7 @@ _TYPE_wchar_t; | ||
21 | #ifndef ___int_ptrdiff_t_h | ||
22 | #ifndef _GCC_PTRDIFF_T | ||
23 | #ifndef _PTRDIFF_T_DECLARED /* DragonFly */ | ||
24 | +#ifndef __DEFINED_ptrdiff_t /* musl */ | ||
25 | #define _PTRDIFF_T | ||
26 | #define _T_PTRDIFF_ | ||
27 | #define _T_PTRDIFF | ||
28 | @@ -137,10 +138,12 @@ _TYPE_wchar_t; | ||
29 | #define ___int_ptrdiff_t_h | ||
30 | #define _GCC_PTRDIFF_T | ||
31 | #define _PTRDIFF_T_DECLARED | ||
32 | +#define __DEFINED_ptrdiff_t /* musl */ | ||
33 | #ifndef __PTRDIFF_TYPE__ | ||
34 | #define __PTRDIFF_TYPE__ long int | ||
35 | #endif | ||
36 | typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
37 | +#endif /* __DEFINED_ptrdiff_t */ | ||
38 | #endif /* _PTRDIFF_T_DECLARED */ | ||
39 | #endif /* _GCC_PTRDIFF_T */ | ||
40 | #endif /* ___int_ptrdiff_t_h */ | ||
41 | @@ -178,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
42 | #ifndef _GCC_SIZE_T | ||
43 | #ifndef _SIZET_ | ||
44 | #ifndef __size_t | ||
45 | +#ifndef __DEFINED_size_t /* musl */ | ||
46 | #define __size_t__ /* BeOS */ | ||
47 | #define __SIZE_T__ /* Cray Unicos/Mk */ | ||
48 | #define _SIZE_T | ||
49 | @@ -194,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
50 | #define ___int_size_t_h | ||
51 | #define _GCC_SIZE_T | ||
52 | #define _SIZET_ | ||
53 | +#define __DEFINED_size_t /* musl */ | ||
54 | #if defined (__FreeBSD__) \ | ||
55 | || defined(__DragonFly__) \ | ||
56 | || defined(__FreeBSD_kernel__) \ | ||
57 | @@ -228,6 +233,7 @@ typedef long ssize_t; | ||
58 | #endif /* _SIZE_T */ | ||
59 | #endif /* __SIZE_T__ */ | ||
60 | #endif /* __size_t__ */ | ||
61 | +#endif /* __DEFINED_size_t */ | ||
62 | #undef __need_size_t | ||
63 | #endif /* _STDDEF_H or __need_size_t. */ | ||
64 | |||
65 | @@ -257,6 +263,7 @@ typedef long ssize_t; | ||
66 | #ifndef ___int_wchar_t_h | ||
67 | #ifndef __INT_WCHAR_T_H | ||
68 | #ifndef _GCC_WCHAR_T | ||
69 | +#ifndef __DEFINED_wchar_t /* musl */ | ||
70 | #define __wchar_t__ /* BeOS */ | ||
71 | #define __WCHAR_T__ /* Cray Unicos/Mk */ | ||
72 | #define _WCHAR_T | ||
73 | @@ -272,6 +279,7 @@ typedef long ssize_t; | ||
74 | #define __INT_WCHAR_T_H | ||
75 | #define _GCC_WCHAR_T | ||
76 | #define _WCHAR_T_DECLARED | ||
77 | +#define __DEFINED_wchar_t /* musl */ | ||
78 | |||
79 | /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ | ||
80 | instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other | ||
81 | @@ -337,6 +345,7 @@ typedef __WCHAR_TYPE__ wchar_t; | ||
82 | #endif | ||
83 | #endif /* __WCHAR_T__ */ | ||
84 | #endif /* __wchar_t__ */ | ||
85 | +#endif /* __DEFINED_wchar_t musl */ | ||
86 | #undef __need_wchar_t | ||
87 | #endif /* _STDDEF_H or __need_wchar_t. */ | ||
88 | |||
diff --git a/meta/recipes-devtools/gcc/gcc/0027-libatomic-Do-not-enforce-march-on-aarch64.patch b/meta/recipes-devtools/gcc/gcc/0023-libatomic-Do-not-enforce-march-on-aarch64.patch index 85b1251482..2f01659847 100644 --- a/meta/recipes-devtools/gcc/gcc/0027-libatomic-Do-not-enforce-march-on-aarch64.patch +++ b/meta/recipes-devtools/gcc/gcc/0023-libatomic-Do-not-enforce-march-on-aarch64.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From df1c63bbd7a520e8c6d0d0692b4d8bff56952394 Mon Sep 17 00:00:00 2001 | 1 | From 52931ec7a708b58d68e69ce9eb99001ae9f099dd Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Wed, 13 May 2020 15:10:38 -0700 | 3 | Date: Wed, 13 May 2020 15:10:38 -0700 |
4 | Subject: [PATCH] libatomic: Do not enforce march on aarch64 | 4 | Subject: [PATCH] libatomic: Do not enforce march on aarch64 |
@@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
17 | 2 files changed, 2 deletions(-) | 17 | 2 files changed, 2 deletions(-) |
18 | 18 | ||
19 | diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am | 19 | diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am |
20 | index ab8c2da24a1..f614a46b34d 100644 | 20 | index d88515e4a03..e0e2f8b442a 100644 |
21 | --- a/libatomic/Makefile.am | 21 | --- a/libatomic/Makefile.am |
22 | +++ b/libatomic/Makefile.am | 22 | +++ b/libatomic/Makefile.am |
23 | @@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS))) | 23 | @@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS))) |
diff --git a/meta/recipes-devtools/gcc/gcc/0029-Fix-install-path-of-linux64.h.patch b/meta/recipes-devtools/gcc/gcc/0024-Fix-install-path-of-linux64.h.patch index d7e156e7a3..555be62328 100644 --- a/meta/recipes-devtools/gcc/gcc/0029-Fix-install-path-of-linux64.h.patch +++ b/meta/recipes-devtools/gcc/gcc/0024-Fix-install-path-of-linux64.h.patch | |||
@@ -1,4 +1,4 @@ | |||
1 | From 8a62cc0a64670e39f462c1dbbf82e04d2f03b89e Mon Sep 17 00:00:00 2001 | 1 | From 3e67c9c77e46132c252911bf1e5e4222dfd3aa34 Mon Sep 17 00:00:00 2001 |
2 | From: Andrei Gherzan <andrei.gherzan@huawei.com> | 2 | From: Andrei Gherzan <andrei.gherzan@huawei.com> |
3 | Date: Wed, 22 Dec 2021 12:49:25 +0100 | 3 | Date: Wed, 22 Dec 2021 12:49:25 +0100 |
4 | Subject: [PATCH] Fix install path of linux64.h | 4 | Subject: [PATCH] Fix install path of linux64.h |
@@ -17,10 +17,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com> | |||
17 | 1 file changed, 2 insertions(+) | 17 | 1 file changed, 2 insertions(+) |
18 | 18 | ||
19 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in | 19 | diff --git a/gcc/Makefile.in b/gcc/Makefile.in |
20 | index 06eb0d27a28..a8678ca24ed 100644 | 20 | index 07fa63b6640..0def7394454 100644 |
21 | --- a/gcc/Makefile.in | 21 | --- a/gcc/Makefile.in |
22 | +++ b/gcc/Makefile.in | 22 | +++ b/gcc/Makefile.in |
23 | @@ -3686,6 +3686,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype | 23 | @@ -3706,6 +3706,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype |
24 | "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \ | 24 | "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \ |
25 | | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \ | 25 | | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \ |
26 | base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \ | 26 | base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \ |
diff --git a/meta/recipes-devtools/gcc/gcc/0025-Move-sched.h-include-ahead-of-user-headers.patch b/meta/recipes-devtools/gcc/gcc/0025-Move-sched.h-include-ahead-of-user-headers.patch new file mode 100644 index 0000000000..d4aeacfed5 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/0025-Move-sched.h-include-ahead-of-user-headers.patch | |||
@@ -0,0 +1,56 @@ | |||
1 | From 7422adfb471f4b4f2ec870124064632d55f72e50 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Mon, 11 Apr 2022 15:46:18 -0700 | ||
4 | Subject: [PATCH] Move sched.h include ahead of user headers | ||
5 | |||
6 | Fix attempt to use poisoned calloc error, this moves the sched.h before | ||
7 | using system.h from gcc headers which includes #pragma GCC poison calloc | ||
8 | |||
9 | Fixes | ||
10 | In file included from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/pthread.h:30, | ||
11 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/aarch64-yoe-linux-musl/bits/gthr-default.h:35, | ||
12 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/aarch64-yoe-linux-musl/bits/gthr.h:148, | ||
13 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/ext/atomicity.h:35, | ||
14 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/bits/shared_ptr_base.h:61, | ||
15 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/bits/shared_ptr.h:53, | ||
16 | from /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/c++/12.0.1/memory:77, | ||
17 | from ../../../../../../../work-shared/gcc-12.0.1-r0/gcc-12-20220410/libcc1/deleter.hh:23, | ||
18 | from ../../../../../../../work-shared/gcc-12.0.1-r0/gcc-12-20220410/libcc1/rpc.hh:25, | ||
19 | from ../../../../../../../work-shared/gcc-12.0.1-r0/gcc-12-20220410/libcc1/libcc1plugin.cc:67: | ||
20 | /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" | ||
21 | 84 | void *calloc(size_t, size_t); | ||
22 | | ^ | ||
23 | /mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/gcc/12.0.1-r0/recipe-sysroot/usr/include/sched.h:124:36: error: attempt to use poisoned "calloc" | ||
24 | 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) | ||
25 | |||
26 | Upstream-Status: Pending | ||
27 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
28 | --- | ||
29 | libcc1/libcc1plugin.cc | 1 + | ||
30 | libcc1/libcp1plugin.cc | 1 + | ||
31 | 2 files changed, 2 insertions(+) | ||
32 | |||
33 | diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc | ||
34 | index 12ab5a57c8d..fff9bfab18b 100644 | ||
35 | --- a/libcc1/libcc1plugin.cc | ||
36 | +++ b/libcc1/libcc1plugin.cc | ||
37 | @@ -17,6 +17,7 @@ | ||
38 | along with GCC; see the file COPYING3. If not see | ||
39 | <http://www.gnu.org/licenses/>. */ | ||
40 | |||
41 | +#include <sched.h> | ||
42 | #include <cc1plugin-config.h> | ||
43 | |||
44 | #undef PACKAGE_NAME | ||
45 | diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc | ||
46 | index 83dab7f58b1..0b83ce7a09d 100644 | ||
47 | --- a/libcc1/libcp1plugin.cc | ||
48 | +++ b/libcc1/libcp1plugin.cc | ||
49 | @@ -18,6 +18,7 @@ | ||
50 | along with GCC; see the file COPYING3. If not see | ||
51 | <http://www.gnu.org/licenses/>. */ | ||
52 | |||
53 | +#include <sched.h> | ||
54 | #include <cc1plugin-config.h> | ||
55 | |||
56 | #undef PACKAGE_NAME | ||
diff --git a/meta/recipes-devtools/gcc/gcc/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch b/meta/recipes-devtools/gcc/gcc/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch deleted file mode 100644 index de06793482..0000000000 --- a/meta/recipes-devtools/gcc/gcc/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | From 49008eeedc97014f44e12afe179d3785e4438372 Mon Sep 17 00:00:00 2001 | ||
2 | From: Richard Biener <rguenther@suse.de> | ||
3 | Date: Tue, 20 Jul 2021 11:00:33 +0200 | ||
4 | Subject: [PATCH] debug/101473 - apply debug prefix maps before checksumming | ||
5 | DIEs | ||
6 | |||
7 | The following makes sure to apply the debug prefix maps to filenames | ||
8 | before checksumming DIEs to create the global symbol for the CU DIE | ||
9 | used by LTO to link the late debug to the early debug. This avoids | ||
10 | binary differences (in said symbol) when compiling with toolchains | ||
11 | installed under a different path and that compensated with appropriate | ||
12 | -fdebug-prefix-map options. | ||
13 | |||
14 | The easiest and most scalable way is to record both the unmapped | ||
15 | and the remapped filename in the dwarf_file_data so the remapping | ||
16 | process takes place at a single point and only once (otherwise it | ||
17 | creates GC garbage at each point doing that). | ||
18 | |||
19 | 2021-07-20 Richard Biener <rguenther@suse.de> | ||
20 | |||
21 | PR debug/101473 | ||
22 | * dwarf2out.h (dwarf_file_data): Add key member. | ||
23 | * dwarf2out.c (dwarf_file_hasher::equal): Compare key. | ||
24 | (dwarf_file_hasher::hash): Hash key. | ||
25 | (lookup_filename): Remap the filename and store it in the | ||
26 | filename member of dwarf_file_data when creating a new | ||
27 | dwarf_file_data. | ||
28 | (file_name_acquire): Do not remap the filename again. | ||
29 | (maybe_emit_file): Likewise. | ||
30 | |||
31 | [YOCTO #14481] | ||
32 | |||
33 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7cc2df084b7977653a9b59cbc34a9ad500ae619c] | ||
34 | |||
35 | The upstream patch was modified to compensate for the definition of | ||
36 | "struct dwarf_file_data" being in dwarf2out.c rather than dwarf2out.h in | ||
37 | this version of gcc. | ||
38 | |||
39 | Signed-off-by: Tony Battersby <tonyb@cybernetics.com> | ||
40 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
41 | --- | ||
42 | gcc/dwarf2out.c | 13 +++++++------ | ||
43 | 1 file changed, 7 insertions(+), 6 deletions(-) | ||
44 | |||
45 | diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c | ||
46 | index e5d3ce4966d..41ac3008507 100644 | ||
47 | --- a/gcc/dwarf2out.c | ||
48 | +++ b/gcc/dwarf2out.c | ||
49 | @@ -1283,6 +1283,7 @@ dwarf2out_switch_text_section (void) | ||
50 | |||
51 | /* Data about a single source file. */ | ||
52 | struct GTY((for_user)) dwarf_file_data { | ||
53 | + const char * key; | ||
54 | const char * filename; | ||
55 | int emitted_number; | ||
56 | }; | ||
57 | @@ -12335,7 +12336,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad) | ||
58 | |||
59 | fi = fnad->files + fnad->used_files++; | ||
60 | |||
61 | - f = remap_debug_filename (d->filename); | ||
62 | + f = d->filename; | ||
63 | |||
64 | /* Skip all leading "./". */ | ||
65 | while (f[0] == '.' && IS_DIR_SEPARATOR (f[1])) | ||
66 | @@ -27259,13 +27260,13 @@ dwarf2out_ignore_block (const_tree block) | ||
67 | bool | ||
68 | dwarf_file_hasher::equal (dwarf_file_data *p1, const char *p2) | ||
69 | { | ||
70 | - return filename_cmp (p1->filename, p2) == 0; | ||
71 | + return filename_cmp (p1->key, p2) == 0; | ||
72 | } | ||
73 | |||
74 | hashval_t | ||
75 | dwarf_file_hasher::hash (dwarf_file_data *p) | ||
76 | { | ||
77 | - return htab_hash_string (p->filename); | ||
78 | + return htab_hash_string (p->key); | ||
79 | } | ||
80 | |||
81 | /* Lookup FILE_NAME (in the list of filenames that we know about here in | ||
82 | @@ -27295,7 +27296,8 @@ lookup_filename (const char *file_name) | ||
83 | return *slot; | ||
84 | |||
85 | created = ggc_alloc<dwarf_file_data> (); | ||
86 | - created->filename = file_name; | ||
87 | + created->key = file_name; | ||
88 | + created->filename = remap_debug_filename (file_name); | ||
89 | created->emitted_number = 0; | ||
90 | *slot = created; | ||
91 | return created; | ||
92 | @@ -27321,8 +27323,7 @@ maybe_emit_file (struct dwarf_file_data * fd) | ||
93 | if (output_asm_line_debug_info ()) | ||
94 | { | ||
95 | fprintf (asm_out_file, "\t.file %u ", fd->emitted_number); | ||
96 | - output_quoted_string (asm_out_file, | ||
97 | - remap_debug_filename (fd->filename)); | ||
98 | + output_quoted_string (asm_out_file, fd->filename); | ||
99 | fputc ('\n', asm_out_file); | ||
100 | } | ||
101 | } | ||
diff --git a/meta/recipes-devtools/gcc/gcc_11.3.bb b/meta/recipes-devtools/gcc/gcc_12.1.bb index 255fe552bd..255fe552bd 100644 --- a/meta/recipes-devtools/gcc/gcc_11.3.bb +++ b/meta/recipes-devtools/gcc/gcc_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/libgcc-initial_11.3.bb b/meta/recipes-devtools/gcc/libgcc-initial_12.1.bb index a259082b47..a259082b47 100644 --- a/meta/recipes-devtools/gcc/libgcc-initial_11.3.bb +++ b/meta/recipes-devtools/gcc/libgcc-initial_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/libgcc_11.3.bb b/meta/recipes-devtools/gcc/libgcc_12.1.bb index f88963b0a4..f88963b0a4 100644 --- a/meta/recipes-devtools/gcc/libgcc_11.3.bb +++ b/meta/recipes-devtools/gcc/libgcc_12.1.bb | |||
diff --git a/meta/recipes-devtools/gcc/libgfortran_11.3.bb b/meta/recipes-devtools/gcc/libgfortran_12.1.bb index 71dd8b4bdc..71dd8b4bdc 100644 --- a/meta/recipes-devtools/gcc/libgfortran_11.3.bb +++ b/meta/recipes-devtools/gcc/libgfortran_12.1.bb | |||