From 6468f6151b982b722043d55b1a50e5cd56fbf75f Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Wed, 8 Sep 2021 18:52:28 +0900 Subject: [PATCH 1/4] patches: Make keep the order of some patches applied --- ...rget-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} | 0 ...h => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} | 0 ... gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} | 0 ...gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} | 0 ...rget-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} | 0 ...h => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} | 0 ... gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} | 0 ...gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} | 0 ...rget-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} | 0 ...h => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} | 0 ... gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} | 0 ...gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} | 0 ...rget-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} | 0 ...h => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} | 0 ... gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} | 0 ...gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename patches/gcc10.1/{gcc-xtensa-fix-PR-target-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} (100%) rename patches/gcc10.1/{gcc-xtensa-rearrange-DI-mode-constant-loading.patch => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} (100%) rename patches/gcc10.1/{gcc-xtensa-add-optimizations-for-shift-operations.patch => gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} (100%) rename patches/gcc10.1/{gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch => gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} (100%) rename patches/gcc10.2/{gcc-xtensa-fix-PR-target-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} (100%) rename patches/gcc10.2/{gcc-xtensa-rearrange-DI-mode-constant-loading.patch => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} (100%) rename patches/gcc10.2/{gcc-xtensa-add-optimizations-for-shift-operations.patch => gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} (100%) rename patches/gcc10.2/{gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch => gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} (100%) rename patches/gcc10.3/{gcc-xtensa-fix-PR-target-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} (100%) rename patches/gcc10.3/{gcc-xtensa-rearrange-DI-mode-constant-loading.patch => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} (100%) rename patches/gcc10.3/{gcc-xtensa-add-optimizations-for-shift-operations.patch => gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} (100%) rename patches/gcc10.3/{gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch => gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} (100%) rename patches/gcc11.1/{gcc-xtensa-fix-PR-target-98285.patch => gcc-xtensa-0001-fix-PR-target-98285.patch} (100%) rename patches/gcc11.1/{gcc-xtensa-rearrange-DI-mode-constant-loading.patch => gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch} (100%) rename patches/gcc11.1/{gcc-xtensa-add-optimizations-for-shift-operations.patch => gcc-xtensa-0003-add-optimizations-for-shift-operations.patch} (100%) rename patches/gcc11.1/{gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch => gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch} (100%) diff --git a/patches/gcc10.1/gcc-xtensa-fix-PR-target-98285.patch b/patches/gcc10.1/gcc-xtensa-0001-fix-PR-target-98285.patch similarity index 100% rename from patches/gcc10.1/gcc-xtensa-fix-PR-target-98285.patch rename to patches/gcc10.1/gcc-xtensa-0001-fix-PR-target-98285.patch diff --git a/patches/gcc10.1/gcc-xtensa-rearrange-DI-mode-constant-loading.patch b/patches/gcc10.1/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch similarity index 100% rename from patches/gcc10.1/gcc-xtensa-rearrange-DI-mode-constant-loading.patch rename to patches/gcc10.1/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch diff --git a/patches/gcc10.1/gcc-xtensa-add-optimizations-for-shift-operations.patch b/patches/gcc10.1/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch similarity index 100% rename from patches/gcc10.1/gcc-xtensa-add-optimizations-for-shift-operations.patch rename to patches/gcc10.1/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch diff --git a/patches/gcc10.1/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch b/patches/gcc10.1/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch similarity index 100% rename from patches/gcc10.1/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch rename to patches/gcc10.1/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch diff --git a/patches/gcc10.2/gcc-xtensa-fix-PR-target-98285.patch b/patches/gcc10.2/gcc-xtensa-0001-fix-PR-target-98285.patch similarity index 100% rename from patches/gcc10.2/gcc-xtensa-fix-PR-target-98285.patch rename to patches/gcc10.2/gcc-xtensa-0001-fix-PR-target-98285.patch diff --git a/patches/gcc10.2/gcc-xtensa-rearrange-DI-mode-constant-loading.patch b/patches/gcc10.2/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch similarity index 100% rename from patches/gcc10.2/gcc-xtensa-rearrange-DI-mode-constant-loading.patch rename to patches/gcc10.2/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch diff --git a/patches/gcc10.2/gcc-xtensa-add-optimizations-for-shift-operations.patch b/patches/gcc10.2/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch similarity index 100% rename from patches/gcc10.2/gcc-xtensa-add-optimizations-for-shift-operations.patch rename to patches/gcc10.2/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch diff --git a/patches/gcc10.2/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch b/patches/gcc10.2/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch similarity index 100% rename from patches/gcc10.2/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch rename to patches/gcc10.2/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch diff --git a/patches/gcc10.3/gcc-xtensa-fix-PR-target-98285.patch b/patches/gcc10.3/gcc-xtensa-0001-fix-PR-target-98285.patch similarity index 100% rename from patches/gcc10.3/gcc-xtensa-fix-PR-target-98285.patch rename to patches/gcc10.3/gcc-xtensa-0001-fix-PR-target-98285.patch diff --git a/patches/gcc10.3/gcc-xtensa-rearrange-DI-mode-constant-loading.patch b/patches/gcc10.3/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch similarity index 100% rename from patches/gcc10.3/gcc-xtensa-rearrange-DI-mode-constant-loading.patch rename to patches/gcc10.3/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch diff --git a/patches/gcc10.3/gcc-xtensa-add-optimizations-for-shift-operations.patch b/patches/gcc10.3/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch similarity index 100% rename from patches/gcc10.3/gcc-xtensa-add-optimizations-for-shift-operations.patch rename to patches/gcc10.3/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch diff --git a/patches/gcc10.3/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch b/patches/gcc10.3/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch similarity index 100% rename from patches/gcc10.3/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch rename to patches/gcc10.3/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch diff --git a/patches/gcc11.1/gcc-xtensa-fix-PR-target-98285.patch b/patches/gcc11.1/gcc-xtensa-0001-fix-PR-target-98285.patch similarity index 100% rename from patches/gcc11.1/gcc-xtensa-fix-PR-target-98285.patch rename to patches/gcc11.1/gcc-xtensa-0001-fix-PR-target-98285.patch diff --git a/patches/gcc11.1/gcc-xtensa-rearrange-DI-mode-constant-loading.patch b/patches/gcc11.1/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch similarity index 100% rename from patches/gcc11.1/gcc-xtensa-rearrange-DI-mode-constant-loading.patch rename to patches/gcc11.1/gcc-xtensa-0002-rearrange-DI-mode-constant-loading.patch diff --git a/patches/gcc11.1/gcc-xtensa-add-optimizations-for-shift-operations.patch b/patches/gcc11.1/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch similarity index 100% rename from patches/gcc11.1/gcc-xtensa-add-optimizations-for-shift-operations.patch rename to patches/gcc11.1/gcc-xtensa-0003-add-optimizations-for-shift-operations.patch diff --git a/patches/gcc11.1/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch b/patches/gcc11.1/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch similarity index 100% rename from patches/gcc11.1/gcc-xtensa-implement-bswapsi2-bswapdi2-and-helpers.patch rename to patches/gcc11.1/gcc-xtensa-0004-implement-bswapsi2-bswapdi2-and-helpers.patch From ed86506061e9e09b0aec375470858d58d0890fad Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Wed, 8 Sep 2021 19:07:40 +0900 Subject: [PATCH 2/4] GCC: xtensa: backport patch from upstream this PR relieves the problem (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102115): b552c4e601c7fdc4d341e29cc1ed6081d42b00d0 "gcc: xtensa: fix PR target/102115" --- ...gcc-xtensa-0005-fix-PR-target-102115.patch | 29 +++++++++++++++++++ ...gcc-xtensa-0005-fix-PR-target-102115.patch | 29 +++++++++++++++++++ ...gcc-xtensa-0005-fix-PR-target-102115.patch | 29 +++++++++++++++++++ ...gcc-xtensa-0005-fix-PR-target-102115.patch | 29 +++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 patches/gcc10.1/gcc-xtensa-0005-fix-PR-target-102115.patch create mode 100644 patches/gcc10.2/gcc-xtensa-0005-fix-PR-target-102115.patch create mode 100644 patches/gcc10.3/gcc-xtensa-0005-fix-PR-target-102115.patch create mode 100644 patches/gcc11.1/gcc-xtensa-0005-fix-PR-target-102115.patch diff --git a/patches/gcc10.1/gcc-xtensa-0005-fix-PR-target-102115.patch b/patches/gcc10.1/gcc-xtensa-0005-fix-PR-target-102115.patch new file mode 100644 index 0000000..3cda431 --- /dev/null +++ b/patches/gcc10.1/gcc-xtensa-0005-fix-PR-target-102115.patch @@ -0,0 +1,29 @@ +From b552c4e601c7fdc4d341e29cc1ed6081d42b00d0 Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Tue, 7 Sep 2021 15:40:00 -0700 +Subject: [PATCH] gcc: xtensa: fix PR target/102115 + +2021-09-07 Takayuki 'January June' Suwa +gcc/ + PR target/102115 + * config/xtensa/xtensa.c (xtensa_emit_move_sequence): Add + 'CONST_INT_P (src)' to the condition of the block that tries to + eliminate literal when loading integer contant. +--- + gcc/config/xtensa/xtensa.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c +index f4f8f1975c55a..8d6755144c120 100644 +--- a/gcc/config/xtensa/xtensa.c ++++ b/gcc/config/xtensa/xtensa.c +@@ -1084,7 +1084,8 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) + { + /* Try to emit MOVI + SLLI sequence, that is smaller + than L32R + literal. */ +- if (optimize_size && mode == SImode && register_operand (dst, mode)) ++ if (optimize_size && mode == SImode && CONST_INT_P (src) ++ && register_operand (dst, mode)) + { + HOST_WIDE_INT srcval = INTVAL (src); + int shift = ctz_hwi (srcval); diff --git a/patches/gcc10.2/gcc-xtensa-0005-fix-PR-target-102115.patch b/patches/gcc10.2/gcc-xtensa-0005-fix-PR-target-102115.patch new file mode 100644 index 0000000..3cda431 --- /dev/null +++ b/patches/gcc10.2/gcc-xtensa-0005-fix-PR-target-102115.patch @@ -0,0 +1,29 @@ +From b552c4e601c7fdc4d341e29cc1ed6081d42b00d0 Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Tue, 7 Sep 2021 15:40:00 -0700 +Subject: [PATCH] gcc: xtensa: fix PR target/102115 + +2021-09-07 Takayuki 'January June' Suwa +gcc/ + PR target/102115 + * config/xtensa/xtensa.c (xtensa_emit_move_sequence): Add + 'CONST_INT_P (src)' to the condition of the block that tries to + eliminate literal when loading integer contant. +--- + gcc/config/xtensa/xtensa.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c +index f4f8f1975c55a..8d6755144c120 100644 +--- a/gcc/config/xtensa/xtensa.c ++++ b/gcc/config/xtensa/xtensa.c +@@ -1084,7 +1084,8 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) + { + /* Try to emit MOVI + SLLI sequence, that is smaller + than L32R + literal. */ +- if (optimize_size && mode == SImode && register_operand (dst, mode)) ++ if (optimize_size && mode == SImode && CONST_INT_P (src) ++ && register_operand (dst, mode)) + { + HOST_WIDE_INT srcval = INTVAL (src); + int shift = ctz_hwi (srcval); diff --git a/patches/gcc10.3/gcc-xtensa-0005-fix-PR-target-102115.patch b/patches/gcc10.3/gcc-xtensa-0005-fix-PR-target-102115.patch new file mode 100644 index 0000000..3cda431 --- /dev/null +++ b/patches/gcc10.3/gcc-xtensa-0005-fix-PR-target-102115.patch @@ -0,0 +1,29 @@ +From b552c4e601c7fdc4d341e29cc1ed6081d42b00d0 Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Tue, 7 Sep 2021 15:40:00 -0700 +Subject: [PATCH] gcc: xtensa: fix PR target/102115 + +2021-09-07 Takayuki 'January June' Suwa +gcc/ + PR target/102115 + * config/xtensa/xtensa.c (xtensa_emit_move_sequence): Add + 'CONST_INT_P (src)' to the condition of the block that tries to + eliminate literal when loading integer contant. +--- + gcc/config/xtensa/xtensa.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c +index f4f8f1975c55a..8d6755144c120 100644 +--- a/gcc/config/xtensa/xtensa.c ++++ b/gcc/config/xtensa/xtensa.c +@@ -1084,7 +1084,8 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) + { + /* Try to emit MOVI + SLLI sequence, that is smaller + than L32R + literal. */ +- if (optimize_size && mode == SImode && register_operand (dst, mode)) ++ if (optimize_size && mode == SImode && CONST_INT_P (src) ++ && register_operand (dst, mode)) + { + HOST_WIDE_INT srcval = INTVAL (src); + int shift = ctz_hwi (srcval); diff --git a/patches/gcc11.1/gcc-xtensa-0005-fix-PR-target-102115.patch b/patches/gcc11.1/gcc-xtensa-0005-fix-PR-target-102115.patch new file mode 100644 index 0000000..3cda431 --- /dev/null +++ b/patches/gcc11.1/gcc-xtensa-0005-fix-PR-target-102115.patch @@ -0,0 +1,29 @@ +From b552c4e601c7fdc4d341e29cc1ed6081d42b00d0 Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Tue, 7 Sep 2021 15:40:00 -0700 +Subject: [PATCH] gcc: xtensa: fix PR target/102115 + +2021-09-07 Takayuki 'January June' Suwa +gcc/ + PR target/102115 + * config/xtensa/xtensa.c (xtensa_emit_move_sequence): Add + 'CONST_INT_P (src)' to the condition of the block that tries to + eliminate literal when loading integer contant. +--- + gcc/config/xtensa/xtensa.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c +index f4f8f1975c55a..8d6755144c120 100644 +--- a/gcc/config/xtensa/xtensa.c ++++ b/gcc/config/xtensa/xtensa.c +@@ -1084,7 +1084,8 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode) + { + /* Try to emit MOVI + SLLI sequence, that is smaller + than L32R + literal. */ +- if (optimize_size && mode == SImode && register_operand (dst, mode)) ++ if (optimize_size && mode == SImode && CONST_INT_P (src) ++ && register_operand (dst, mode)) + { + HOST_WIDE_INT srcval = INTVAL (src); + int shift = ctz_hwi (srcval); From 0b9752623e1cff524d09ee57dffb84b01d103f87 Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Thu, 9 Sep 2021 01:09:35 +0900 Subject: [PATCH 3/4] Makefile: Add GCC config options to `--enable-checking=all` --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5cae772..a831b89 100644 --- a/Makefile +++ b/Makefile @@ -254,6 +254,7 @@ configure += --enable-languages=c,c++ configure += --enable-lto configure += --enable-static=yes configure += --disable-libstdcxx-verbose +configure += --enable-checking=all # Newlib configuration common CONFIGURENEWLIBCOM = --with-newlib From 7a464ef5b6eb6457e1e24f16170a6922d9c6f1d3 Mon Sep 17 00:00:00 2001 From: Takayuki 'January June' Suwa Date: Thu, 9 Sep 2021 19:48:07 +0900 Subject: [PATCH 4/4] Revert "Makefile: Add GCC config options to `--enable-checking=all`" with `--enable-checking=all`, /~https://github.com/earlephilhower/esp-quick-toolchain/pull/31/commits/ed86506061e9e09b0aec375470858d58d0890fad surely inhibits ICE such as: ``` /tmp/esp-quick-toolchain/repo/newlib/newlib/libc/stdlib/__exp10.c:19:20: internal compiler error: RTL check: expected code 'const_int', have 'symbol_ref' in xtensa_emit_move_sequence, at config/xtensa/xtensa.c:1079 ``` by the way, however, `--enable-checking=all` reveals another issue; building stops by ICE in `.stage.LINUX.libstdcpp`: ``` In file included from /tmp/esp-quick-toolchain/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/hashtable.h:35, from /tmp/esp-quick-toolchain/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/unordered_map:46, from /tmp/esp-quick-toolchain/repo/gcc-gnu/libstdc++-v3/include/precompiled/stdc++.h:117: /tmp/esp-quick-toolchain/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/hashtable_policy.h:787:23: internal compiler error: in discriminator_for_local$ | __throw_out_of_range(__EXCSTR(__N("_Map_base::at"))); | ^~~~~~~~ 0x5fe038 discriminator_for_local_entity /tmp/esp-quick-toolchain/repo/gcc-gnu/gcc/cp/mangle.c:1910 (snip) ``` ``` static int discriminator_for_local_entity (tree entity) { if (!DECL_LANG_SPECIFIC (entity)) { /* Some decls, like __FUNCTION__, don't need a discriminator. */ gcc_checking_assert (DECL_ARTIFICIAL (entity)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return 0; } else if (tree disc = DECL_DISCRIMINATOR (entity)) return TREE_INT_CST_LOW (disc); else /* The first entity with a particular name doesn't get DECL_DISCRIMINATOR set up. */ return 0; } ``` (/~https://github.com/gcc-mirror/gcc/blob/releases/gcc-10.3.0/gcc/cp/mangle.c#L1910) but the abovementioned issue seems not to be related to this PR and should be posted as detached issue/PR, i guess. then, this reverts commit 0b9752623e1cff524d09ee57dffb84b01d103f87. --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index a831b89..5cae772 100644 --- a/Makefile +++ b/Makefile @@ -254,7 +254,6 @@ configure += --enable-languages=c,c++ configure += --enable-lto configure += --enable-static=yes configure += --disable-libstdcxx-verbose -configure += --enable-checking=all # Newlib configuration common CONFIGURENEWLIBCOM = --with-newlib