| ... |
... |
@@ -153,12 +153,38 @@ AC_SUBST([EnableStrictGhcToolchainCheck]) |
|
153
|
153
|
|
|
154
|
154
|
dnl ** Which gcc to use?
|
|
155
|
155
|
dnl --------------------------------------------------------------
|
|
|
156
|
+
|
|
|
157
|
+dnl AC_PROG_CC sets CFLAGS to `-g -O2` if the env var is empty.
|
|
|
158
|
+dnl Same goes for AC_PROG_CXX and CXXFLAGS. Setting the vars prevents this.
|
|
|
159
|
+dnl (`-g` increases binary sizes with debugging symbols. `-O2` may optimize
|
|
|
160
|
+dnl symbols away, confusing the RTS linker.)
|
|
|
161
|
+: ${CFLAGS=""}
|
|
|
162
|
+: ${CXXFLAGS=""}
|
|
|
163
|
+
|
|
156
|
164
|
AC_PROG_CC([cc gcc clang])
|
|
157
|
165
|
AC_PROG_CXX([c++ g++ clang++])
|
|
158
|
166
|
# Work around #24324
|
|
159
|
167
|
MOVE_TO_FLAGS([CC],[CFLAGS])
|
|
160
|
168
|
MOVE_TO_FLAGS([CXX],[CXXFLAGS])
|
|
161
|
169
|
|
|
|
170
|
+dnl Save the original user-provided environment variables immediately
|
|
|
171
|
+dnl before any m4 macros modify them. These will be passed to ghc-toolchain
|
|
|
172
|
+dnl so it can make independent decisions and reach the same conclusions as autoconf.
|
|
|
173
|
+USER_CONF_CC_OPTS_STAGE2="$CFLAGS"
|
|
|
174
|
+USER_CONF_CXX_OPTS_STAGE2="$CXXFLAGS"
|
|
|
175
|
+USER_CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS"
|
|
|
176
|
+USER_CPP_ARGS="$CPPFLAGS"
|
|
|
177
|
+USER_HS_CPP_ARGS="$HaskellCPPArgs"
|
|
|
178
|
+USER_JS_CPP_ARGS="$JavaScriptCPPArgs"
|
|
|
179
|
+USER_CMM_CPP_ARGS="$CmmCPPArgs"
|
|
|
180
|
+
|
|
|
181
|
+dnl Initialize CONF_* variables with user-provided environment variables
|
|
|
182
|
+dnl so that subsequent configure checks modify them and both autoconf and
|
|
|
183
|
+dnl ghc-toolchain see the same values
|
|
|
184
|
+CONF_CC_OPTS_STAGE2="$CFLAGS"
|
|
|
185
|
+CONF_CXX_OPTS_STAGE2="$CXXFLAGS"
|
|
|
186
|
+CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS"
|
|
|
187
|
+
|
|
162
|
188
|
dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
|
|
163
|
189
|
AC_PROG_CPP
|
|
164
|
190
|
|