aboutsummaryrefslogtreecommitdiff
path: root/libatomic/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'libatomic/configure.ac')
-rw-r--r--libatomic/configure.ac25
1 files changed, 20 insertions, 5 deletions
diff --git a/libatomic/configure.ac b/libatomic/configure.ac
index 32a2cdb..23a9695 100644
--- a/libatomic/configure.ac
+++ b/libatomic/configure.ac
@@ -129,6 +129,26 @@ AC_SUBST(toolexeclibdir)
# the wrong, non-multilib-adjusted value will be used in multilibs.
# As a side effect, we have to subst CFLAGS ourselves.
+# AC_PROG_CC sets CFLAGS to "-g -O2" by default (if unset), and
+# then compile conftests with default CFLAGS, leaving no place to temporarily
+# modify CFLAGS and restore them later. However we need to pass
+# -fno-link-libatomic in CFLAGS so conftests compiled in AC_PROG_CC don't fail.
+# Assert that CFLAGS is always set by user so the default setting of CFLAGS by
+# AC_PROG_CC won't be applicable anyway.
+if test -z "${CFLAGS}"; then
+ AC_MSG_ERROR([CFLAGS must be set.])
+fi
+
+# In order to override CFLAGS_FOR_TARGET, all of our special flags go
+# in XCFLAGS. But we need them in CFLAGS during configury. So put them
+# in both places for now and restore CFLAGS at the end of config.
+save_CFLAGS="$CFLAGS"
+
+# Append -fno-link-libatomic to avoid automatically linking libatomic,
+# while building libatomic itself.
+XCFLAGS="$XCFLAGS -fno-link-libatomic"
+CFLAGS="$save_CFLAGS $XCFLAGS"
+
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
m4_define([_AC_ARG_VAR_PRECIOUS],[])
AC_PROG_CC
@@ -137,11 +157,6 @@ m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
AC_SUBST(CFLAGS)
-# In order to override CFLAGS_FOR_TARGET, all of our special flags go
-# in XCFLAGS. But we need them in CFLAGS during configury. So put them
-# in both places for now and restore CFLAGS at the end of config.
-save_CFLAGS="$CFLAGS"
-
# Find other programs we need.
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(NM, nm)