Skip to contentSkip to conversation

valgrind: build for the right MIPS ISA revision level

PATCH New Vicente Olivert Riera 3 participants 3 messages Sep 21, 2015 – Oct 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 valgrind: build for the right MIPS ISA revision level

When Valgrind detects a 32-bit MIPS architecture, it forcibly adds -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture, it forcibly adds -march=mips64. This causes Valgrind to be built always for the first ISA revision level (R1), even when the user has configured Buildroot for the second ISA revision level (R2).

Since R2 is backwards compatible with R1, you can run a Valgrind built for R1 in an R2 core. This is why nobody noticed about this problem, or at least nobody complained.

But, since (I hope) we will support R6 in Buildroot in the near future, this problem will become very important because R6 is not backwards compatible with R1 or R2, so building Valgrind for R1 when your target is R6 will result in a non-working Valgrind.

Override the CFLAGS variable (which Valgrind appends to its CFLAGS) and pass the right -march option, so they take precedence over Valgrind's wrongfully detected value.

---
Changes v1 -> v2:
- Improved commit log. (Suggested by Yann E. Morin)

 package/valgrind/valgrind.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/valgrind/valgrind.mk +13 -0
index f8f205e..9500264 100644
@@ -13,6 +13,19 @@ VALGRIND_CONF_OPTS = --disable-tls
 VALGRIND_AUTORECONF = YES
 VALGRIND_INSTALL_STAGING = YES
 
+# When Valgrind detects a 32-bit MIPS architecture, it forcibly adds
+# -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture,
+# it forcibly adds -march=mips64. This causes Valgrind to be built
+# always for the first ISA revision level (R1), even when the user has
+# configured Buildroot for the second ISA revision level (R2).
+#
+# Override the CFLAGS variable (which Valgrind appends to its CFLAGS)
+# and pass the right -march option, so they take precedence over
+# Valgrind's wrongfully detected value.
+ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
+VALGRIND_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -march=$(BR2_GCC_TARGET_ARCH)"
+endif
+
 # On ARM, Valgrind only supports ARMv7, and uses the arch part of the
 # host tuple to determine whether it's being built for ARMv7 or
 # not. Therefore, we adjust the host tuple to specify we're on
Signature · 1 line
2.4.9
#1 lore raw

PATCH v2 1/1 valgrind: build for the right MIPS ISA revision level

Vicente, All,

On 2015-09-21 23:31 +0100, Vicente Olivert Riera spake thusly:

Quoted 15 lines

When Valgrind detects a 32-bit MIPS architecture, it forcibly adds -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture, it forcibly adds -march=mips64. This causes Valgrind to be built always for the first ISA revision level (R1), even when the user has configured Buildroot for the second ISA revision level (R2).

Since R2 is backwards compatible with R1, you can run a Valgrind built for R1 in an R2 core. This is why nobody noticed about this problem, or at least nobody complained.

But, since (I hope) we will support R6 in Buildroot in the near future, this problem will become very important because R6 is not backwards compatible with R1 or R2, so building Valgrind for R1 when your target is R6 will result in a non-working Valgrind.

Quoted 6 lines

Override the CFLAGS variable (which Valgrind appends to its CFLAGS) and pass the right -march option, so they take precedence over Valgrind's wrongfully detected value.

Regards,
Yann E. MORIN.

Quoted 34 lines

---
Changes v1 -> v2:
- Improved commit log. (Suggested by Yann E. Morin)

 package/valgrind/valgrind.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/valgrind/valgrind.mk +13 -0
index f8f205e..9500264 100644
@@ -13,6 +13,19 @@ VALGRIND_CONF_OPTS = --disable-tls
 VALGRIND_AUTORECONF = YES
 VALGRIND_INSTALL_STAGING = YES
 
+# When Valgrind detects a 32-bit MIPS architecture, it forcibly adds
+# -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture,
+# it forcibly adds -march=mips64. This causes Valgrind to be built
+# always for the first ISA revision level (R1), even when the user has
+# configured Buildroot for the second ISA revision level (R2).
+#
+# Override the CFLAGS variable (which Valgrind appends to its CFLAGS)
+# and pass the right -march option, so they take precedence over
+# Valgrind's wrongfully detected value.
+ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
+VALGRIND_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -march=$(BR2_GCC_TARGET_ARCH)"
+endif
+
 # On ARM, Valgrind only supports ARMv7, and uses the arch part of the
 # host tuple to determine whether it's being built for ARMv7 or
 # not. Therefore, we adjust the host tuple to specify we're on
Signature · 1 line
2.4.9
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 valgrind: build for the right MIPS ISA revision level

In reply to Vicente Olivert Riera
Quoted 21 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vicente" == Vicente Olivert Riera <[email protected]> writes:

When Valgrind detects a 32-bit MIPS architecture, it forcibly adds -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture, it forcibly adds -march=mips64. This causes Valgrind to be built always for the first ISA revision level (R1), even when the user has configured Buildroot for the second ISA revision level (R2).

Since R2 is backwards compatible with R1, you can run a Valgrind built for R1 in an R2 core. This is why nobody noticed about this problem, or at least nobody complained.

But, since (I hope) we will support R6 in Buildroot in the near future, this problem will become very important because R6 is not backwards compatible with R1 or R2, so building Valgrind for R1 when your target is R6 will result in a non-working Valgrind.

Override the CFLAGS variable (which Valgrind appends to its CFLAGS) and pass the right -march option, so they take precedence over Valgrind's wrongfully detected value.

Quoted 5 lines

---
Changes v1 -> v2:
- Improved commit log. (Suggested by Yann E. Morin)

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard