PR tree-optimization/65709
[official-gcc.git] / config / picflag.m4
blob836523d67c965168571b668f4959b5e2242f3694
1 # _GCC_PICFLAG(FLAG, DISPATCH)
2 # ----------------------------
3 # Store PIC flag corresponding to DISPATCH triplet in FLAG.
4 # Explit use of -fpic in CFLAGS corresponding to FLAG overrides default.
5 AC_DEFUN([_GCC_PICFLAG], [
7 case "${$2}" in
8     # PIC is the default on some targets or must not be used.
9     *-*-darwin*)
10         # PIC is the default on this platform
11         # Common symbols not allowed in MH_DYLIB files
12         # Cancel any earlier -mdynamic-no-pic, as that makes
13         # the code not suitable for shared libraries.
14         $1='-fno-common -mno-dynamic-no-pic'
15         ;;
16     alpha*-dec-osf5*)
17         # PIC is the default.
18         ;;
19     hppa*64*-*-hpux*)
20         # PIC is the default for 64-bit PA HP-UX.
21         ;;
22     i[[34567]]86-*-cygwin* | x86_64-*-cygwin*)
23         ;;
24     i[[34567]]86-*-mingw* | x86_64-*-mingw*)
25         ;;
26     i[[34567]]86-*-interix[[3-9]]*)
27         # Interix 3.x gcc -fpic/-fPIC options generate broken code.
28         # Instead, we relocate shared libraries at runtime.
29         ;;
30     i[[34567]]86-*-nto-qnx*)
31         # QNX uses GNU C++, but need to define -shared option too, otherwise
32         # it will coredump.
33         $1='-fPIC -shared'
34         ;;
35     i[[34567]]86-pc-msdosdjgpp*)
36         # DJGPP does not support shared libraries at all.
37         ;;
38     ia64*-*-hpux*)
39         # On IA64 HP-UX, PIC is the default but the pic flag
40         # sets the default TLS model and affects inlining.
41         $1=-fPIC
42         ;;
43     mips-sgi-irix6*)
44         # PIC is the default.
45         ;;
46     rs6000-ibm-aix* | powerpc-ibm-aix*)
47         # All AIX code is PIC.
48         ;;
50     # Some targets support both -fPIC and -fpic, but prefer the latter.
51     # FIXME: Why?
52     i[[34567]]86-*-* | x86_64-*-*)
53         $1=-fpic
54         ;;
55     # FIXME: Override -fPIC default in libgcc only? 
56     sh-*-linux* | sh[[2346lbe]]*-*-linux*)
57         $1=-fpic
58         ;;
59     # FIXME: Simplify to sh*-*-netbsd*?
60     sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
61       sh64-*-netbsd* | sh64l*-*-netbsd*)
62         $1=-fpic
63         ;;
64     # Default to -fPIC unless specified otherwise.
65     *)
66         $1=-fPIC
67         ;;
68 esac
70 # If the user explicitly uses -fpic/-fPIC, keep that.
71 case "${m4_bpatsubsts($1, PICFLAG, CFLAGS)}" in
72     *-fpic*)
73         $1=-fpic
74         ;;
75     *-fPIC*)
76         $1=-fPIC
77         ;;
78 esac
81 # GCC_PICFLAG
82 # -----------
83 # Store host PIC flag in PICFLAG.
84 AC_DEFUN([GCC_PICFLAG], [
85   AC_REQUIRE([AC_CANONICAL_HOST])
86   _GCC_PICFLAG([PICFLAG], [host])])
88 # GCC_PICFLAG_FOR_TARGET
89 # ----------------------
90 # Store target PIC flag in PICFLAG_FOR_TARGET.
91 AC_DEFUN([GCC_PICFLAG_FOR_TARGET], [
92   AC_REQUIRE([AC_CANONICAL_TARGET])
93   _GCC_PICFLAG([PICFLAG_FOR_TARGET], [target])])