3 # Find which linker to use to merge object files.
5 # See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
8 AC_DEFUN([CHECK_MERGE_OBJECTS],[
9 AC_REQUIRE([FP_FIND_NM])
10 AC_MSG_NOTICE([Checking whether $MergeObjsCmd can merge objects])
11 echo 'int funA(int x) {return x;}' > conftesta.c
12 echo 'int funB(int x) {return x;}' > conftestb.c
13 "$CC" -c -o conftesta.o conftesta.c
14 "$CC" -c -o conftestb.o conftestb.c
15 $MergeObjsCmd $MergeObjsArgs conftesta.o conftestb.o -o conftestc.o || AC_MSG_ERROR([ $MergeObjsCmd could not merge objects ])
17 # Check the resulting object file has both functions.
18 "$NM" conftestc.o | grep funA > /dev/null 2>&1 || AC_MSG_ERROR([ $MergeObjsCmd could not merge objects ])
19 "$NM" conftestc.o | grep funB > /dev/null 2>&1 || AC_MSG_ERROR([ $MergeObjsCmd could not merge objects ])
21 rm -r conftest*.c conftest*.o
24 AC_DEFUN([FIND_MERGE_OBJECTS],[
27 if test -z ${MergeObjsCmd+x}; then
28 AC_MSG_NOTICE([Setting cmd])
31 if test -z ${MergeObjsArgs+x}; then
36 # If MergeObjsCmd="" then we assume that the user is explicitly telling us that
37 # they do not want to configure the MergeObjsCmd, this is particularly important for
38 # the bundled windows toolchain.
39 if test -z "$MergeObjsCmd"; then
40 AC_MSG_NOTICE([No command for merging objects as explicitly instructed by user])
43 # Check first that gold works
44 CHECK_FOR_GOLD_T22266($MergeObjsCmd)
45 if test "$result" = "1"; then
46 AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...])
48 AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld])
49 CHECK_FOR_GOLD_T22266($MergeObjsCmd)
50 if test "$result" = "1"; then
51 AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.])
56 # Now just check that merging objects works at all
61 AC_SUBST([MergeObjsCmd])
62 AC_SUBST([MergeObjsArgs])