FW: [PATCH v2 1/4] aarch64: add configure checks for BTI support

Yury Khrustalev yury.khrustalev@arm.com
Thu Nov 20 10:34:00 GMT 2025


Thanks Andreas and Bill!

On Sun, Nov 16, 2025 at 04:54:27AM -0600, Bill Roberts wrote:
> 
> On 11/19/25 3:15 PM, Bill Roberts wrote:
> > 
> > 
> > From: Andreas Schwab <schwab@suse.de>
> > Date: Wednesday, November 19, 2025 at 10:46 AM
> > To: Yury Khrustalev <Yury.Khrustalev@arm.com>
> > ...
> > Subject: Re: [PATCH v2 1/4] aarch64: add configure checks for BTI support
> 
> ...
> 
> > 
> > On Nov 19 2025, Yury Khrustalev wrote:
> >
> > ...
> >
> > > +AC_DEFUN([LIBC_CHECK_CC_MACRO],
> > > +[
> > > +AC_CACHE_CHECK([$1], $3, [dnl
> > > +  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -dM -E - < /dev/null | grep -wF "$2" 1>&AS_MESSAGE_LOG_FD])
> > > +  then
> > > +    [$4]
> > > +  else
> > > +    [$5]
> > > +  fi])
> > > +])
> > 
> > This should use AC_EGREP_CPP, and I don't think we need an extra macro
> > for that.
> 
> You can't, unfortunately, I learned this the painful way. These macros don't
> respect CFLAGS only CPPFLAGS.

I confirm that this is the case (although this fact is not documented in
[1] sadly). The recommended replacement AC_PREPROC_IFELSE uses only
CPPFLAGS too.

[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.72/html_node/Running-the-Preprocessor.html

> So there's a few ways to handle that:
> 1. You can add CFLAGS to CPPFLAGS and restore them after the check
> 2. Use AC_COMPILE_IFELSE
> 3. Run your own check as done here using $CC -E

The thing that we want to test for (-mbranch-protection=standard) would
normally go into CFLAGS because it is intended for the compiler not the
preprocessor, so using AC_EGREP_CPP or AC_PREPROC_IFELSE would require
an extra macro anyway.

Maybe I missed something, but AC_COMPILE_IFELSE in my tests does not
respond to CFLAGS as well.

So I think using the macro I proposed is the best option here?

Thanks,
Yury



More information about the Libc-alpha mailing list