On Wed, Jul 16, 2025 at 3:48 PM John Ericson <John.Ericson@obsidian.systems> wrote: > > From: John Ericson <g...@johnericson.me> > > My goal is to be able to build libgcc cleanly in isolation --- today one > needs to figure `make ...` misc things in the gcc subdir. > > Following Andrew Pinski's suggestions in > https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, this > commit moves the NO_PIE_CFLAGS logic. > > gcc/ChangeLog: > > * Makefile.in: Remove NO_PIE_CFLAGS logic, since it is now in > libgcc. > * configure.ac: Delete --enable-default-pie, because it no > longer serves a purpose and would be dead code.
Actually you can't remove this part of the code. Since it defines ENABLE_DEFAULT_PIE in config.in if --enable-default-pie is passed and there is a check in gcc.cc that is defined or not. [apinski@xeond2 gcc]$ git grep ENABLE_DEFAULT_PIE gcc.cc gcc.cc:#ifdef ENABLE_DEFAULT_PIE gcc.cc:#ifdef ENABLE_DEFAULT_PIE So NAK. Thanks, Andrew Pinski > > libgcc/ChangeLog: > > * Makefile.in: Define NO_PIE_CFLAGS make variable via autoconf > substitution. > * configure.ac: New configure check to define NO_PIE_CFLAGS > using the algorithm Andrew asked for in the linked mail. > > Suggested-by: Andrew Pinski <quic_apin...@quicinc.com> > --- > gcc/Makefile.in | 6 ------ > gcc/configure.ac | 12 ------------ > libgcc/Makefile.in | 2 ++ > libgcc/configure.ac | 14 ++++++++++++++ > 4 files changed, 16 insertions(+), 18 deletions(-) > > diff --git a/gcc/Makefile.in b/gcc/Makefile.in > index 55b4cd7dbed..71d5dfb2ee9 100644 > --- a/gcc/Makefile.in > +++ b/gcc/Makefile.in > @@ -2464,12 +2464,6 @@ libgcc.mvars: config.status Makefile specs > xgcc$(exeext) > echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars > echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> > tmp-libgcc.mvars > echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars > - if test @enable_default_pie@ = yes; then \ > - NO_PIE_CFLAGS="-fno-PIE"; \ > - else \ > - NO_PIE_CFLAGS=; \ > - fi; \ > - echo NO_PIE_CFLAGS = "$$NO_PIE_CFLAGS" >> tmp-libgcc.mvars > > mv tmp-libgcc.mvars libgcc.mvars > > diff --git a/gcc/configure.ac b/gcc/configure.ac > index 9f67e62950a..fd7d05d73e2 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -7755,18 +7755,6 @@ else > fi > AC_SUBST([libgccjit_version]) > > -# Check whether --enable-default-pie was given. > -AC_ARG_ENABLE(default-pie, > -[AS_HELP_STRING([--enable-default-pie], > - [enable Position Independent Executable as default])], > -enable_default_pie=$enableval, > -enable_default_pie=no) > -if test x$enable_default_pie = xyes ; then > - AC_DEFINE(ENABLE_DEFAULT_PIE, 1, > - [Define if your target supports default PIE and it is enabled.]) > -fi > -AC_SUBST([enable_default_pie]) > - > # Check if -fno-PIE works. > AC_CACHE_CHECK([for -fno-PIE option], > [gcc_cv_c_no_fpie], > diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in > index 0719fd0615d..12124d4a065 100644 > --- a/libgcc/Makefile.in > +++ b/libgcc/Makefile.in > @@ -298,6 +298,8 @@ override CFLAGS := $(filter-out -fprofile-generate > -fprofile-use,$(CFLAGS)) > INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \ > $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@ > > +NO_PIE_CFLAGS = @NO_PIE_CFLAGS@ > + > # Options to use when compiling crtbegin/end. > CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ > $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \ > diff --git a/libgcc/configure.ac b/libgcc/configure.ac > index 85e4f1bc48b..bc084e0c2a3 100644 > --- a/libgcc/configure.ac > +++ b/libgcc/configure.ac > @@ -258,6 +258,20 @@ AC_CACHE_CHECK([whether fixed-point is supported], > [libgcc_cv_fixed_point], > fixed_point=$libgcc_cv_fixed_point > AC_SUBST(fixed_point) > > +# Check whether the compiler defines __PIE__ by default, so -fno-PIE is > needed. > +AC_CACHE_CHECK([whether the compiler defines __PIE__], > [libgcc_cv_no_pie_cflags], > + [AC_COMPILE_IFELSE( > + [AC_LANG_PROGRAM([[ > +#ifdef __PIE__ > +#error __PIE__ defined > +#endif > + ]], [[]])], > + [libgcc_cv_no_pie_cflags=''], > + [libgcc_cv_no_pie_cflags='-fno-PIE'])]) > + > +NO_PIE_CFLAGS=$libgcc_cv_no_pie_cflags > +AC_SUBST([NO_PIE_CFLAGS]) > + > # For platforms with the unwind ABI which includes an unwind library, > # libunwind, we can choose to use the system libunwind. > # config.gcc also contains tests of with_system_libunwind. > -- > 2.47.2 >