Skip to contentSkip to conversation

gcc: fix miscompilation for mips64 which caused systemd's strange behaviour

PATCH In review Chen Qi 3 participants 8 messages Oct 27, 2017 – Oct 30, 2017

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover gcc: fix miscompilation for mips64 which caused systemd's strange behaviour

The following changes since commit 65d23bd7986615fdfb0f1717b615534a2a14ab80:

README.qemu: qemuppc64 is not supported (2017-10-16 23:54:31 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/bug12266
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/bug12266

Chen Qi (2):
systemd: remove useless options for mips4
gcc: fix miscompilation on mips64

 meta/recipes-core/systemd/systemd_234.bb           |  3 --
 meta/recipes-devtools/gcc/gcc-7.2.inc              |  1 +
 .../fix-miscompilation-for-O1-on-mips64el.patch    | 35 ++++++++++++++++++++++
 3 files changed, 36 insertions(+), 3 deletions(-)
 create mode 100644 meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/2 systemd: remove useless options for mips4

Looking back the history, we had problem with systemd on qemumips64 which is also related to compilation flags. We solved that by using tweaking FULL_OPTIMIZATION for mips64 to have "-fno-tree-switch-conversion -fno-tree-tail-merge".

Now systemd has been upgraded to 234, and we don't have the above problem any more, thus removing these flags.

---
 meta/recipes-core/systemd/systemd_234.bb | 3 ---
 1 file changed, 3 deletions(-)
meta/recipes-core/systemd/systemd_234.bb +0 -3
index 36fd3f8..971226f 100644
@@ -158,9 +158,6 @@ CFLAGS .= "${@bb.utils.contains('PACKAGECONFIG', 'valgrind', ' -DVALGRIND=1', ''
 # disable problematic GCC 5.2 optimizations [YOCTO #8291]
 FULL_OPTIMIZATION_append_arm = " -fno-schedule-insns -fno-schedule-insns2"
 
-# Avoid login failure on qemumips64 when pam is enabled
-FULL_OPTIMIZATION_append_mips64 = " -fno-tree-switch-conversion -fno-tree-tail-merge"
-
 COMPILER_NM ?= "${HOST_PREFIX}gcc-nm"
 COMPILER_AR ?= "${HOST_PREFIX}gcc-ar"
 COMPILER_RANLIB ?= "${HOST_PREFIX}gcc-ranlib"
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 2/2 gcc: fix miscompilation on mips64

In reply to Chen Qi

We've observed strange behaviour of systemctl status <xxx> on qemumips64. The output of the command is like systemctl show <xxx>', which is incorrect.

This patch is from gcc bugzilla's attachment.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803

The patch hasn't been merged into gcc. But it does solve the above problem.

---
 meta/recipes-devtools/gcc/gcc-7.2.inc              |  1 +
 .../fix-miscompilation-for-O1-on-mips64el.patch    | 35 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch
meta/recipes-devtools/gcc/gcc-7.2.inc +1 -0
index 5883bc6..04edad7 100644
@@ -75,6 +75,7 @@ SRC_URI = "\
            file://0048-gcc-Enable-static-PIE.patch \
            file://fix-segmentation-fault-precompiled-hdr.patch \
            file://0050-RISC-V-Handle-non-legitimate-address-in-riscv_legiti.patch \
+           file://fix-miscompilation-for-O1-on-mips64el.patch \
            ${BACKPORTS} \
 "
 BACKPORTS = "\
meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file +35 -0
new file mode 100644
index 0000000..28020b0
@@ -0,0 +1,35 @@
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+
+Author: mpf <mpf@138bc75d-0d04-0410-961f-82ee72b054a4>
+
+This patch hasn't been merged into gcc. But it does solve the problem of
+strange behaviour of `systemd status <xxx>' on qemumips64.
+
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ gcc/lra-constraints.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
+index c8bc9b9a66f..6d319662b09 100644
+--- a/gcc/lra-constraints.c
++++ b/gcc/lra-constraints.c
+@@ -4235,7 +4235,12 @@ curr_insn_transform (bool check_only_p)
+ 			  && (goal_alt[i] == NO_REGS
+ 			      || (simplify_subreg_regno
+ 				  (ira_class_hard_regs[goal_alt[i]][0],
+-				   GET_MODE (reg), byte, mode) >= 0)))))
++				   GET_MODE (reg), byte, mode) >= 0))))
++		      || (type != OP_IN
++			  && GET_MODE_PRECISION (mode)
++			  < GET_MODE_PRECISION (GET_MODE (reg))
++			  && GET_MODE_SIZE (GET_MODE (reg)) <= UNITS_PER_WORD
++			  && WORD_REGISTER_OPERATIONS))
+ 		{
+ 		  /* An OP_INOUT is required when reloading a subreg of a
+ 		     mode wider than a word to ensure that data beyond the
+-- 
+2.13.0
+
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH 2/2] gcc: fix miscompilation on mips64

meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch line 8

Quoted 2 lines · Chen Qi
meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file +2 -0
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]

Then it should be 'Submitted', right?

Alex

#4 lore raw

Re: [PATCH 2/2] gcc: fix miscompilation on mips64

Quoted 8 lines · Alexander Kanavin

meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch line 8

Quoted 2 lines · Chen Qi
meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file +2 -0
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]

Then it should be 'Submitted', right?

It has to be on gcc-patches ml for it to considered submitted

Quoted 7 lines

Alex

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#5 lore raw

Re: [PATCH 2/2] gcc: fix miscompilation on mips64

In reply to Chen Qi
Quoted 8 lines · Chen Qi

We've observed strange behaviour of systemctl status <xxx> on qemumips64. The output of the command is like systemctl show <xxx>', which is incorrect.

This patch is from gcc bugzilla's attachment.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803

The patch hasn't been merged into gcc. But it does solve the above problem.

This looks ok. Can you help by providing your testing results to gcc bugzilla so the patch can then be submitted to gcc ml.

Quoted 68 lines
---
 meta/recipes-devtools/gcc/gcc-7.2.inc              |  1 +
 .../fix-miscompilation-for-O1-on-mips64el.patch    | 35 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch
meta/recipes-devtools/gcc/gcc-7.2.inc +1 -0
index 5883bc6..04edad7 100644
@@ -75,6 +75,7 @@ SRC_URI = "\
            file://0048-gcc-Enable-static-PIE.patch \
            file://fix-segmentation-fault-precompiled-hdr.patch \
            file://0050-RISC-V-Handle-non-legitimate-address-in-riscv_legiti.patch \
+           file://fix-miscompilation-for-O1-on-mips64el.patch \
            ${BACKPORTS} \
 "
 BACKPORTS = "\
meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file +35 -1
new file mode 100644
index 0000000..28020b0
@@ -0,0 +1,35 @@
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+
+Author: mpf <mpf@138bc75d-0d04-0410-961f-82ee72b054a4>
+
+This patch hasn't been merged into gcc. But it does solve the problem of
+strange behaviour of `systemd status <xxx>' on qemumips64.
+
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ gcc/lra-constraints.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
+index c8bc9b9a66f..6d319662b09 100644
+--- a/gcc/lra-constraints.c
++++ b/gcc/lra-constraints.c
+@@ -4235,7 +4235,12 @@ curr_insn_transform (bool check_only_p)
+                         && (goal_alt[i] == NO_REGS
+                             || (simplify_subreg_regno
+                                 (ira_class_hard_regs[goal_alt[i]][0],
+-                                 GET_MODE (reg), byte, mode) >= 0)))))
++                                 GET_MODE (reg), byte, mode) >= 0))))
++                    || (type != OP_IN
++                        && GET_MODE_PRECISION (mode)
++                        < GET_MODE_PRECISION (GET_MODE (reg))
++                        && GET_MODE_SIZE (GET_MODE (reg)) <= UNITS_PER_WORD
++                        && WORD_REGISTER_OPERATIONS))
+               {
+                 /* An OP_INOUT is required when reloading a subreg of a
+                    mode wider than a word to ensure that data beyond the
+--
+2.13.0
+
--

1.9.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#6 lore raw

Re: [PATCH 2/2] gcc: fix miscompilation on mips64

Quoted 11 lines · Khem Raj
Quoted 8 lines · Chen Qi

We've observed strange behaviour of systemctl status <xxx> on qemumips64. The output of the command is like systemctl show <xxx>', which is incorrect.

This patch is from gcc bugzilla's attachment.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803

The patch hasn't been merged into gcc. But it does solve the above problem.

This looks ok. Can you help by providing your testing results to gcc bugzilla so the patch can then be submitted to gcc ml.

Some updates in this issue.

1) I've provided information in gcc bugzilla. The author says that he's going to submit the patch to gcc mailing list.

2) I've update remote branch to fix a typo ('mips4' --> 'mips64').

git://git.pokylinux.org/poky-contrib ChenQi/bug12266
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/bug12266

3) 'core-image-sato + testimage' has been tested on other qemu machines including qemux86-64, qemux86, qemumips, qemuppc, qemuarm64.

Best Regards,
Chen Qi

Quoted 68 lines
Quoted 68 lines
---
  meta/recipes-devtools/gcc/gcc-7.2.inc              |  1 +
  .../fix-miscompilation-for-O1-on-mips64el.patch    | 35 ++++++++++++++++++++++
  2 files changed, 36 insertions(+)

create mode 100644 meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch

meta/recipes-devtools/gcc/gcc-7.2.inc +1 -0
index 5883bc6..04edad7 100644
@@ -75,6 +75,7 @@ SRC_URI = "\
             file://0048-gcc-Enable-static-PIE.patch \
             file://fix-segmentation-fault-precompiled-hdr.patch \
             file://0050-RISC-V-Handle-non-legitimate-address-in-riscv_legiti.patch \
+           file://fix-miscompilation-for-O1-on-mips64el.patch \
             ${BACKPORTS} \
  "
  BACKPORTS = "\
meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file +35 -1
new file mode 100644
index 0000000..28020b0
@@ -0,0 +1,35 @@
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+
+Author: mpf <mpf@138bc75d-0d04-0410-961f-82ee72b054a4>
+
+This patch hasn't been merged into gcc. But it does solve the problem of
+strange behaviour of `systemd status <xxx>' on qemumips64.
+
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ gcc/lra-constraints.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
+index c8bc9b9a66f..6d319662b09 100644
+--- a/gcc/lra-constraints.c
++++ b/gcc/lra-constraints.c
+@@ -4235,7 +4235,12 @@ curr_insn_transform (bool check_only_p)
+                         && (goal_alt[i] == NO_REGS
+                             || (simplify_subreg_regno
+                                 (ira_class_hard_regs[goal_alt[i]][0],
+-                                 GET_MODE (reg), byte, mode) >= 0)))))
++                                 GET_MODE (reg), byte, mode) >= 0))))
++                    || (type != OP_IN
++                        && GET_MODE_PRECISION (mode)
++                        < GET_MODE_PRECISION (GET_MODE (reg))
++                        && GET_MODE_SIZE (GET_MODE (reg)) <= UNITS_PER_WORD
++                        && WORD_REGISTER_OPERATIONS))
+               {
+                 /* An OP_INOUT is required when reloading a subreg of a
+                    mode wider than a word to ensure that data beyond the
+--
+2.13.0
+
--

1.9.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#7 lore raw

Re: [PATCH 2/2] gcc: fix miscompilation on mips64

Quoted 23 lines · ChenQi

On 10/28/2017 01:40 AM, Khem Raj wrote:

On Fri, Oct 27, 2017 at 2:43 AM, Chen Qi <[email protected]> wrote:

We've observed strange behaviour of systemctl status <xxx> on qemumips64. The output of the command is like systemctl show <xxx>', which is incorrect.

This patch is from gcc bugzilla's attachment.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803

The patch hasn't been merged into gcc. But it does solve the above problem.

This looks ok. Can you help by providing your testing results to gcc bugzilla
so the patch can then be submitted to gcc ml.

Some updates in this issue.

1) I've provided information in gcc bugzilla. The author says that he's going to submit the patch to gcc mailing list.

Quoted 9 lines

2) I've update remote branch to fix a typo ('mips4' --> 'mips64').

git://git.pokylinux.org/poky-contrib ChenQi/bug12266
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/bug12266

3) 'core-image-sato + testimage' has been tested on other qemu machines including qemux86-64, qemux86, qemumips, qemuppc, qemuarm64.

thanks I have tested this fix locally. its good to apply

Quoted 82 lines

Best Regards,
Chen Qi

---
 meta/recipes-devtools/gcc/gcc-7.2.inc              |  1 +
 .../fix-miscompilation-for-O1-on-mips64el.patch    | 35
++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644

meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch

meta/recipes-devtools/gcc/gcc-7.2.inc +1 -0
index 5883bc6..04edad7 100644
@@ -75,6 +75,7 @@ SRC_URI = "\
            file://0048-gcc-Enable-static-PIE.patch \
            file://fix-segmentation-fault-precompiled-hdr.patch \
 
 file://0050-RISC-V-Handle-non-legitimate-address-in-riscv_legiti.patch \
+           file://fix-miscompilation-for-O1-on-mips64el.patch \
            ${BACKPORTS} \
 "

BACKPORTS = "\
diff --git a/meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch b/meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch new file mode 100644
index 0000000..28020b0
--- /dev/null
+++
b/meta/recipes-devtools/gcc/gcc-7.2/fix-miscompilation-for-O1-on-mips64el.patch

meta/recipes-devtools/gcc/gcc-7.2.inc +28 -0
@@ -0,0 +1,35 @@
+This patch comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81803
+
+Author: mpf <mpf@138bc75d-0d04-0410-961f-82ee72b054a4>
+
+This patch hasn't been merged into gcc. But it does solve the problem of
+strange behaviour of `systemd status <xxx>' on qemumips64.
+
+Upstream-Status: Pending [Taken from gcc bugzilla's attachment]
+
+Signed-off-by: Chen Qi <[email protected]>
+---
+ gcc/lra-constraints.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
+index c8bc9b9a66f..6d319662b09 100644
+--- a/gcc/lra-constraints.c
++++ b/gcc/lra-constraints.c
+@@ -4235,7 +4235,12 @@ curr_insn_transform (bool check_only_p)
+                         && (goal_alt[i] == NO_REGS
+                             || (simplify_subreg_regno
+                                 (ira_class_hard_regs[goal_alt[i]][0],
+-                                 GET_MODE (reg), byte, mode) >= 0)))))
++                                 GET_MODE (reg), byte, mode) >= 0))))
++                    || (type != OP_IN
++                        && GET_MODE_PRECISION (mode)
++                        < GET_MODE_PRECISION (GET_MODE (reg))
++                        && GET_MODE_SIZE (GET_MODE (reg)) <=

UNITS_PER_WORD
++ && WORD_REGISTER_OPERATIONS))

meta/recipes-devtools/gcc/gcc-7.2.inc +6 -1
+               {
+                 /* An OP_INOUT is required when reloading a subreg of a
+                    mode wider than a word to ensure that data beyond the
+--
+2.13.0
+
--

1.9.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core