Commit 001b9a4d authored by Ian Lynagh's avatar Ian Lynagh

Keep separate linker flags, for when we want to link with gcc or ld

parent 77b29b56
......@@ -8,12 +8,13 @@
# ----------------------------------
# Set the C, LD and CPP flags for a given platform
# $1 is the platform
# $2 is the name of the C flags variable
# $3 is the name of the LD flags variable
# $4 is the name of the CPP flags variable
# $2 is the name of the CC flags variable
# $3 is the name of the linker flags variable when linking with gcc
# $4 is the name of the linker flags variable when linking with ld
# $5 is the name of the CPP flags variable
AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
[
AC_MSG_CHECKING([Setting up $2, $3 and $4])
AC_MSG_CHECKING([Setting up $2, $3, $4 and $5])
case $$1 in
i386-apple-darwin)
# By default, gcc on OS X will generate SSE
......@@ -22,12 +23,14 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
# back to generic i686 compatibility. Trac #2983.
$2="$$2 -march=i686 -m32"
$3="$$3 -march=i686 -m32"
$4="$$4 -march=i686 -m32"
$4="$$4 -arch i386"
$5="$$5 -march=i686 -m32"
;;
x86_64-apple-darwin)
$2="$$2 -m64"
$3="$$3 -m64"
$4="$$4 -m64"
$4="$$4 -arch x86_64"
$5="$$5 -m64"
;;
esac
......@@ -36,7 +39,8 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
# We support back to OS X 10.5
$2="$$2 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
$3="$$3 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
$4="$$4 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
$4="$$4 -macosx_version_min 10.5"
$5="$$5 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
;;
esac
......
......@@ -110,8 +110,10 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
@echo 'cStage = show (STAGE :: Int)' >> $@
@echo 'cCcOpts :: [String]' >> $@
@echo 'cCcOpts = words "$(CONF_CC_OPTS_STAGE$*)"' >> $@
@echo 'cLdOpts :: [String]' >> $@
@echo 'cLdOpts = words "$(CONF_LD_OPTS_STAGE$*)"' >> $@
@echo 'cGccLinkerOpts :: [String]' >> $@
@echo 'cGccLinkerOpts = words "$(CONF_GCC_LINKER_OPTS_STAGE$*)"' >> $@
@echo 'cLdLinkerOpts :: [String]' >> $@
@echo 'cLdLinkerOpts = words "$(CONF_LD_LINKER_OPTS_STAGE$*)"' >> $@
@echo 'cIntegerLibrary :: String' >> $@
@echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
@echo 'cSplitObjs :: String' >> $@
......
......@@ -2296,6 +2296,7 @@ compilerInfo = [("Project name", String cProjectName),
("LibDir", FromDynFlags topDir),
("Global Package DB", FromDynFlags systemPackageConfig),
("C compiler flags", String (show cCcOpts)),
("Linker flags", String (show cLdOpts))
("Gcc Linker flags", String (show cGccLinkerOpts)),
("Ld Linker flags", String (show cLdLinkerOpts))
]
......@@ -546,11 +546,11 @@ dnl If gcc, make sure it's at least 2.1
dnl
FP_HAVE_GCC
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[CPPFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_LD_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_LD_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
# Stage 3 won't be supported by cross-compilation
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_LD_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
FP_GCC_EXTRA_FLAGS
......@@ -560,9 +560,12 @@ AC_PROG_CPP
AC_SUBST(CONF_CC_OPTS_STAGE0)
AC_SUBST(CONF_CC_OPTS_STAGE1)
AC_SUBST(CONF_CC_OPTS_STAGE2)
AC_SUBST(CONF_LD_OPTS_STAGE0)
AC_SUBST(CONF_LD_OPTS_STAGE1)
AC_SUBST(CONF_LD_OPTS_STAGE2)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_CPP_OPTS_STAGE0)
AC_SUBST(CONF_CPP_OPTS_STAGE1)
AC_SUBST(CONF_CPP_OPTS_STAGE2)
......
......@@ -60,17 +60,24 @@ dnl ** Check gcc version and flags we need to pass it **
#
FP_GCC_EXTRA_FLAGS
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_LD_OPTS_STAGE0])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_LD_OPTS_STAGE1])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_LD_OPTS_STAGE2])
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
# Stage 3 won't be supported by cross-compilation
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
AC_SUBST(CONF_CC_OPTS_STAGE0)
AC_SUBST(CONF_CC_OPTS_STAGE1)
AC_SUBST(CONF_CC_OPTS_STAGE2)
AC_SUBST(CONF_LD_OPTS_STAGE0)
AC_SUBST(CONF_LD_OPTS_STAGE1)
AC_SUBST(CONF_LD_OPTS_STAGE2)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_CPP_OPTS_STAGE0)
AC_SUBST(CONF_CPP_OPTS_STAGE1)
AC_SUBST(CONF_CPP_OPTS_STAGE2)
#
dnl ** how to invoke `ar' and `ranlib'
......
......@@ -119,7 +119,7 @@ $(libffi_STAMP_CONFIGURE):
AR=$(AR) \
NM=$(NM) \
CFLAGS="$(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -w" \
LDFLAGS="$(SRC_LD_OPTS) $(CONF_LD_OPTS_STAGE1) -w" \
LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
"$(SHELL)" configure \
--enable-static=yes \
--enable-shared=$(libffi_EnableShared) \
......
......@@ -545,9 +545,12 @@ endif
CONF_CC_OPTS_STAGE0 = @CONF_CC_OPTS_STAGE0@
CONF_CC_OPTS_STAGE1 = @CONF_CC_OPTS_STAGE1@
CONF_CC_OPTS_STAGE2 = @CONF_CC_OPTS_STAGE2@
CONF_LD_OPTS_STAGE0 = @CONF_LD_OPTS_STAGE0@
CONF_LD_OPTS_STAGE1 = @CONF_LD_OPTS_STAGE1@
CONF_LD_OPTS_STAGE2 = @CONF_LD_OPTS_STAGE2@
CONF_GCC_LINKER_OPTS_STAGE0 = @CONF_GCC_LINKER_OPTS_STAGE0@
CONF_GCC_LINKER_OPTS_STAGE1 = @CONF_GCC_LINKER_OPTS_STAGE1@
CONF_GCC_LINKER_OPTS_STAGE2 = @CONF_GCC_LINKER_OPTS_STAGE2@
CONF_LD_LINKER_OPTS_STAGE0 = @CONF_LD_LINKER_OPTS_STAGE0@
CONF_LD_LINKER_OPTS_STAGE1 = @CONF_LD_LINKER_OPTS_STAGE1@
CONF_LD_LINKER_OPTS_STAGE2 = @CONF_LD_LINKER_OPTS_STAGE2@
CONF_CPP_OPTS_STAGE0 = @CONF_CPP_OPTS_STAGE0@
CONF_CPP_OPTS_STAGE1 = @CONF_CPP_OPTS_STAGE1@
CONF_CPP_OPTS_STAGE2 = @CONF_CPP_OPTS_STAGE2@
......
......@@ -40,7 +40,7 @@ endif
# for a feature it may not generate warning-free C code, and thus may
# think that the feature doesn't exist if -Werror is on.
$1_$2_CONFIGURE_OPTS += --configure-option=CFLAGS="$$(filter-out -Werror,$$(SRC_CC_OPTS)) $$(CONF_CC_OPTS_STAGE$3) $$($1_CC_OPTS) $$($1_$2_CC_OPTS)"
$1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$(SRC_LD_OPTS) $$(CONF_LD_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)"
$1_$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="$$(SRC_LD_OPTS) $$(CONF_GCC_LINKER_OPTS_STAGE$3) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)"
$1_$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="$$(SRC_CPP_OPTS) $$(CONF_CPP_OPTS_STAGE$3) $$($1_CPP_OPTS) $$($1_$2_CPP_OPTS)"
ifneq "$$(ICONV_INCLUDE_DIRS)" ""
......
......@@ -109,7 +109,7 @@ $1_$2_DIST_LD_LIB_DIRS:=$$(shell for i in $$($1_$2_DEP_LIB_DIRS); do echo \"-L$$
endif
$1_$2_DIST_LD_OPTS = \
$$(CONF_LD_OPTS_STAGE$4) \
$$(CONF_GCC_LINKER_OPTS_STAGE$4) \
$$(SRC_LD_OPTS) \
$$($1_LD_OPTS) \
$$($1_$2_LD_OPTS) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment