build/autoconf/llvm-pr8927.m4

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/autoconf/llvm-pr8927.m4	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +dnl Check if the compiler suffers from http://llvm.org/pr8927. If so, ask the
     1.9 +dnl user to upgrade.
    1.10 +
    1.11 +AC_DEFUN([MOZ_LLVM_PR8927],
    1.12 +[
    1.13 +AC_MSG_CHECKING(for llvm pr8927)
    1.14 +ac_have_llvm_pr8927="no"
    1.15 +AC_LANG_SAVE
    1.16 +AC_LANG_C
    1.17 +
    1.18 +_SAVE_CFLAGS=$CFLAGS
    1.19 +CFLAGS="-O2"
    1.20 +AC_TRY_RUN([
    1.21 +struct foobar {
    1.22 +  int x;
    1.23 +};
    1.24 +static const struct foobar* foo() {
    1.25 +  static const struct foobar d = { 0 };
    1.26 +  return &d;
    1.27 +}
    1.28 +static const struct foobar* bar() {
    1.29 +  static const struct foobar d = { 0 };
    1.30 +  return &d;
    1.31 +}
    1.32 +__attribute__((noinline)) int zed(const struct foobar *a,
    1.33 +                                  const struct foobar *b) {
    1.34 +  return a == b;
    1.35 +}
    1.36 +int main() {
    1.37 +  return zed(foo(), bar());
    1.38 +}
    1.39 +], true,
    1.40 +   ac_have_llvm_pr8927="yes",
    1.41 +   true)
    1.42 +CFLAGS="$_SAVE_CFLAGS"
    1.43 +
    1.44 +AC_LANG_RESTORE
    1.45 +
    1.46 +if test "$ac_have_llvm_pr8927" = "yes"; then
    1.47 +   AC_MSG_RESULT(yes)
    1.48 +   echo This compiler would miscompile firefox, please upgrade.
    1.49 +   echo see http://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions/Mac_OS_X_Prerequisites
    1.50 +   echo for more information.
    1.51 +   exit 1
    1.52 +else
    1.53 +   AC_MSG_RESULT(no)
    1.54 +fi
    1.55 +])

mercurial