RFR: JDK-8323008: filter out any -std* flags added by autoconf from CC/CXX

Julian Waters jwaters at openjdk.org
Wed Jan 10 08:03:26 UTC 2024


On Wed, 10 Jan 2024 07:44:47 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> That might be a bit tricky, because on my macOS test machine, with a self compiled autoconf 2.72, I did not even get this strange behavior. But it was a different macOS version . So it seems to be a problem of very specific environment.

I see, that's unfortunate (and confusing). But such is the case with autoconf after all I suppose :)



> Can we set this somewhere in the OpenJDK m4 files, would be better for us than on the shell before configure.
> Should we set this in general , or do we want autoconf to add sometimes flags like these to CXX (or maybe CC) ?

I believe can be set in m4 files as well (though it may need quoting, not sure). It would need to go before AC_PROG_CC and AC_PROG_CXX, and I also made a mistake earlier, we would also need to set ac_prog_cxx_stdcxx as well, not only ac_prog_cc_stdc (ac_prog_cc_stdc is for C, ac_prog_cxx_stdcxx is for C++). Perhaps something like the following might work:


readonly ac_prog_cc_stdc=
readonly ac_prog_cxx_stdcxx=

#
# Setup the compilers (CC and CXX)
#
TOOLCHAIN_FIND_COMPILER([CC], [C], $TOOLCHAIN_CC_BINARY)
# Now that we have resolved CC ourself, let autoconf have its go at it
AC_PROG_CC([$CC])

TOOLCHAIN_FIND_COMPILER([CXX], [C++], $TOOLCHAIN_CXX_BINARY)
# Now that we have resolved CXX ourself, let autoconf have its go at it
AC_PROG_CXX([$CXX])


Setting ac_prog_cc_stdc and ac_prog_cxx_stdcxx to empty values should work too, since the test explicitly only does the check if the value is a literal no. The readonly is because in the compiled configure script both are set to no unconditionally. It doesn't have to explicitly be right before AC_PROG_CC or AC_PROG_CXX, but it has to appear in front of them (In practice, before TOOLCHAIN_DETECT_TOOLCHAIN_CORE). But I stress that this is only a band aid solution. I don't think we have ever relied on autoconf adding options to our CFLAGS and CXXFLAGS thus far, though to confirm you might have to ask Erik or Kim

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17301#issuecomment-1884357078


More information about the build-dev mailing list