>  | Correct, _LIBC_INTERNAL is not defined for tools/compat.
> 
> I wonder what the difference is between your environment, and
> a standard build on a NetBSD host.
> 
>  | MD2Transform() must be defined for MD2Update() in lib/libc/hash/md2/md2.c.
> 
> Yes, that I understand.
> 
> Try the following patch to src/tools/compat/md2.h and see if that helps
> (though I think there should be a better way).
> 
> kre
> 
> Index: md2.h
> ===================================================================
> RCS file: /cvsroot/src/tools/compat/md2.h,v
> retrieving revision 1.2
> diff -u -r1.2 md2.h
> --- md2.h 27 Oct 2003 00:12:43 -0000 1.2
> +++ md2.h 25 Jan 2024 19:59:10 -0000
> @@ -1,5 +1,8 @@
> /* $NetBSD: md2.h,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
> 
> /* We unconditionally use the NetBSD MD2 in libnbcompat. */
> +#ifndef _LIBC_INTERNAL
> +#define _LIBC_INTERNAL
> +#endif
> #include "nbtool_config.h"
> #include "../../include/md2.h"

The above is a hack. IMHO my fix is a cleaner one.

Anyway, the problem seems to be related to Clang, which in my case is the 
native compiler. It doesn't accept implicit function declarations. Consider the 
following example:

-----
// file zz.c
void MD2Update() {
  MD2Transform();
}

void MD2Transform() {
}
-----


% clang -std=c89 -c zz.c
zz.c:5:6: error: conflicting types for 'MD2Transform'
    5 | void MD2Transform() {
      |      ^
zz.c:2:3: note: previous implicit declaration is here
    2 |   MD2Transform();
      |   ^
1 error generated.


% clang -std=gnu99 -c zz.c
zz.c:2:3: error: call to undeclared function 'MD2Transform'; ISO C99 and later 
do not support implicit function declarations [-Wimplicit-function-declaration]
    2 |   MD2Transform();
      |   ^
zz.c:5:6: error: conflicting types for 'MD2Transform'
    5 | void MD2Transform() {
      |      ^
zz.c:2:3: note: previous implicit declaration is here
    2 |   MD2Transform();
      |   ^
2 errors generated.


% gcc -c zz.c
zz.c:5:6: warning: conflicting types for 'MD2Transform'; have 'void()'
    5 | void MD2Transform() {
      |      ^~~~~~~~~~~~
zz.c:2:3: note: previous implicit declaration of 'MD2Transform' with type 
'void()'
    2 |   MD2Transform();
      |   ^~~~~~~~~~~~


Of course it will fail with -Werror. And my guess it the release engineering 
builds are using NOGCCERROR=yes, as the warning shows up in the logs, like here 
http://releng.netbsd.org/builds/HEAD/202401252350Z/evbarm-aarch64.build (or any 
other architecture):

/home/source/ab/HEAD/src/tools/compat/../../lib/libc/hash/md2/md2.c: In 
function 'MD2Update':
/home/source/ab/HEAD/src/tools/compat/../../lib/libc/hash/md2/md2.c:130:4: 
warning: implicit declaration of function 'MD2Transform' 
[-Wimplicit-function-declaration]
MD2Transform(context); /* resets i */
^~~~~~~~~~~~
/home/source/ab/HEAD/src/tools/compat/../../lib/libc/hash/md2/md2.c: At top 
level:
/home/source/ab/HEAD/src/tools/compat/../../lib/libc/hash/md2/md2.c:163:1: 
warning: conflicting types for 'MD2Transform'
MD2Transform(MD2_CTX *context)
^~~~~~~~~~~~
/home/source/ab/HEAD/src/tools/compat/../../lib/libc/hash/md2/md2.c:130:4: 
note: previous implicit declaration of 'MD2Transform' was here
MD2Transform(context); /* resets i */
^~~~~~~~~~~~

Reply via email to