bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Re: implicit declaration of function 'utime' in trailing slashes test
       [not found]   ` <48275C81-8FDA-4589-B05C-02E6DA08504F@ryandesign.com>
@ 2021-01-23 18:44     ` Tim Rühsen
  2021-01-23 21:22       ` Bruno Haible
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Rühsen @ 2021-01-23 18:44 UTC (permalink / raw)
  To: Ryan Schmidt; +Cc: bug-wget, bug-gnulib


[-- Attachment #1.1: Type: text/plain, Size: 4071 bytes --]



On 23.01.21 07:09, Ryan Schmidt wrote:
> On Jan 22, 2021, at 16:47, Tim Rühsen wrote:
> 
>> On 21.01.21 01:34, Ryan Schmidt wrote:
>>> Hi, I'm the maintainer of wget in MacPorts.
>>> In the version of clang included with Xcode 12 and later, implicit declaration of functions is an error.
>>> During configure, wget 1.12.1 prints this:
>>> checking whether utime handles trailing slashes on files... no
>>> config.log contains this:
>>> configure:49368: checking whether utime handles trailing slashes on files
>>> configure:49414: ccache /usr/bin/clang -o conftest -DNDEBUG -pipe -Os -Werror=implicit-function-declaration -arch x86_64 -I/opt/local/include -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 conftest.c  >&5
>>> conftest.c:491:23: error: implicit declaration of function 'utime' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
>>>                   if (!utime ("conftest.tmp/", NULL))
>>>                        ^
>>> 1 error generated.
>>> configure:49414: $? = 1
>>> configure: program exited with status 1
>>> So the results of this test don't represent what you want them to.
>>> This configure test uses #include <time.h>. The problem goes away if I change that to #include <utime.h>. Then configure output is still:
>>> checking whether utime handles trailing slashes on files... no
>>> but config.log then contains:
>>> configure:49368: checking whether utime handles trailing slashes on files
>>> configure:49414: ccache /usr/bin/clang -o conftest -DNDEBUG -pipe -Os -Werror=implicit-function-declaration -arch x86_64 -I/opt/local/include -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 conftest.c  >&5
>>> configure:49414: $? = 0
>>> configure:49414: ./conftest
>>> configure:49414: $? = 2
>>> configure: program exited with status 2
>>> Now the results of the test are accurate.
>>> I included this patch in the MacPorts wget 1.12.1 port:
>>> https://github.com/macports/macports-ports/blob/13fd7facb9e1ea9e70b79c8c0b429058b9bb8698/net/wget/files/implicit.patch
>>> Of course you'll want to patch m4/utime.m4 instead of configure.
>>
>> ./configure scripts are not made for using -Werror in CFLAGS.
>>
>> This is documented somewhere but (sorry), I am just too tired to search for the URL right now.
> 
> Unfortunately, you no longer have much of a choice. Treating implicit declarations of functions as an error is the *default* behavior of the compiler included with Xcode 12 and later.
> 
> In the output I showed above I have specified -Werror=implicit-function-declaration manually in CFLAGS because I am using an earlier version of Xcode but I want to simulate the experience of an Xcode 12 user so that I can identify and fix this type of problem.
> 
> Apple intentionally changed the default behavior of the compiler in order to be able to ship Macintosh computers with ARM processors ("Apple Silicon"). ARM processors have different calling conventions for variadic and non-variadic functions, so the compiler must know before you call a function what type of function it is, and the way it knows that is by the function declaration.
> 
> The C99 standard requires that you declare functions before you use them. It has been this way for over 2 decades. wget should do so in all of its code, regardless of whether the code is in a configure test or elsewhere.
> 
> This one configure test that I mentioned is the only place where I noticed a problem, so as far as I know only the one-byte change I proposed above needs to be made.

Thanks for the explanation, that makes it clearer now (and possibly my 
brain is not as mushed as during my last read/answer).

The code involved here comes directly from gnulib and is not part of the 
wget project. The issue affects not only wget and any patching here is 
mostly lost time/efford.

So I am adding the gnulib mailing list to the recipients as IMO this 
issue should be discussed/answered there. It will be read by people with 
more related expertise than I can provide.

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: implicit declaration of function 'utime' in trailing slashes test
  2021-01-23 18:44     ` implicit declaration of function 'utime' in trailing slashes test Tim Rühsen
@ 2021-01-23 21:22       ` Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2021-01-23 21:22 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Ryan Schmidt, bug-wget, Tim Rühsen

> >>> conftest.c:491:23: error: implicit declaration of function 'utime' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> >>>                   if (!utime ("conftest.tmp/", NULL))
> >>>                        ^
> >>> 1 error generated.

Thanks for the report. Fixed through the patch below.

> ARM processors have different calling conventions for variadic and
> non-variadic functions, so the compiler must know before you call a
> function what type of function it is, and the way it knows that is
> by the function declaration.

This is well-known for 'float' parameters (for a long time, on most
platforms).

Do you happen to know other cases for which this is the case? I'm asking
in order to check GNU libffcall and libffi w.r.t. this situation.

Bruno


2021-01-23  Bruno Haible  <bruno@clisp.org>

	utime: Fix configure test (regression 2020-12-04).
	Reported by Ryan Schmidt <wget@ryandesign.com> via Tim Rühsen in
	<https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00282.html>.
	* m4/utime.m4 (gl_FUNC_UTIME): In the test program, include <utime.h>,
	not <time.h>.

diff --git a/m4/utime.m4 b/m4/utime.m4
index 03df7b7..4ed4158 100644
--- a/m4/utime.m4
+++ b/m4/utime.m4
@@ -1,4 +1,4 @@
-# utime.m4 serial 3
+# utime.m4 serial 4
 dnl Copyright (C) 2017-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,7 +34,7 @@ AC_DEFUN([gl_FUNC_UTIME],
            AC_RUN_IFELSE(
              [AC_LANG_PROGRAM(
                [[#include <stddef.h>
-                 #include <time.h>
+                 #include <utime.h>
                ]],
                [[int result = 0;
                  if (!utime ("conftest.tmp/", NULL))



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-23 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <A4AAE1B7-17AC-408F-9AC2-0EDB07465E92@ryandesign.com>
     [not found] ` <70856395-f4ed-e3b2-66c3-17c5261586fb@gmx.de>
     [not found]   ` <48275C81-8FDA-4589-B05C-02E6DA08504F@ryandesign.com>
2021-01-23 18:44     ` implicit declaration of function 'utime' in trailing slashes test Tim Rühsen
2021-01-23 21:22       ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).