Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-27 Thread Detlef Riekenberg
> > On 24/9/23 11:03, Nick Bowler wrote:
> >> The word AC_CHECK_DEFINE is not found anywhere in the Autoconf
> >> source code or documentation.
> >
> > My guess would be that the 3rd party is the autoconf archive because
> > they provide both AX_CHECK_DEFINE and AC_CHECK_DEFINE
> >
> > http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_check_define.m4
>
> OK, I see.

Thanks Peter.
I can confirm, the "autoconf-archive" - Package is installed here.


> Ignoring the fact that the this macro definition flagrantly disregards
> the Autoconf reserved namespace...

That trap catched me.

> AC_CHECK_DEFINE here is quoting
> inconsistently: $1 is double-quoted in the argument to AC_LANG_PROGRAM,
> but it is only single-quoted in the arguments of AS_VAR_PUSHDEF and
> AC_CACHE_CHECK.

Oh, thanks for the in deepth analysis.
I will check to see, how and where i can report this bug.

> So no amount of quoting at the call site will ever solve the problem for 
> Detlef.

The suggested workarounds should help.

> We can quote __unix__ correctly for AC_LANG_PROGRAM, or we can
> quote it for the other expansions, but never both at the same time.

>  For example:
>  AC_CHECK_DEFINE([__unix@@__], [...])

>   m4_ifdef([__unix__], [m4_define([__unix__], [[__unix__]])])dnl
>   AC_CHECK_DEFINE([__unix__], [...])

I will try your suggested workarounds.

> I don't think there is any regression in Autoconf here, I don't see any
> significant difference in behaviour between Autoconf 2.72c, 2.71 or
> 2.69.

I was not sure, where the bug belongs, and with the "AC_" prefix, i started 
here.

--
Regards ... Detlef


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-27 Thread Detlef Riekenberg
Thanks Nick and Peter for your analysis.

Yes, the "AC_" prefix fooled me, that AC_CHECK_DEFINE belongs to autoconf.


> On 2023-09-23, Nick Bowler  wrote:
> > On 2023-09-23, Detlef Riekenberg  wrote:
> >> AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
> >> AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
> >> AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")
> [...]
> > So it sounds like there must be some third party code involved which
> > is defining this macro (and this code is defining macros in the AC_*
> > namespace to make it look like it came from Autoconf when in fact it
> > did not).

I can confirm, that i have the "autoconf-archive" package insalled.
The installed "/usr/share/aclocal/ax_check_define.m4"
contains AC_CHECK_DEFINE and AX_CHECK_DEFINE

> Just to add, you don't need any third party macros to check for typical
> C predefined macros including __unix, etc.  I would write such checks
> something like this (untested):
>
>   AC_COMPUTE_INT([unix_val], [__unix], [@@], [unix_val=0])
>   AS_IF([test $unix_val -ne 0],
> [put code here to run when __unix is defined and is non-zero])

Learned something new. Thanks
The magic "[@@]" is really strange.

> Hope that helps,

Sure.
Thanks


--
Regards ... Detlef


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-25 Thread Nick Bowler
On 24/09/2023, Peter Johansson  wrote:
> Hi Detlef and Nick,
>
> On 24/9/23 11:03, Nick Bowler wrote:
>> The word AC_CHECK_DEFINE is not found anywhere in the Autoconf
>> source code or documentation.
>
> My guess would be that the 3rd party is the autoconf archive because
> they provide both AX_CHECK_DEFINE and AC_CHECK_DEFINE
>
> http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_check_define.m4

OK, I see.

So, depending on the system you are running Autoconf on, GNU m4 may pre-
define __unix__ as an m4 macro which expands to the empty string.

Ignoring the fact that the this macro definition flagrantly disregards
the Autoconf reserved namespace... AC_CHECK_DEFINE here is quoting
inconsistently: $1 is double-quoted in the argument to AC_LANG_PROGRAM,
but it is only single-quoted in the arguments of AS_VAR_PUSHDEF and
AC_CACHE_CHECK.

So no amount of quoting at the call site will ever solve the problem for
Detlef.  We can quote __unix__ correctly for AC_LANG_PROGRAM, or we can
quote it for the other expansions, but never both at the same time.

If unwilling to fix the quoting issues within AC_CHECK_DEFINE, one way
to work around the problem is by using a quadrigraph to prevent __unix__
from being recognized as a macro, since quadrigraphs are removed only
after all macro processing is complete.  For example:

  AC_CHECK_DEFINE([__unix@@__], [...])

Another option is to redefine __unix__ as this GNU m4 feature seems
pretty unlikely to be useful in Autoconf, and even then it seems
unlikely to matter exactly what text __unix__ expands to:

  m4_ifdef([__unix__], [m4_define([__unix__], [[__unix__]])])dnl
  AC_CHECK_DEFINE([__unix__], [...])

I don't think there is any regression in Autoconf here, I don't see any
significant difference in behaviour between Autoconf 2.72c, 2.71 or
2.69.

Hope that helps,
  Nick

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-24 Thread Nick Bowler
Hi,

On 2023-09-23, Detlef Riekenberg  wrote:
> During testing of tcc 0.9.28rc,
> I found a strange bug in autoconf 2.71 with `AC_CHECK_DEFINE` for
> `__unix__`.

The word AC_CHECK_DEFINE is not found anywhere in the Autoconf
source code or documentation.

So I am afraid it is a bit difficult to understand this report.

[snip]
> Please test this snipped with the current 2.72rc:
> ```
> AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
> AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
> AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")

As expected, if I translate this into an "obvious" configure.ac by
adding the mandatory AC_INIT and AC_OUTPUT expansions, I just get:

  configure.ac:3: error: possibly undefined macro: AC_CHECK_DEFINE
  [...]

So it sounds lkie there must be some third party code involved which
is defining this macro (and this code is defining macros in the AC_*
namespace to make it look like it came from Autoconf when in fact it
did not).

That doesn't mean there isn't a bug in Autoconf.  It would be helpful if
you could produce a complete self-contained test case which demonstrates
the problem, one that doesn't depend on code from outside of Autoconf
which we don't necessarily have.

Cheers,
  Nick

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-24 Thread Nick Bowler
On 2023-09-23, Nick Bowler  wrote:
> On 2023-09-23, Detlef Riekenberg  wrote:
>> AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
>> AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
>> AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")
[...]
> So it sounds like there must be some third party code involved which
> is defining this macro (and this code is defining macros in the AC_*
> namespace to make it look like it came from Autoconf when in fact it
> did not).

Just to add, you don't need any third party macros to check for typical
C predefined macros including __unix, etc.  I would write such checks
something like this (untested):

  AC_COMPUTE_INT([unix_val], [__unix], [@@], [unix_val=0])
  AS_IF([test $unix_val -ne 0],
[put code here to run when __unix is defined and is non-zero])

That works out of the box with Autoconf and should be a very robust
check.  The third argument to AC_COMPUTE_INT is @@ to prevent
Autoconf from inserting the default #includes in the test program.

If you need to distinguish the case where __unix may be pre-defined
with the value 0 (probably not relevant with this particular macro),
then you can tweak the action-if-failed (fourth argument) and if
condition a bit.

Hope that helps,
  Nick

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-24 Thread Peter Johansson

Hi Detlef and Nick,

On 24/9/23 11:03, Nick Bowler wrote:

The word AC_CHECK_DEFINE is not found anywhere in the Autoconf
source code or documentation.


My guess would be that the 3rd party is the autoconf archive because 
they provide both AX_CHECK_DEFINE and AC_CHECK_DEFINE


http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_check_define.m4


Cheers,

Peter


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] tcc 0.9.28rc testing: bug in autoconf 2.71 with AC_CHECK_DEFINE

2023-09-23 Thread Detlef Riekenberg
Hi autoconf team.

During testing of tcc 0.9.28rc,
I found a strange bug in autoconf 2.71 with `AC_CHECK_DEFINE` for `__unix__`.
For comparsion, i added checks for "__unix" and "__linux__":

Overview:
* [__unix__] always found, but the log text is crippled
*  __unix__  never found and the log text is crippled
* The second check does not use the cached result from the first check

* When i duplicate the tests, the duplicate test used the cached result
  from the previous check, but all other failures remain.
  (1: first result: see above, 2: cached result from 1,
   3: different result: see above, 4: cached result from 3)


I am using tcc 0.9.28rc on linux
and gcc 12.3.0 produces the same results.


Please test this snipped with the current 2.72rc:
```
AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")

AC_CHECK_DEFINE([__unix], CFLAGS="-DFOUNDxx__unix $CFLAGS")
AC_CHECK_DEFINE([__unix__], CFLAGS="-DFOUNDxx__unix__ $CFLAGS")
AC_CHECK_DEFINE([__linux__], CFLAGS="-DFOUNDxx__linux__ $CFLAGS")
```

buggy results:
```
checking for __unix defined... yes
checking for  defined... no
checking for __linux__ defined... yes
checking for __unix defined... (cached) yes
checking for  defined... yes
checking for __linux__ defined... (cached) yes
```


And yes, when the checks are reordered, 
```
AC_CHECK_DEFINE([__unix], CFLAGS="-DFOUNDxx__unix $CFLAGS")
AC_CHECK_DEFINE([__unix__], CFLAGS="-DFOUNDxx__unix__ $CFLAGS")
AC_CHECK_DEFINE([__linux__], CFLAGS="-DFOUNDxx__linux__ $CFLAGS")

AC_CHECK_DEFINE(__unix, CFLAGS="-DFOUND__unix $CFLAGS")
AC_CHECK_DEFINE(__unix__, CFLAGS="-DFOUND__unix__ $CFLAGS")
AC_CHECK_DEFINE(__linux__, CFLAGS="-DFOUND__linux__ $CFLAGS")
```

... the results are different:

```
checking for __unix defined... yes
checking for  defined... yes
checking for __linux__ defined... yes
checking for __unix defined... (cached) yes
checking for  defined... no
checking for __linux__ defined... (cached) yes
```

* What is 2.72rc doing?
* Should i add a bug report for 2.71 to document this bug?


--
Bye bye ... Detlef


___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel