Skip to contentSkip to conversation

musl: use a more specific fix for ARM thumb + frame pointers

PATCH Superseded Andre McCurdy 2 participants 2 messages Oct 7, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 musl: use a more specific fix for ARM thumb + frame pointers

When compiling for Thumb or Thumb2, frame pointers _must_ be disabled since the Thumb frame pointer in r7 clashes with musl's use of inline asm to make syscalls (where r7 is used for the syscall NR).

In most cases, frame pointers will be disabled automatically due to the optimisation level, but appending an explicit -fomit-frame-pointer to CFLAGS handles cases where optimisation is set to -O0 or frame pointers have been enabled by -fno-omit-frame-pointer earlier in CFLAGS, etc.

Note that this limitation applies both to gcc and clang, the only difference between the two being that where gcc aborts with an error about reusing r7, clang apparently silently generates broken code:

https://bugs.llvm.org/show_bug.cgi?id=34165

---
 meta/recipes-core/musl/musl_git.bb | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/recipes-core/musl/musl_git.bb +10 -0
index 8b6a2e3..3766501 100644
@@ -28,6 +28,16 @@ export CROSS_COMPILE="${TARGET_PREFIX}"
 
 LDFLAGS += "-Wl,-soname,libc.so"
 
+# When compiling for Thumb or Thumb2, frame pointers _must_ be disabled since the
+# Thumb frame pointer in r7 clashes with musl's use of inline asm to make syscalls
+# (where r7 is used for the syscall NR). In most cases, frame pointers will be
+# disabled automatically due to the optimisation level, but append an explicit
+# -fomit-frame-pointer to handle cases where optimisation is set to -O0 or frame
+# pointers have been enabled by -fno-omit-frame-pointer earlier in CFLAGS, etc.
+CFLAGS_append_arm = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+
+# Pending testing, this can probably be removed (fixed more specifically above
+# by appending -fomit-frame-pointer to CFLAGS when building for Thumb).
 ARM_INSTRUCTION_SET_toolchain-clang = "arm"
 
 CONFIGUREOPTS = " \
Signature · 1 line
1.9.1
#1 lore raw
Quoted 30 lines · Andre McCurdy

When compiling for Thumb or Thumb2, frame pointers _must_ be disabled since the Thumb frame pointer in r7 clashes with musl's use of inline asm to make syscalls (where r7 is used for the syscall NR).

In most cases, frame pointers will be disabled automatically due to the optimisation level, but appending an explicit -fomit-frame-pointer to CFLAGS handles cases where optimisation is set to -O0 or frame pointers have been enabled by -fno-omit-frame-pointer earlier in CFLAGS, etc.

Note that this limitation applies both to gcc and clang, the only difference between the two being that where gcc aborts with an error about reusing r7, clang apparently silently generates broken code:

https://bugs.llvm.org/show_bug.cgi?id=34165

---
 meta/recipes-core/musl/musl_git.bb | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/recipes-core/musl/musl_git.bb +1 -0
index 8b6a2e3..3766501 100644
@@ -28,6 +28,16 @@ export CROSS_COMPILE="${TARGET_PREFIX}"
 
 LDFLAGS += "-Wl,-soname,libc.so"
 
+# When compiling for Thumb or Thumb2, frame pointers _must_ be disabled since the

meta/recipes-core/musl/musl_git.bb export CROSS_COMPILE="${TARGET_PREFIX}" · line 41

Quoted 10 lines
meta/recipes-core/musl/musl_git.bb +9 -0
+# Thumb frame pointer in r7 clashes with musl's use of inline asm to make syscalls
+# (where r7 is used for the syscall NR). In most cases, frame pointers will be
+# disabled automatically due to the optimisation level, but append an explicit
+# -fomit-frame-pointer to handle cases where optimisation is set to -O0 or frame
+# pointers have been enabled by -fno-omit-frame-pointer earlier in CFLAGS, etc.
+CFLAGS_append_arm = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
+
+# Pending testing, this can probably be removed (fixed more specifically above
+# by appending -fomit-frame-pointer to CFLAGS when building for Thumb).
 ARM_INSTRUCTION_SET_toolchain-clang = "arm"

Please remove this. Then I can test the patch with clang and see if it fails

Quoted 10 lines
meta/recipes-core/musl/musl_git.bb +0 -1
 CONFIGUREOPTS = " \
--

1.9.1

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