]>
Commit | Line | Data |
---|---|---|
d7f09764 | 1 | AC_INIT([LTO plugin for ld], 0.1,,[lto-plugin]) |
73d5e770 | 2 | AC_CANONICAL_SYSTEM |
d7f09764 | 3 | GCC_TOPLEV_SUBDIRS |
13917ae3 | 4 | AM_INIT_AUTOMAKE([foreign no-dist]) |
03428d41 | 5 | AM_MAINTAINER_MODE |
2a7a8388 TS |
6 | AC_ARG_WITH(libiberty, |
7 | [AS_HELP_STRING([--with-libiberty=PATH], | |
8 | [specify the directory where to find libiberty [../libiberty]])], | |
9 | [], with_libiberty=../libiberty) | |
10 | AC_SUBST(with_libiberty) | |
dcbc9df9 | 11 | AC_USE_SYSTEM_EXTENSIONS |
d7f09764 | 12 | AC_PROG_CC |
4c0f4b0b | 13 | AC_SYS_LARGEFILE |
f3016c47 | 14 | ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags]) |
a2555c65 RO |
15 | |
16 | # Check whether -static-libgcc is supported. | |
17 | saved_LDFLAGS="$LDFLAGS" | |
18 | LDFLAGS="$LDFLAGS -static-libgcc" | |
19 | AC_MSG_CHECKING([for -static-libgcc]) | |
22e05272 JM |
20 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
21 | int main() {}])], [have_static_libgcc=yes], [have_static_libgcc=no]) | |
a2555c65 RO |
22 | AC_MSG_RESULT($have_static_libgcc); |
23 | LDFLAGS="$saved_LDFLAGS" | |
5523efdf | 24 | # Need -Wc to get it through libtool. |
a2555c65 RO |
25 | if test "x$have_static_libgcc" = xyes; then |
26 | ac_lto_plugin_ldflags="-Wc,-static-libgcc" | |
27 | fi | |
33ebb0df MP |
28 | |
29 | # Enable --enable-host-bind-now | |
30 | AC_ARG_ENABLE(host-bind-now, | |
31 | [AS_HELP_STRING([--enable-host-bind-now], | |
32 | [link host code as BIND_NOW])]) | |
33 | AC_SUBST(enable_host_bind_now) | |
34 | ||
35 | if test x$enable_host_bind_now = xyes; then | |
36 | ac_lto_plugin_ldflags="$ac_lto_plugin_ldflags -Wl,-z,now" | |
37 | fi | |
38 | ||
5523efdf | 39 | AC_SUBST(ac_lto_plugin_ldflags) |
a2555c65 | 40 | |
8fc8bf80 L |
41 | GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) |
42 | AC_SUBST(CET_HOST_FLAGS) | |
43 | ||
43f4a446 L |
44 | if test x"$host_subdir" = x.; then |
45 | gcc_build_dir=../gcc | |
46 | else | |
47 | gcc_build_dir=../../$host_subdir/gcc | |
48 | fi | |
49 | AC_SUBST(gcc_build_dir) | |
50 | ||
85c64bbe BS |
51 | # Used for constructing correct paths for offload compilers. |
52 | accel_dir_suffix= | |
53 | real_target_noncanonical=${target_noncanonical} | |
54 | if test x"$enable_as_accelerator_for" != x; then | |
55 | accel_dir_suffix=/accel/${target_noncanonical} | |
56 | real_target_noncanonical=${enable_as_accelerator_for} | |
57 | fi | |
58 | AC_SUBST(accel_dir_suffix) | |
59 | AC_SUBST(real_target_noncanonical) | |
60 | ||
3c36aa6b JJ |
61 | # Determine what GCC version number to use in filesystem paths. |
62 | GCC_BASE_VER | |
63 | ||
6ee58926 JJ |
64 | AC_MSG_CHECKING([whether symbol versioning is supported]) |
65 | lto_plugin_use_symver=no | |
66 | if test x$gcc_no_link = xyes; then | |
67 | # If we cannot link, we cannot build shared libraries, so do not use | |
68 | # symbol versioning. | |
69 | lto_plugin_use_symver=no | |
70 | else | |
71 | save_LDFLAGS="$LDFLAGS" | |
72 | LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" | |
73 | cat > conftest.map <<EOF | |
74 | { | |
75 | global: *foo*; bar; local: *; | |
76 | }; | |
77 | EOF | |
78 | AC_TRY_LINK([int foo;],[],[lto_plugin_use_symver=gnu],[lto_plugin_use_symver=no]) | |
79 | if test x$lto_plugin_use_symver = xno; then | |
80 | case "$target_os" in | |
81 | solaris2*) | |
82 | LDFLAGS="$save_LDFLAGS" | |
83 | LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map" | |
84 | # Sun ld cannot handle wildcards and treats all entries as undefined. | |
85 | cat > conftest.map <<EOF | |
86 | { | |
87 | global: foo; local: *; | |
88 | }; | |
89 | EOF | |
90 | AC_TRY_LINK([int foo;],[],[lto_plugin_use_symver=sun],[lto_plugin_use_symver=no]) | |
91 | ;; | |
92 | esac | |
93 | fi | |
94 | LDFLAGS="$save_LDFLAGS" | |
95 | fi | |
96 | AC_MSG_RESULT($lto_plugin_use_symver) | |
97 | AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER, [test "x$lto_plugin_use_symver" != xno]) | |
98 | AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_GNU, [test "x$lto_plugin_use_symver" = xgnu]) | |
99 | AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun]) | |
100 | ||
2669cae0 | 101 | # Check for thread headers. |
d89fa97f | 102 | use_locking=no |
29f40a80 | 103 | ac_lto_plugin_extra_ldflags= |
d89fa97f | 104 | |
5d863720 | 105 | case $host in |
d89fa97f ML |
106 | riscv*) |
107 | # do not use locking as pthread depends on libatomic | |
108 | ;; | |
109 | *-linux*) | |
110 | use_locking=yes | |
111 | ;; | |
112 | esac | |
113 | ||
114 | if test x$use_locking = xyes; then | |
115 | AC_CHECK_HEADER(pthread.h, | |
116 | [AC_DEFINE(HAVE_PTHREAD_LOCKING, 1, [Define if the system provides pthread locking mechanism.])]) | |
29f40a80 ML |
117 | |
118 | ac_lto_plugin_extra_ldflags="-pthread" | |
d89fa97f | 119 | fi |
2669cae0 | 120 | |
29f40a80 ML |
121 | AC_SUBST(ac_lto_plugin_extra_ldflags) |
122 | ||
d7f09764 | 123 | AM_PROG_LIBTOOL |
7de6ba7a | 124 | ACX_LT_HOST_FLAGS |
d7f09764 | 125 | AC_SUBST(target_noncanonical) |
d19e0f01 | 126 | AC_TYPE_INT64_T |
21750c78 | 127 | AC_TYPE_UINT64_T |
ec692d5f | 128 | AC_HEADER_SYS_WAIT |
d7f09764 | 129 | AC_CONFIG_FILES(Makefile) |
48215350 | 130 | AC_CONFIG_HEADERS(config.h) |
d7f09764 | 131 | AC_OUTPUT |