2020-12-15 01:30:00 +08:00
|
|
|
# Configure script for c++tools
|
2024-01-03 19:19:35 +08:00
|
|
|
# Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
2020-12-15 01:30:00 +08:00
|
|
|
# Written by Nathan Sidwell <nathan@acm.org> while at FaceBook
|
|
|
|
#
|
|
|
|
# This file is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; see the file COPYING3. If not see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# C++ has grown a C++20 mapper server. This may be used to provide
|
|
|
|
# and/or learn and/or build required modules. This sample server
|
|
|
|
# shows how the protocol introduced by wg21.link/p1184 may be used.
|
|
|
|
# By default g++ uses an in-process mapper.
|
|
|
|
|
|
|
|
sinclude(../config/acx.m4)
|
|
|
|
|
|
|
|
AC_INIT(c++tools)
|
|
|
|
|
|
|
|
AC_CONFIG_SRCDIR([server.cc])
|
|
|
|
|
|
|
|
# Determine the noncanonical names used for directories.
|
|
|
|
ACX_NONCANONICAL_TARGET
|
|
|
|
|
|
|
|
AC_CANONICAL_SYSTEM
|
|
|
|
AC_PROG_INSTALL
|
2020-12-17 03:44:42 +08:00
|
|
|
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
|
|
|
|
AC_SUBST(INSTALL_PROGRAM)
|
2020-12-15 01:30:00 +08:00
|
|
|
|
|
|
|
AC_PROG_CXX
|
|
|
|
MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
|
|
|
|
AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
|
|
|
|
AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
|
|
|
|
|
2021-07-20 21:00:38 +08:00
|
|
|
AC_LANG(C++)
|
|
|
|
|
2020-12-15 01:30:00 +08:00
|
|
|
dnl Enabled by default
|
|
|
|
AC_MSG_CHECKING([whether to build C++ tools])
|
|
|
|
AC_ARG_ENABLE(c++-tools,
|
|
|
|
[AS_HELP_STRING([--enable-c++-tools],
|
|
|
|
[build auxiliary c++ tools])],
|
|
|
|
cxx_aux_tools=$enableval,
|
|
|
|
cxx_aux_tools=yes)
|
|
|
|
|
|
|
|
AC_MSG_RESULT($cxx_aux_tools)
|
|
|
|
CXX_AUX_TOOLS="$cxx_aux_tools"
|
|
|
|
AC_SUBST(CXX_AUX_TOOLS)
|
|
|
|
|
|
|
|
AC_ARG_ENABLE([maintainer-mode],
|
|
|
|
AS_HELP_STRING([--enable-maintainer-mode],
|
|
|
|
[enable maintainer mode. Add rules to rebuild configurey bits]),,
|
|
|
|
[enable_maintainer_mode=no])
|
|
|
|
case "$enable_maintainer_mode" in
|
2021-05-25 18:12:08 +08:00
|
|
|
yes) maintainer_mode=yes ;;
|
|
|
|
no) maintainer_mode=no ;;
|
|
|
|
*) AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode]) ;;
|
2020-12-15 01:30:00 +08:00
|
|
|
esac
|
|
|
|
AC_MSG_CHECKING([maintainer-mode])
|
|
|
|
AC_MSG_RESULT([$maintainer_mode])
|
|
|
|
test "$maintainer_mode" = yes && MAINTAINER=yes
|
|
|
|
AC_SUBST(MAINTAINER)
|
|
|
|
|
2021-07-20 21:00:38 +08:00
|
|
|
# Handle configuration of checking; for the tools in this directory we
|
|
|
|
# default to release checking and stricter checks do not change this.
|
|
|
|
|
|
|
|
AC_ARG_ENABLE(checking,
|
|
|
|
[AS_HELP_STRING([[--enable-checking[=LIST]]],
|
|
|
|
[enable expensive run-time checks. With LIST,
|
|
|
|
enable only specific categories of checks.
|
|
|
|
Categories are: yes,no,all,none,release.])],
|
|
|
|
[ac_checking_flags="${enableval}"],[
|
|
|
|
# Default to checking.
|
|
|
|
ac_checking_flags=yes
|
|
|
|
])
|
|
|
|
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
|
|
|
|
for check in release $ac_checking_flags
|
|
|
|
do
|
|
|
|
case $check in
|
|
|
|
# these set all the flags to specific states
|
|
|
|
yes|all|release|assert) ac_assert_checking=1 ; ;;
|
|
|
|
no|none) ac_assert_checking= ; ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
IFS="$ac_save_IFS"
|
|
|
|
|
|
|
|
if test x$ac_assert_checking != x ; then
|
|
|
|
AC_DEFINE(ENABLE_ASSERT_CHECKING, 1,
|
|
|
|
[Define if you want assertions enabled. This is a cheap check.])
|
|
|
|
fi
|
|
|
|
|
2020-12-23 20:50:00 +08:00
|
|
|
# Check whether --enable-default-pie was given.
|
|
|
|
AC_ARG_ENABLE(default-pie,
|
|
|
|
[AS_HELP_STRING([--enable-default-pie],
|
|
|
|
[enable Position Independent Executable as default])],
|
configure: Implement --enable-host-pie
[ This is my third attempt to add this configure option. The first
version was approved but it came too late in the development cycle.
The second version was also approved, but I had to revert it:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer
need to touch Makefile.def, so this patch is simplified. ]
This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE. This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.
It is similar to the option --enable-host-shared, except that --e-h-s
won't add -shared to the linker flags whereas --e-h-p will add -pie.
It is different from --enable-default-pie because that option just
adds an implicit -fPIE/-pie when the compiler is invoked, but the
compiler itself isn't PIE.
Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
regressions.
When building the compiler, the build process may use various in-tree
libraries; these need to be built with -fPIE so that it's possible to
use them when building a PIE. For instance, when --with-included-gettext
is in effect, intl object files must be compiled with -fPIE. Similarly,
when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
-fPIE.
With this patch and --enable-host-pie used to configure gcc:
$ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1
gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped
I plan to add an option to link with -Wl,-z,now.
Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
--enable-host-pie as well as without --enable-host-pie. Also tested
on a Debian system where the system gcc was configured with
--enable-default-pie.
Co-Authored by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:
* configure.ac (--enable-host-pie): New check. Set PICFLAG after this
check.
* configure: Regenerate.
c++tools/ChangeLog:
* Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
Use pic/libiberty.a if PICFLAG is set.
* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
(--enable-host-pie): New check.
* configure: Regenerate.
fixincludes/ChangeLog:
* Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
build of libiberty if PICFLAG is set.
* configure.ac:
* configure: Regenerate.
gcc/ChangeLog:
* Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
* doc/install.texi: Document --enable-host-pie.
gcc/ada/ChangeLog:
* gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add
PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o.
* gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set.
Remove NO_PIE_FLAG.
gcc/m2/ChangeLog:
* Make-lang.in: New var, GM2_PICFLAGS. Use it.
gcc/d/ChangeLog:
* Make-lang.in: Remove NO_PIE_CFLAGS.
intl/ChangeLog:
* Makefile.in: Use @PICFLAG@ in COMPILE as well.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libcody/ChangeLog:
* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
libcpp/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libdecnumber/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libiberty/ChangeLog:
* configure.ac: Also set shared when enable_host_pie.
* configure: Regenerate.
zlib/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
2023-05-04 05:06:13 +08:00
|
|
|
[PICFLAG=-fPIE], [PICFLAG=])
|
|
|
|
|
|
|
|
# Enable --enable-host-pie
|
|
|
|
AC_ARG_ENABLE(host-pie,
|
|
|
|
[AS_HELP_STRING([--enable-host-pie],
|
|
|
|
[build host code as PIE])],
|
|
|
|
[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
|
|
|
|
AC_SUBST(PICFLAG)
|
configure: Implement --enable-host-bind-now
As promised in the --enable-host-pie patch, this patch adds another
configure option, --enable-host-bind-now, which adds -z now when linking
the compiler executables in order to extend hardening. BIND_NOW with RELRO
allows the GOT to be marked RO; this prevents GOT modification attacks.
This option does not affect linking of target libraries; you can use
LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now to enable RELRO/BIND_NOW.
With this patch:
$ readelf -Wd cc1{,plus,obj,gm2} f951 lto1 cpp rust1 gnat1 | grep FLAGS
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
c++tools/ChangeLog:
* configure.ac (--enable-host-bind-now): New check.
* configure: Regenerate.
gcc/ChangeLog:
* configure.ac (--enable-host-bind-now): New check. Add
-Wl,-z,now to LD_PICFLAG if --enable-host-bind-now.
* configure: Regenerate.
* doc/install.texi: Document --enable-host-bind-now.
lto-plugin/ChangeLog:
* configure.ac (--enable-host-bind-now): New check. Link with
-z,now.
* configure: Regenerate.
2023-06-22 23:30:01 +08:00
|
|
|
|
|
|
|
# Enable --enable-host-bind-now
|
|
|
|
AC_ARG_ENABLE(host-bind-now,
|
|
|
|
[AS_HELP_STRING([--enable-host-bind-now],
|
|
|
|
[link host code as BIND_NOW])],
|
|
|
|
[LD_PICFLAG="$LD_PICFLAG -Wl,-z,now"], [])
|
|
|
|
AC_SUBST(enable_host_bind_now)
|
configure: Implement --enable-host-pie
[ This is my third attempt to add this configure option. The first
version was approved but it came too late in the development cycle.
The second version was also approved, but I had to revert it:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer
need to touch Makefile.def, so this patch is simplified. ]
This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE. This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.
It is similar to the option --enable-host-shared, except that --e-h-s
won't add -shared to the linker flags whereas --e-h-p will add -pie.
It is different from --enable-default-pie because that option just
adds an implicit -fPIE/-pie when the compiler is invoked, but the
compiler itself isn't PIE.
Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
regressions.
When building the compiler, the build process may use various in-tree
libraries; these need to be built with -fPIE so that it's possible to
use them when building a PIE. For instance, when --with-included-gettext
is in effect, intl object files must be compiled with -fPIE. Similarly,
when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
-fPIE.
With this patch and --enable-host-pie used to configure gcc:
$ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1
gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped
I plan to add an option to link with -Wl,-z,now.
Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
--enable-host-pie as well as without --enable-host-pie. Also tested
on a Debian system where the system gcc was configured with
--enable-default-pie.
Co-Authored by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:
* configure.ac (--enable-host-pie): New check. Set PICFLAG after this
check.
* configure: Regenerate.
c++tools/ChangeLog:
* Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
Use pic/libiberty.a if PICFLAG is set.
* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
(--enable-host-pie): New check.
* configure: Regenerate.
fixincludes/ChangeLog:
* Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
build of libiberty if PICFLAG is set.
* configure.ac:
* configure: Regenerate.
gcc/ChangeLog:
* Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
* doc/install.texi: Document --enable-host-pie.
gcc/ada/ChangeLog:
* gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add
PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o.
* gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set.
Remove NO_PIE_FLAG.
gcc/m2/ChangeLog:
* Make-lang.in: New var, GM2_PICFLAGS. Use it.
gcc/d/ChangeLog:
* Make-lang.in: Remove NO_PIE_CFLAGS.
intl/ChangeLog:
* Makefile.in: Use @PICFLAG@ in COMPILE as well.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libcody/ChangeLog:
* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
libcpp/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libdecnumber/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libiberty/ChangeLog:
* configure.ac: Also set shared when enable_host_pie.
* configure: Regenerate.
zlib/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
2023-05-04 05:06:13 +08:00
|
|
|
AC_SUBST(LD_PICFLAG)
|
2020-12-23 20:50:00 +08:00
|
|
|
|
2020-12-15 01:30:00 +08:00
|
|
|
# Check if O_CLOEXEC is defined by fcntl
|
|
|
|
AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <fcntl.h>]], [[
|
|
|
|
return open ("/dev/null", O_RDONLY | O_CLOEXEC);]])],
|
|
|
|
[ac_cv_o_cloexec=yes],[ac_cv_o_cloexec=no])])
|
|
|
|
if test $ac_cv_o_cloexec = yes; then
|
|
|
|
AC_DEFINE(HOST_HAS_O_CLOEXEC, 1,
|
|
|
|
[Define if O_CLOEXEC supported by fcntl.])
|
|
|
|
fi
|
|
|
|
|
2020-12-17 21:57:13 +08:00
|
|
|
AC_CHECK_HEADERS(sys/mman.h)
|
|
|
|
|
2020-12-15 01:30:00 +08:00
|
|
|
# C++ Modules would like some networking features to provide the mapping
|
|
|
|
# server. You can still use modules without them though.
|
|
|
|
# The following network-related checks could probably do with some
|
|
|
|
# Windows and other non-linux defenses and checking.
|
|
|
|
|
|
|
|
# Local socket connectivity wants AF_UNIX networking
|
|
|
|
# Check for AF_UNIX networking
|
|
|
|
AC_CACHE_CHECK(for AF_UNIX, ac_cv_af_unix, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <netinet/in.h>]],[[
|
|
|
|
sockaddr_un un;
|
|
|
|
un.sun_family = AF_UNSPEC;
|
|
|
|
int fd = socket (AF_UNIX, SOCK_STREAM, 0);
|
|
|
|
connect (fd, (sockaddr *)&un, sizeof (un));]])],
|
|
|
|
[ac_cv_af_unix=yes],
|
|
|
|
[ac_cv_af_unix=no])])
|
|
|
|
if test $ac_cv_af_unix = yes; then
|
|
|
|
AC_DEFINE(HAVE_AF_UNIX, 1,
|
|
|
|
[Define if AF_UNIX supported.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remote socket connectivity wants AF_INET6 networking
|
|
|
|
# Check for AF_INET6 networking
|
|
|
|
AC_CACHE_CHECK(for AF_INET6, ac_cv_af_inet6, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>]],[[
|
|
|
|
sockaddr_in6 in6;
|
|
|
|
in6.sin6_family = AF_UNSPEC;
|
|
|
|
struct addrinfo *addrs = 0;
|
|
|
|
struct addrinfo hints;
|
|
|
|
hints.ai_flags = 0;
|
|
|
|
hints.ai_family = AF_INET6;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_protocol = 0;
|
|
|
|
hints.ai_canonname = 0;
|
|
|
|
hints.ai_addr = 0;
|
|
|
|
hints.ai_next = 0;
|
|
|
|
int e = getaddrinfo ("localhost", 0, &hints, &addrs);
|
|
|
|
const char *str = gai_strerror (e);
|
|
|
|
freeaddrinfo (addrs);
|
|
|
|
int fd = socket (AF_INET6, SOCK_STREAM, 0);
|
|
|
|
connect (fd, (sockaddr *)&in6, sizeof (in6));]])],
|
|
|
|
[ac_cv_af_inet6=yes],
|
|
|
|
[ac_cv_af_inet6=no])])
|
|
|
|
if test $ac_cv_af_inet6 = yes; then
|
|
|
|
AC_DEFINE(HAVE_AF_INET6, 1,
|
|
|
|
[Define if AF_INET6 supported.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Efficient server response wants epoll
|
|
|
|
# Check for epoll_create, epoll_ctl, epoll_pwait
|
|
|
|
AC_CACHE_CHECK(for epoll, ac_cv_epoll, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/epoll.h>]],[[
|
|
|
|
int fd = epoll_create (1);
|
|
|
|
epoll_event ev;
|
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = 0;
|
|
|
|
epoll_ctl (fd, EPOLL_CTL_ADD, 0, &ev);
|
|
|
|
epoll_pwait (fd, 0, 0, -1, 0);]])],
|
|
|
|
[ac_cv_epoll=yes],
|
|
|
|
[ac_cv_epoll=no])])
|
|
|
|
if test $ac_cv_epoll = yes; then
|
|
|
|
AC_DEFINE(HAVE_EPOLL, 1,
|
|
|
|
[Define if epoll_create, epoll_ctl, epoll_pwait provided.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we can't use epoll, try pselect.
|
|
|
|
# Check for pselect
|
|
|
|
AC_CACHE_CHECK(for pselect, ac_cv_pselect, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/select.h>]],[[
|
|
|
|
pselect (0, 0, 0, 0, 0, 0);]])],
|
|
|
|
[ac_cv_pselect=yes],
|
|
|
|
[ac_cv_pselect=no])])
|
|
|
|
if test $ac_cv_pselect = yes; then
|
|
|
|
AC_DEFINE(HAVE_PSELECT, 1,
|
|
|
|
[Define if pselect provided.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# And failing that, use good old select.
|
|
|
|
# If we can't even use this, the server is serialized.
|
|
|
|
# Check for select
|
|
|
|
AC_CACHE_CHECK(for select, ac_cv_select, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/select.h>]],[[
|
|
|
|
select (0, 0, 0, 0, 0);]])],
|
|
|
|
[ac_cv_select=yes],
|
|
|
|
[ac_cv_select=no])])
|
|
|
|
if test $ac_cv_select = yes; then
|
|
|
|
AC_DEFINE(HAVE_SELECT, 1,
|
|
|
|
[Define if select provided.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Avoid some fnctl calls by using accept4, when available.
|
|
|
|
# Check for accept4
|
|
|
|
AC_CACHE_CHECK(for accept4, ac_cv_accept4, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <sys/socket.h>]],[[
|
|
|
|
int err = accept4 (1, 0, 0, SOCK_NONBLOCK);]])],
|
|
|
|
[ac_cv_accept4=yes],
|
|
|
|
[ac_cv_accept4=no])])
|
|
|
|
if test $ac_cv_accept4 = yes; then
|
|
|
|
AC_DEFINE(HAVE_ACCEPT4, 1,
|
|
|
|
[Define if accept4 provided.])
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For better server messages, look for a way to stringize network addresses
|
|
|
|
# Check for inet_ntop
|
|
|
|
AC_CACHE_CHECK(for inet_ntop, ac_cv_inet_ntop, [
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netinet/in.h>]],[[
|
|
|
|
sockaddr_in6 in6;
|
|
|
|
char buf[INET6_ADDRSTRLEN];
|
|
|
|
const char *str = inet_ntop (AF_INET6, &in6, buf, sizeof (buf));]])],
|
|
|
|
[ac_cv_inet_ntop=yes],
|
|
|
|
[ac_cv_inet_ntop=no])])
|
|
|
|
if test $ac_cv_inet_ntop = yes; then
|
|
|
|
AC_DEFINE(HAVE_INET_NTOP, 1,
|
|
|
|
[Define if inet_ntop provided.])
|
|
|
|
fi
|
|
|
|
|
2020-12-17 21:31:05 +08:00
|
|
|
# Determine what GCC version number to use in filesystem paths.
|
|
|
|
GCC_BASE_VER
|
|
|
|
|
2020-12-15 01:30:00 +08:00
|
|
|
AC_CONFIG_HEADERS([config.h])
|
|
|
|
AC_CONFIG_FILES([Makefile])
|
|
|
|
|
|
|
|
AC_OUTPUT
|