build/autoconf/frameptr.m4
author Nick Alexander <nalexander@mozilla.com>
Fri, 12 Oct 2018 22:38:44 +0000
changeset 499408 91300d29898b1a1102e1b62164aeee1f56b2ee86
parent 495468 303fb0953da3d720582705879415680d33270838
child 519604 6f86eefc83a54a89c54f9e5d9b439e9e02e946f7
permissions -rw-r--r--
Bug 1489443 - Set GCC_USE_GNU_LD based on linker kind. r=froydnj The desired outcome of this change is that we'll set `-Wl,--version-script` based on linker kind and not on the output of `$LINKER -v`. This is a cheap way to address a simple problem that has a complicated ideal solution. The underlying issue is that in some situations, when targeting Android, a macOS system `ld` is interrogated to determine if a cross-compiling linker "is GNU ld" and a particular linker feature is set in that situation. The macOS system `ld` doesn't pass the "is GNU ld" test, and the linker feature isn't set; that causes link failures, even though the actual linker has nothing to do with the system `ld`. The ideal solution is to test for linker capabilities dynamically. We do a lot of that in old-configure.in, and we don't do any of that in toolchain.configure. Rather than start testing in toolchain.configure, we hard-code: a cheap solution to the immediate problem. Differential Revision: https://phabricator.services.mozilla.com/D8471

dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.

dnl Set MOZ_FRAMEPTR_FLAGS to the flags that should be used for enabling or
dnl disabling frame pointers in this architecture based on the configure
dnl options

AC_DEFUN([MOZ_SET_FRAMEPTR_FLAGS], [
  if test "$GNU_CC"; then
    MOZ_ENABLE_FRAME_PTR="-fno-omit-frame-pointer -funwind-tables"
    MOZ_DISABLE_FRAME_PTR="-fomit-frame-pointer -funwind-tables"
  else
    case "$target" in
    dnl Oy (Frame-Pointer Omission) is only support on x86 compilers
    *-mingw32*)
      MOZ_ENABLE_FRAME_PTR="-Oy-"
      MOZ_DISABLE_FRAME_PTR="-Oy"
    ;;
    esac
  fi

  # If we are debugging, profiling, using sanitizers, or on win32 we want a
  # frame pointer.  It is not required to enable frame pointers on AArch64
  # Windows, but we enable it for compatibility with ETW.
  if test -z "$MOZ_OPTIMIZE" -o \
          -n "$MOZ_PROFILING" -o \
          -n "$MOZ_DEBUG" -o \
          -n "$MOZ_MSAN" -o \
          -n "$MOZ_ASAN" -o \
          -n "$MOZ_UBSAN" -o \
          "$OS_ARCH:$CPU_ARCH" = "WINNT:x86" -o \
	  "$OS_ARCH:$CPU_ARCH" = "WINNT:aarch64"; then
    MOZ_FRAMEPTR_FLAGS="$MOZ_ENABLE_FRAME_PTR"
  else
    MOZ_FRAMEPTR_FLAGS="$MOZ_DISABLE_FRAME_PTR"
  fi
])