js/src/build/autoconf/llvm-pr8927.m4
author Rafael Ávila de Espíndola <respindola@mozilla.com>
Wed, 12 Sep 2012 14:48:16 -0400
changeset 113787 b68926c02a8378f4005d94bfc5fdcf7e5b39640d
child 152451 6c6b968a895a5a3e74f438c44803503b239dd4e1
permissions -rw-r--r--
Bug 788276 - Properly check for broken (deprecated) compilers. r=gps. Check for old versions of llvm.

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 Check if the compiler suffers from http://llvm.org/pr8927. If so, ask the
dnl user to upgrade.

AC_DEFUN([MOZ_LLVM_PR8927],
[
AC_MSG_CHECKING(for llvm pr8927)
ac_have_llvm_pr8927="no"
AC_LANG_SAVE
AC_LANG_C

_SAVE_CFLAGS=$CFLAGS
CFLAGS="-O2"
AC_TRY_RUN([
struct foobar {
  int x;
};
static const struct foobar* foo() {
  static const struct foobar d = { 0 };
  return &d;
}
static const struct foobar* bar() {
  static const struct foobar d = { 0 };
  return &d;
}
__attribute__((noinline)) int zed(const struct foobar *a,
                                  const struct foobar *b) {
  return a == b;
}
int main() {
  return zed(foo(), bar());
}
], true,
   ac_have_llvm_pr8927="yes",
   true)
CFLAGS="$_SAVE_CFLAGS"

AC_LANG_RESTORE

if test "$ac_have_llvm_pr8927" = "yes"; then
   AC_MSG_RESULT(yes)
   echo This compiler would miscompile firefox, plase upgrade.
   echo see http://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites
   echo for more information.
   exit 1
else
   AC_MSG_RESULT(no)
fi
])