x86 NCG: fix regUsageOfInstr for VMOVU & friends
[ghc.git] / m4 / check_for_gold_t22266.m4
blobe540eb928b6004bdd04df90c74fc3873b1db61b0
1 # CHECK_FOR_GOLD_T22266
2 # ----------------------
4 # Test for binutils #22266. This bug manifested as GHC bug #14328 (see also:
5 # #14675, #14291).
6 # Uses test from
7 # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=033bfb739b525703bfe23f151d09e9beee3a2afe
9 # $1 = linker to test
10 # Sets $result to 0 if not affected, 1 otherwise
11 AC_DEFUN([CHECK_FOR_GOLD_T22266],[
12     AC_MSG_CHECKING([for ld.gold object merging bug (binutils 22266)])
13     if ! $1 --version | grep -q "GNU gold" 2>/dev/null; then
14         # Not gold
15         result=0
16     elif test "$cross_compiling" = "yes"; then
17         AC_MSG_RESULT([cross-compiling, assuming LD can merge objects correctly.])
18         result=0
19     else
20         FPTOOLS_WRITE_FILE([conftest.a.c], [
21           __attribute__((section(".data.a")))
22           static int int_from_a_1 = 0x11223344;
24           __attribute__((section(".data.rel.ro.a")))
25           int *p_int_from_a_2 = &int_from_a_1;
27           const char *hello (void);
29           const char *
30           hello (void)
31           {
32             return "XXXHello, world!" + 3;
33           }
34         ])
36         FPTOOLS_WRITE_FILE([conftest.main.c], [
37           #include <stdlib.h>
38           #include <string.h>
40           extern int *p_int_from_a_2;
41           extern const char *hello (void);
43           int main (void) {
44             if (*p_int_from_a_2 != 0x11223344)
45               abort ();
46             if (strcmp(hello(), "Hello, world!") != 0)
47               abort ();
48             return 0;
49           }
50         ])
52         FPTOOLS_WRITE_FILE([conftest.t], [
53           SECTIONS
54           {
55               .text : {
56                   *(.text*)
57               }
58               .rodata :
59               {
60                   *(.rodata .rodata.* .gnu.linkonce.r.*)
61               }
62               .data.rel.ro : {
63                   *(.data.rel.ro*)
64               }
65               .data : {
66                   *(.data*)
67               }
68               .bss : {
69                   *(.bss*)
70               }
71           }
72         ])
74         $CC -c -o conftest.a.o conftest.a.c || AC_MSG_ERROR([Failed to compile test])
75         $MergeObjsCmd $MergeObjsArgs -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object])
77         $CC -c -o conftest.main.o conftest.main.c || AC_MSG_ERROR([Failed to compile test driver])
78         $CC conftest.ar.o conftest.main.o -o conftest || AC_MSG_ERROR([Failed to link test driver])
80         if ./conftest; then
81             AC_MSG_RESULT([not affected])
82             result=0
83         else
84             AC_MSG_RESULT([affected])
85             result=1
86         fi
87         rm -f conftest.a.o conftest.a.c  conttest.ar.o conftest.main.c conftest.main.o conftest
88     fi