Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#62134 closed defect (fixed)

wget @1.21.1 does not build on PPC Leopard, Mac OS X 10.5.8, because of "error: 'for' loop initial declaration used outside C99 mode'"

Reported by: ballapete (Peter "Pete" Dyballa) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: leopard Cc:
Port: wget

Description

	/usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I../src  -DDEFAULT_TEXT_DOMAIN=\"wget-gnulib\" -I/opt/local/include   -DNDEBUG -pipe -Os -arch ppc -MT tempname.o -MD -MP -MF $depbase.Tpo -c -o tempname.o tempname.c &&\
	mv -f $depbase.Tpo $depbase.Po
tempname.c: In function 'random_bits':
tempname.c:92: warning: integer constant is too large for 'long' type
tempname.c:92: warning: this decimal constant is unsigned only in ISO C90
tempname.c: In function 'try_tempname_len':
tempname.c:290: error: 'for' loop initial declaration used outside C99 mode
make[3]: *** [tempname.o] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/wget-1.21.1/lib'
make[2]: *** [all] Error 2

The function is this one:

  233	#ifdef _LIBC
  234	static
  235	#endif
  236	int
  237	try_tempname_len (char *tmpl, int suffixlen, void *args,
  238	                  int (*tryfunc) (char *, void *), size_t x_suffix_len)
  239	{
  240	  size_t len;
  241	  char *XXXXXX;
  242	  unsigned int count;
  243	  int fd = -1;
  244	  int save_errno = errno;
  245	
  246	  /* A lower bound on the number of temporary files to attempt to
  247	     generate.  The maximum total number of temporary file names that
  248	     can exist for a given template is 62**6.  It should never be
  249	     necessary to try all of these combinations.  Instead if a reasonable
  250	     number of names is tried (we define reasonable as 62**3) fail to
  251	     give the system administrator the chance to remove the problems.
  252	     This value requires that X_SUFFIX_LEN be at least 3.  */
  253	#define ATTEMPTS_MIN (62 * 62 * 62)
  254	
  255	  /* The number of times to attempt to generate a temporary file.  To
  256	     conform to POSIX, this must be no smaller than TMP_MAX.  */
  257	#if ATTEMPTS_MIN < TMP_MAX
  258	  unsigned int attempts = TMP_MAX;
  259	#else
  260	  unsigned int attempts = ATTEMPTS_MIN;
  261	#endif
  262	
  263	  /* A random variable.  The initial value is used only the for fallback path
  264	     on 'random_bits' on 'getrandom' failure.  Its initial value tries to use
  265	     some entropy from the ASLR and ignore possible bits from the stack
  266	     alignment.  */
  267	  random_value v = ((uintptr_t) &v) / alignof (max_align_t);
  268	
  269	  /* How many random base-62 digits can currently be extracted from V.  */
  270	  int vdigits = 0;
  271	
  272	  /* Least unfair value for V.  If V is less than this, V can generate
  273	     BASE_62_DIGITS digits fairly.  Otherwise it might be biased.  */
  274	  random_value const unfair_min
  275	    = RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER;
  276	
  277	  len = strlen (tmpl);
  278	  if (len < x_suffix_len + suffixlen
  279	      || strspn (&tmpl[len - x_suffix_len - suffixlen], "X") < x_suffix_len)
  280	    {
  281	      __set_errno (EINVAL);
  282	      return -1;
  283	    }
  284	
  285	  /* This is where the Xs start.  */
  286	  XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
  287	
  288	  for (count = 0; count < attempts; ++count)
  289	    {
  290	      for (size_t i = 0; i < x_suffix_len; i++)        <<<<<<<<<<<<<<<
  291	        {
  292	          if (vdigits == 0)
  293	            {
  294	              do
  295	                v = random_bits (v);
  296	              while (unfair_min <= v);
  297	
  298	              vdigits = BASE_62_DIGITS;
  299	            }
  300	
  301	          XXXXXX[i] = letters[v % 62];
  302	          v /= 62;
  303	          vdigits--;
  304	        }
  305	
  306	      fd = tryfunc (tmpl, args);
  307	      if (fd >= 0)
  308	        {
  309	          __set_errno (save_errno);
  310	          return fd;
  311	        }
  312	      else if (errno != EEXIST)
  313	        return -1;
  314	    }
  315	
  316	  /* We got out of the loop because we ran out of combinations to try.  */
  317	  __set_errno (EEXIST);
  318	  return -1;
  319	}

I presume it's that "size_t i = 0;" that causes the error. (x_suffix_len is an argument of this function.) So we have two options to solve: GCC7 or declare both len and i at the beginning of the finction.

Attachments (2)

main.log (223.9 KB) - added by ballapete (Peter "Pete" Dyballa) 4 years ago.
Main.log from PPC Leopard
Leopard.patch (1.2 KB) - added by ballapete (Peter "Pete" Dyballa) 4 years ago.
Patch set to make wget @1.21.1 compile with GCC 7 on Leopard

Download all attachments as: .zip

Change History (25)

Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Attachment: main.log added

Main.log from PPC Leopard

comment:1 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Choosing the second solution the file is compiled and a new error appears:

	/usr/bin/gcc-4.2 -DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/opt/local/etc/wgetrc\" -DLOCALEDIR=\"/opt/local/share/locale\" -I.  -I../lib -I../lib  -I/opt/local/include    -DNDEBUG -pipe -Os -arch ppc -MT progress.o -MD -MP -MF $depbase.Tpo -c -o progress.o progress.c &&\
	mv -f $depbase.Tpo $depbase.Po
progress.c: In function 'bar_set_params':
progress.c:1378: error: 'for' loop initial declaration used outside C99 mode
make[3]: *** [progress.o] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/wget-1.21.1/src'

Its cause is similar:

 1366	static void
 1367	bar_set_params (const char *params)
 1368	{
 1369	/* if run_with_timeout() will be used for read, needs to disable interactive bar,
 1370	   or  on every timeout(1s) we will have 'retry' with error "decryption failed" */
 1371	#if (defined(HAVE_LIBSSL) || defined(HAVE_LIBSSL32)) && defined(OPENSSL_RUN_WITHTIMEOUT)
 1372	  current_impl->interactive = false;
 1373	#else
 1374	  current_impl->interactive = true;
 1375	#endif
 1376	  if (params)
 1377	    {
 1378	      for (const char *param = params; *param; )
 1379	        {
 1380	          if (!strncmp (param, "force", 5))
 1381	            current_impl_locked = 1;
 1382	          else if (!strncmp (param, "noscroll", 8))
 1383	            opt.noscroll = true;
 1384	
 1385	          if (*(param = strchrnul(param, ':')))
 1386	            param++;
 1387	        }
 1388	    }

Here the re-declaration of param looks faulty since its type is known from the function's definition.

comment:2 in reply to:  1 ; Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Here the re-declaration of param looks faulty since its type is known from the function's definition.

Which is a faulty assumption:

progress.c: In function 'bar_set_params':
progress.c:1378: error: 'param' undeclared (first use in this function)
progress.c:1378: error: (Each undeclared identifier is reported only once
progress.c:1378: error: for each function it appears in.)

comment:3 in reply to:  2 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Because the variable's name is without "s"!

Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Attachment: Leopard.patch added

Patch set to make wget @1.21.1 compile with GCC 7 on Leopard

comment:4 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

make check fails like this:

make[4]: Leaving directory '/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/wget-1.21.1/src'
/usr/bin/gcc-4.2    -DNDEBUG -pipe -Os -arch ppc  -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -o wget_cookie_fuzzer wget_cookie_fuzzer.o main.o ../src/libunittest.a ../lib/libgnu.a              /opt/local/lib/libiconv.dylib /opt/local/lib/libintl.dylib -Wl,-framework -Wl,CoreFoundation -lpthread   -Wl,-framework -Wl,CoreFoundation    -L/opt/local/lib -lpcre2-8 -lidn2 -lnettle /opt/local/lib/libgnutls.dylib -L/opt/local/lib -lz -L/opt/local/lib -lpsl 
Undefined symbols:
  "_uc_width", referenced from:
      _rpl_wcwidth in libgnu.a(wcwidth.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [Makefile:1999: wget_cookie_fuzzer] Error 1
make[3]: Leaving directory '/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/wget-1.21.1/fuzz'

I am going to try GCC7!

comment:5 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

configure: WARNING: unrecognized options: --without-libpth-prefix

comment:6 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

With GCC7 it compiles without patch set, make check fails the same way.

comment:7 Changed 4 years ago by mf2k (Frank Schima)

Cc: ryandesign@… removed
Owner: set to ryandesign
Status: newassigned

comment:8 Changed 4 years ago by jmroot (Joshua Root)

You don't need gcc7, gcc-4.2 supports -std=c99, it just doesn't have it on by default. Upstream should probably be checking for C99 compiler support if they use C99 features of course.

comment:10 Changed 4 years ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In db338c5e24bea055815d7035180c9a40b95e3085/macports-ports (master):

wget: use std=c99

closes: #62134

comment:11 in reply to:  description ; Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to ballapete:

tempname.c: In function 'random_bits':
tempname.c:92: warning: integer constant is too large for 'long' type
tempname.c:92: warning: this decimal constant is unsigned only in ISO C90
tempname.c: In function 'try_tempname_len':
tempname.c:290: error: 'for' loop initial declaration used outside C99 mode

This was reported to the developers here:

https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00004.html

A similar patch was provided to the developers here:

https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00010.html
https://github.com/noloader/Build-Scripts/blob/master/patch/wget.patch

I don't know if they wish to apply it. If not, requiring C99 mode per Ken's commit above is fine.

Last edited 4 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:12 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

In 6ff98cc433c872d3dc5cad04dfbf6bd527d5bd60/macports-ports (master):

wget: Remove --without-libpth-prefix

This option doesn't exist anymore.

See: #62134#comment:5

comment:13 in reply to:  11 Changed 4 years ago by jmroot (Joshua Root)

Replying to ryandesign:

This was reported to the developers here:

https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00004.html

A similar patch was provided to the developers here:

https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00010.html
https://github.com/noloader/Build-Scripts/blob/master/patch/wget.patch

I don't know if they wish to apply it. If not, requiring C99 mode per Ken's commit above is fine.

A later message in that thread says that the code does require C99, and that the configure script should be adding -std=gnu99 to CFLAGS in these circumstances, and that the real bug is that it isn't. https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00009.html

comment:14 Changed 4 years ago by jmroot (Joshua Root)

:info:configure checking for /usr/bin/gcc-4.2 option to enable C99 features... none needed

This is clearly incorrect. The config.log would be needed to see why this check didn't work.

comment:15 Changed 4 years ago by kencu (Ken)

It built on 10.5 Intel with the tiny little addition to the Portfile, so that will save Pete 100 more messages.

However, Jeff there (noloader) appears to have found some other issues building it on PPC I guess, as per his github patch; I haven't tried PPC yet :>

Another day.

comment:16 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Checking on a 10.6 machine, where the compiler is also gcc-4.2, running ./configure outside of MacPorts, the config.log unfortunately provides no details about why is incorrectly believes C99 is supported without a flag:

configure:5958: checking for gcc option to enable C99 features
configure:5973: gcc  -c -g -O2  conftest.c >&5
configure:5973: $? = 0
configure:5988: result: none needed

comment:17 in reply to:  16 ; Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

On PPC Tiger, Mac OS X 10.4.11 I can see:

checking for gcc... /opt/local/bin/gcc-apple-4.2
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /opt/local/bin/gcc-apple-4.2 accepts -g... yes
checking for /opt/local/bin/gcc-apple-4.2 option to enable C11 features... unsupported
checking for /opt/local/bin/gcc-apple-4.2 option to enable C99 features... none needed
checking whether /opt/local/bin/gcc-apple-4.2 understands -c and -o together... yes
checking whether the compiler is clang... no
checking for compiler option needed when checking for declarations... none
checking dependency style of /opt/local/bin/gcc-apple-4.2... gcc3

and in config.log this is recorded:

configure:5912: checking for /opt/local/bin/gcc-apple-4.2 option to enable C11 features
configure:5927: /opt/local/bin/gcc-apple-4.2  -c -pipe -Os -arch ppc -I/opt/local/include conftest.c >&5
conftest.c:63:3: error: #error "Compiler does not advertise C99 conformance"
conftest.c:118: error: expected ';', ',' or ')' before 'text'
conftest.c:167:3: error: #error "Compiler does not advertise C11 conformance"
conftest.c: In function '_Alignas':
conftest.c:171: error: expected declaration specifiers before 'aligned_as_double'
conftest.c:172: error: expected declaration specifiers or '...' before numeric constant
conftest.c:172: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'no_special_alignment'
conftest.c:173: error: storage class specified for parameter 'aligned_as_int'
conftest.c:174: error: expected declaration specifiers or '...' before numeric constant
conftest.c:174: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_Alignas'
conftest.c:179: error: expected expression before 'int'
conftest.c:179: error: enumerator value for 'int_alignment' is not an integer constant
conftest.c:180: error: expected expression before 'int'
conftest.c:180: error: enumerator value for 'int_array_alignment' is not an integer constant
conftest.c:181: error: expected expression before 'char'
conftest.c:182: error: enumerator value for 'char_alignment' is not an integer constant
conftest.c:182: warning: empty declaration
conftest.c:183: error: expected declaration specifiers before '_Static_assert'
conftest.c:186: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'does_not_return'
conftest.c:192: error: expected specifier-qualifier-list before '_Static_assert'
conftest.c:195: warning: empty declaration
conftest.c:199: error: parameter 'utf8_literal' is initialized
conftest.c:199: error: 'syntax' undeclared (first use in this function)
conftest.c:199: error: (Each undeclared identifier is reported only once
conftest.c:199: error: for each function it appears in.)
conftest.c:199: error: expected ',' or ';' before 'error'
conftest.c:202: error: storage class specified for parameter 'long_ptr'
conftest.c:203: error: storage class specified for parameter 'long_ptr'
conftest.c:203: error: redefinition of parameter 'long_ptr'
conftest.c:202: error: previous definition of 'long_ptr' was here
conftest.c:204: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'long_ptr'
conftest.c:219: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
conftest.c:271: error: old-style parameter declarations in prototyped function definition
conftest.c:171: error: parameter name omitted
conftest.c:271: error: expected '{' at end of input
configure:5927: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "wget"
| #define PACKAGE_TARNAME "wget"
| #define PACKAGE_VERSION "1.21.1"
| #define PACKAGE_STRING "wget 1.21.1"
| #define PACKAGE_BUGREPORT "bug-wget@gnu.org"
| #define PACKAGE_URL ""
| #define PACKAGE "wget"
| #define VERSION "1.21.1"
| /* end confdefs.h.  */
| 
| /* Does the compiler advertise C89 conformance?
|    Do not test the value of __STDC__, because some compilers set it to 0
|    while being otherwise adequately conformant. */
| #if !defined __STDC__
| # error "Compiler does not advertise C89 conformance"
| #endif
| 
| #include <stddef.h>
| #include <stdarg.h>
| struct stat;
| /* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
| struct buf { int x; };
| struct buf * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
| 
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not \xHH hex character constants.
|    These do not provoke an error unfortunately, instead are silently treated
|    as an "x".  The following induces an error, until -std is added to get
|    proper ANSI mode.  Curiously \x00 != x always comes out true, for an
|    array size at least.  It is necessary to write \x00 == 0 to get something
|    that is true only with -std.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
| 
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
|    inside strings and character constants.  */
| #define FOO(x) 'x'
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
| 
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
|                int, int);
| 
| // Does the compiler advertise C99 conformance?
| #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
| # error "Compiler does not advertise C99 conformance"
| #endif
| 
| #include <stdbool.h>
| extern int puts (const char *);
| extern int printf (const char *, ...);
| extern int dprintf (int, const char *, ...);
| extern void *malloc (size_t);
| 
| // Check varargs macros.  These examples are taken from C99 6.10.3.5.
| // dprintf is used instead of fprintf to avoid needing to declare
| // FILE and stderr.
| #define debug(...) dprintf (2, __VA_ARGS__)
| #define showlist(...) puts (#__VA_ARGS__)
| #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
| static void
| test_varargs_macros (void)
| {
|   int x = 1234;
|   int y = 5678;
|   debug ("Flag");
|   debug ("X = %d\n", x);
|   showlist (The first, second, and third items.);
|   report (x>y, "x is %d but y is %d", x, y);
| }
| 
| // Check long long types.
| #define BIG64 18446744073709551615ull
| #define BIG32 4294967295ul
| #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
| #if !BIG_OK
|   #error "your preprocessor is broken"
| #endif
| #if BIG_OK
| #else
|   #error "your preprocessor is broken"
| #endif
| static long long int bignum = -9223372036854775807LL;
| static unsigned long long int ubignum = BIG64;
| 
| struct incomplete_array
| {
|   int datasize;
|   double data[];
| };
| 
| struct named_init {
|   int number;
|   const wchar_t *name;
|   double average;
| };
| 
| typedef const char *ccp;
| 
| static inline int
| test_restrict (ccp restrict text)
| {
|   // See if C++-style comments work.
|   // Iterate through items via the restricted pointer.
|   // Also check for declarations in for loops.
|   for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|     continue;
|   return 0;
| }
| 
| // Check varargs and va_copy.
| static bool
| test_varargs (const char *format, ...)
| {
|   va_list args;
|   va_start (args, format);
|   va_list args_copy;
|   va_copy (args_copy, args);
| 
|   const char *str = "";
|   int number = 0;
|   float fnumber = 0;
| 
|   while (*format)
|     {
|       switch (*format++)
| 	{
| 	case 's': // string
| 	  str = va_arg (args_copy, const char *);
| 	  break;
| 	case 'd': // int
| 	  number = va_arg (args_copy, int);
| 	  break;
| 	case 'f': // float
| 	  fnumber = va_arg (args_copy, double);
| 	  break;
| 	default:
| 	  break;
| 	}
|     }
|   va_end (args_copy);
|   va_end (args);
| 
|   return *str && number && fnumber;
| }
| 
| 
| // Does the compiler advertise C11 conformance?
| #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
| # error "Compiler does not advertise C11 conformance"
| #endif
| 
| // Check _Alignas.
| char _Alignas (double) aligned_as_double;
| char _Alignas (0) no_special_alignment;
| extern char aligned_as_int;
| char _Alignas (0) _Alignas (int) aligned_as_int;
| 
| // Check _Alignof.
| enum
| {
|   int_alignment = _Alignof (int),
|   int_array_alignment = _Alignof (int[100]),
|   char_alignment = _Alignof (char)
| };
| _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
| 
| // Check _Noreturn.
| int _Noreturn does_not_return (void) { for (;;) continue; }
| 
| // Check _Static_assert.
| struct test_static_assert
| {
|   int x;
|   _Static_assert (sizeof (int) <= sizeof (long int),
|                   "_Static_assert does not work in struct");
|   long int y;
| };
| 
| // Check UTF-8 literals.
| #define u8 syntax error!
| char const utf8_literal[] = u8"happens to be ASCII" "another string";
| 
| // Check duplicate typedefs.
| typedef long *long_ptr;
| typedef long int *long_ptr;
| typedef long_ptr long_ptr;
| 
| // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
| struct anonymous
| {
|   union {
|     struct { int i; int j; };
|     struct { int k; long int l; } w;
|   };
|   int m;
| } v1;
| 
| 
| int
| main (int argc, char **argv)
| {
|   int ok = 0;
|   
| ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
| 
|   
|   // Check bool.
|   _Bool success = false;
|   success |= (argc != 0);
| 
|   // Check restrict.
|   if (test_restrict ("String literal") == 0)
|     success = true;
|   char *restrict newvar = "Another string";
| 
|   // Check varargs.
|   success &= test_varargs ("s, d' f .", "string", 65, 34.234);
|   test_varargs_macros ();
| 
|   // Check flexible array members.
|   struct incomplete_array *ia =
|     malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
|   ia->datasize = 10;
|   for (int i = 0; i < ia->datasize; ++i)
|     ia->data[i] = i * 1.234;
| 
|   // Check named initializers.
|   struct named_init ni = {
|     .number = 34,
|     .name = L"Test wide string",
|     .average = 543.34343,
|   };
| 
|   ni.number = 58;
| 
|   int dynamic_array[ni.number];
|   dynamic_array[0] = argv[0][0];
|   dynamic_array[ni.number - 1] = 543;
| 
|   // work around unused variable warnings
|   ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
| 	 || dynamic_array[ni.number - 1] != 543);
| 
|   
|   _Static_assert ((offsetof (struct anonymous, i)
| 		   == offsetof (struct anonymous, w.k)),
| 		  "Anonymous union alignment botch");
|   v1.i = 2;
|   v1.w.k = 5;
|   ok |= v1.i != 5;
| 
|   return ok;
| }
| 
configure:5927: /opt/local/bin/gcc-apple-4.2 -std=gnu11 -c -pipe -Os -arch ppc -I/opt/local/include conftest.c >&5
cc1: error: unrecognized command line option "-std=gnu11"
configure:5927: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "wget"
| #define PACKAGE_TARNAME "wget"
| #define PACKAGE_VERSION "1.21.1"
| #define PACKAGE_STRING "wget 1.21.1"
| #define PACKAGE_BUGREPORT "bug-wget@gnu.org"
| #define PACKAGE_URL ""
| #define PACKAGE "wget"
| #define VERSION "1.21.1"
| /* end confdefs.h.  */
| 
| /* Does the compiler advertise C89 conformance?
|    Do not test the value of __STDC__, because some compilers set it to 0
|    while being otherwise adequately conformant. */
| #if !defined __STDC__
| # error "Compiler does not advertise C89 conformance"
| #endif
| 
| #include <stddef.h>
| #include <stdarg.h>
| struct stat;
| /* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
| struct buf { int x; };
| struct buf * (*rcsopen) (struct buf *, struct stat *, int);
| static char *e (p, i)
|      char **p;
|      int i;
| {
|   return p[i];
| }
| static char *f (char * (*g) (char **, int), char **p, ...)
| {
|   char *s;
|   va_list v;
|   va_start (v,p);
|   s = g (p, va_arg (v,int));
|   va_end (v);
|   return s;
| }
| 
| /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
|    function prototypes and stuff, but not \xHH hex character constants.
|    These do not provoke an error unfortunately, instead are silently treated
|    as an "x".  The following induces an error, until -std is added to get
|    proper ANSI mode.  Curiously \x00 != x always comes out true, for an
|    array size at least.  It is necessary to write \x00 == 0 to get something
|    that is true only with -std.  */
| int osf4_cc_array ['\x00' == 0 ? 1 : -1];
| 
| /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
|    inside strings and character constants.  */
| #define FOO(x) 'x'
| int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
| 
| int test (int i, double x);
| struct s1 {int (*f) (int a);};
| struct s2 {int (*f) (double a);};
| int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
|                int, int);
| 
| // Does the compiler advertise C99 conformance?
| #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
| # error "Compiler does not advertise C99 conformance"
| #endif
| 
| #include <stdbool.h>
| extern int puts (const char *);
| extern int printf (const char *, ...);
| extern int dprintf (int, const char *, ...);
| extern void *malloc (size_t);
| 
| // Check varargs macros.  These examples are taken from C99 6.10.3.5.
| // dprintf is used instead of fprintf to avoid needing to declare
| // FILE and stderr.
| #define debug(...) dprintf (2, __VA_ARGS__)
| #define showlist(...) puts (#__VA_ARGS__)
| #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
| static void
| test_varargs_macros (void)
| {
|   int x = 1234;
|   int y = 5678;
|   debug ("Flag");
|   debug ("X = %d\n", x);
|   showlist (The first, second, and third items.);
|   report (x>y, "x is %d but y is %d", x, y);
| }
| 
| // Check long long types.
| #define BIG64 18446744073709551615ull
| #define BIG32 4294967295ul
| #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
| #if !BIG_OK
|   #error "your preprocessor is broken"
| #endif
| #if BIG_OK
| #else
|   #error "your preprocessor is broken"
| #endif
| static long long int bignum = -9223372036854775807LL;
| static unsigned long long int ubignum = BIG64;
| 
| struct incomplete_array
| {
|   int datasize;
|   double data[];
| };
| 
| struct named_init {
|   int number;
|   const wchar_t *name;
|   double average;
| };
| 
| typedef const char *ccp;
| 
| static inline int
| test_restrict (ccp restrict text)
| {
|   // See if C++-style comments work.
|   // Iterate through items via the restricted pointer.
|   // Also check for declarations in for loops.
|   for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|     continue;
|   return 0;
| }
| 
| // Check varargs and va_copy.
| static bool
| test_varargs (const char *format, ...)
| {
|   va_list args;
|   va_start (args, format);
|   va_list args_copy;
|   va_copy (args_copy, args);
| 
|   const char *str = "";
|   int number = 0;
|   float fnumber = 0;
| 
|   while (*format)
|     {
|       switch (*format++)
| 	{
| 	case 's': // string
| 	  str = va_arg (args_copy, const char *);
| 	  break;
| 	case 'd': // int
| 	  number = va_arg (args_copy, int);
| 	  break;
| 	case 'f': // float
| 	  fnumber = va_arg (args_copy, double);
| 	  break;
| 	default:
| 	  break;
| 	}
|     }
|   va_end (args_copy);
|   va_end (args);
| 
|   return *str && number && fnumber;
| }
| 
| 
| // Does the compiler advertise C11 conformance?
| #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
| # error "Compiler does not advertise C11 conformance"
| #endif
| 
| // Check _Alignas.
| char _Alignas (double) aligned_as_double;
| char _Alignas (0) no_special_alignment;
| extern char aligned_as_int;
| char _Alignas (0) _Alignas (int) aligned_as_int;
| 
| // Check _Alignof.
| enum
| {
|   int_alignment = _Alignof (int),
|   int_array_alignment = _Alignof (int[100]),
|   char_alignment = _Alignof (char)
| };
| _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
| 
| // Check _Noreturn.
| int _Noreturn does_not_return (void) { for (;;) continue; }
| 
| // Check _Static_assert.
| struct test_static_assert
| {
|   int x;
|   _Static_assert (sizeof (int) <= sizeof (long int),
|                   "_Static_assert does not work in struct");
|   long int y;
| };
| 
| // Check UTF-8 literals.
| #define u8 syntax error!
| char const utf8_literal[] = u8"happens to be ASCII" "another string";
| 
| // Check duplicate typedefs.
| typedef long *long_ptr;
| typedef long int *long_ptr;
| typedef long_ptr long_ptr;
| 
| // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
| struct anonymous
| {
|   union {
|     struct { int i; int j; };
|     struct { int k; long int l; } w;
|   };
|   int m;
| } v1;
| 
| 
| int
| main (int argc, char **argv)
| {
|   int ok = 0;
|   
| ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
| 
|   
|   // Check bool.
|   _Bool success = false;
|   success |= (argc != 0);
| 
|   // Check restrict.
|   if (test_restrict ("String literal") == 0)
|     success = true;
|   char *restrict newvar = "Another string";
| 
|   // Check varargs.
|   success &= test_varargs ("s, d' f .", "string", 65, 34.234);
|   test_varargs_macros ();
| 
|   // Check flexible array members.
|   struct incomplete_array *ia =
|     malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
|   ia->datasize = 10;
|   for (int i = 0; i < ia->datasize; ++i)
|     ia->data[i] = i * 1.234;
| 
|   // Check named initializers.
|   struct named_init ni = {
|     .number = 34,
|     .name = L"Test wide string",
|     .average = 543.34343,
|   };
| 
|   ni.number = 58;
| 
|   int dynamic_array[ni.number];
|   dynamic_array[0] = argv[0][0];
|   dynamic_array[ni.number - 1] = 543;
| 
|   // work around unused variable warnings
|   ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
| 	 || dynamic_array[ni.number - 1] != 543);
| 
|   
|   _Static_assert ((offsetof (struct anonymous, i)
| 		   == offsetof (struct anonymous, w.k)),
| 		  "Anonymous union alignment botch");
|   v1.i = 2;
|   v1.w.k = 5;
|   ok |= v1.i != 5;
| 
|   return ok;
| }
| 
configure:5945: result: unsupported
configure:5958: checking for /opt/local/bin/gcc-apple-4.2 option to enable C99 features
configure:5973: /opt/local/bin/gcc-apple-4.2  -c -pipe -Os -arch ppc -I/opt/local/include conftest.c >&5
configure:5973: $? = 0
configure:5988: result: none needed

The configure script has:

 5912	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
 5913	printf %s "checking for $CC option to enable C11 features... " >&6; }
 5914	if test ${ac_cv_prog_cc_c11+y}
 5915	then :
 5916	  printf %s "(cached) " >&6
 5917	else $as_nop
 5918	  ac_cv_prog_cc_c11=no
 5919	ac_save_CC=$CC
 5920	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 5921	/* end confdefs.h.  */
 5922	$ac_c_conftest_c11_program
 5923	_ACEOF
 5924	for ac_arg in '' -std=gnu11
 5925	do
 5926	  CC="$ac_save_CC $ac_arg"
 5927	  if ac_fn_c_try_compile "$LINENO"
 5928	then :
 5929	  ac_cv_prog_cc_c11=$ac_arg
 5930	fi
 5931	rm -f core conftest.err conftest.$ac_objext conftest.beam
 5932	  test "x$ac_cv_prog_cc_c11" != "xno" && break
 5933	done
 5934	rm -f conftest.$ac_ext
 5935	CC=$ac_save_CC
 5936	
 5937	fi
 5938	# AC_CACHE_VAL
 5939	ac_prog_cc_stdc_options=
 5940	case "x$ac_cv_prog_cc_c11" in #(
 5941	  x) :
 5942	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
 5943	printf "%s\n" "none needed" >&6; } ;; #(
 5944	  xno) :
 5945	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
 5946	printf "%s\n" "unsupported" >&6; } ;; #(
 5947	  *) :
 5948	    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c11"
 5949	    CC="$CC$ac_prog_cc_stdc_options"
 5950	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
 5951	printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } ;;
 5952	esac
 5953	if test "x$ac_cv_prog_cc_c11" != xno
 5954	then :
 5955	  ac_prog_cc_stdc=c11
 5956			 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
 5957	else $as_nop
 5958	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
 5959	printf %s "checking for $CC option to enable C99 features... " >&6; }
 5960	if test ${ac_cv_prog_cc_c99+y}
 5961	then :
 5962	  printf %s "(cached) " >&6
 5963	else $as_nop
 5964	  ac_cv_prog_cc_c99=no
 5965	ac_save_CC=$CC
 5966	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 5967	/* end confdefs.h.  */
 5968	$ac_c_conftest_c89_program
 5969	_ACEOF
 5970	for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99
 5971	do
 5972	  CC="$ac_save_CC $ac_arg"
 5973	  if ac_fn_c_try_compile "$LINENO"
 5974	then :
 5975	  ac_cv_prog_cc_c99=$ac_arg
 5976	fi
 5977	rm -f core conftest.err conftest.$ac_objext conftest.beam
 5978	  test "x$ac_cv_prog_cc_c99" != "xno" && break
 5979	done
 5980	rm -f conftest.$ac_ext
 5981	CC=$ac_save_CC
 5982	
 5983	fi
 5984	# AC_CACHE_VAL
 5985	ac_prog_cc_stdc_options=
 5986	case "x$ac_cv_prog_cc_c99" in #(
 5987	  x) :
 5988	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
 5989	printf "%s\n" "none needed" >&6; } ;; #(
 5990	  xno) :
 5991	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
 5992	printf "%s\n" "unsupported" >&6; } ;; #(
 5993	  *) :
 5994	    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c99"
 5995	    CC="$CC$ac_prog_cc_stdc_options"
 5996	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
 5997	printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } ;;
 5998	esac
 5999	if test "x$ac_cv_prog_cc_c99" != xno
 6000	then :
 6001	  ac_prog_cc_stdc=c99
 6002			    ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
 6003	else $as_nop
 6004	  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
 6005	printf %s "checking for $CC option to enable C89 features... " >&6; }
 6006	if test ${ac_cv_prog_cc_c89+y}
 6007	then :
 6008	  printf %s "(cached) " >&6
 6009	else $as_nop
 6010	  ac_cv_prog_cc_c89=no
 6011	ac_save_CC=$CC
 6012	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 6013	/* end confdefs.h.  */
 6014	$ac_c_conftest_c89_program
 6015	_ACEOF
 6016	for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
 6017		-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 6018	do
 6019	  CC="$ac_save_CC $ac_arg"
 6020	  if ac_fn_c_try_compile "$LINENO"
 6021	then :
 6022	  ac_cv_prog_cc_c89=$ac_arg
 6023	fi
 6024	rm -f core conftest.err conftest.$ac_objext conftest.beam
 6025	  test "x$ac_cv_prog_cc_c89" != "xno" && break
 6026	done
 6027	rm -f conftest.$ac_ext
 6028	CC=$ac_save_CC
 6029	
 6030	fi
 6031	# AC_CACHE_VAL
 6032	ac_prog_cc_stdc_options=
 6033	case "x$ac_cv_prog_cc_c89" in #(
 6034	  x) :
 6035	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
 6036	printf "%s\n" "none needed" >&6; } ;; #(
 6037	  xno) :
 6038	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
 6039	printf "%s\n" "unsupported" >&6; } ;; #(
 6040	  *) :
 6041	    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c89"
 6042	    CC="$CC$ac_prog_cc_stdc_options"
 6043	    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
 6044	printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } ;;
 6045	esac
 6046	if test "x$ac_cv_prog_cc_c89" != xno
 6047	then :
 6048	  ac_prog_cc_stdc=c89
 6049			       ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
 6050	else $as_nop
 6051	  ac_prog_cc_stdc=no
 6052			       ac_cv_prog_cc_stdc=no
 6053	fi
 6054	
 6055	fi
 6056	
 6057	fi

To me it looks as if the wrong tests were performed for C11 resp. C99. GCC 4.2 ("4.2.4 (Apple Inc. build 5666) (dot 3) (MacPorts apple-gcc42 5666.3_16+gpl3)") defines __STDC__ to 1 and does not define __STDC_VERSION__. The correct options for this version of GCC are:

  -std=c89                    Conform to the ISO 1990 C standard
  -std=c99                    Conform to the ISO 1999 C standard
  -std=c9x                    Deprecated in favor of -std=c99
  -std=gnu89                  Conform to the ISO 1990 C standard with GNU extensions
  -std=gnu99                  Conform to the ISO 1999 C standard with GNU extensions
  -std=gnu9x                  Deprecated in favor of -std=gnu99
  -std=iso9899:1990           Conform to the ISO 1990 C standard
  -std=iso9899:199409         Conform to the ISO 1990 C standard as amended in 1994
  -std=iso9899:1999           Conform to the ISO 1999 C standard
  -std=iso9899:199x           Deprecated in favor of -std=iso9899:1999

  -ansi                       A synonym for -std=c89 (for C) or -std=c++98 (for C++)

  -std=c++98                  Conform to the ISO 1998 C++ standard
  -std=gnu++98                Conform to the ISO 1998 C++ standard with GNU extensions

No modern C++ standard is supported.

comment:18 in reply to:  17 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

(MacPorts gcc7 7.5.0_2) version 7.5.0 (ppc-apple-darwin8), GGC7, defines:

#define __STDC__ 1
#define __STDC_VERSION__ 201112L

comment:19 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

The tests for C99 and C11 support are probably not unique to wget. I guess they're part of gnulib. If they're not working right, you should probably report it to the developers of gnulib so they can fix it.

comment:20 in reply to:  19 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

In https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00292.html and following messages is described that the problem came up earlier this year. Patches to Autoconf 2.70, the culprit, are provided. Could be I can try a few things later – when compilation on Tiger has finished and GNU Emacs is free for other work.

comment:21 in reply to:  11 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

This was reported to the developers here:

https://lists.gnu.org/archive/html/bug-wget/2021-01/msg00004.html

I could read this thread but could not fetch the patch:

pete 259 /\ env LANG=C wget -vd https://github.com/noloader/Build-Scripts/blob/master/patch/wget.patch
DEBUG output created by Wget 1.20.3 on darwin8.11.0.

Reading HSTS entries from /Users/pete/.wget-hsts
URI encoding = ‘UTF-8’
Converted file name 'wget.patch' (UTF-8) -> 'wget.patch' (UTF-8)
--2021-01-26 17:45:29--  https://github.com/noloader/Build-Scripts/blob/master/patch/wget.patch
Certificates loaded: 129
Resolving github.com (github.com)... failed: No address associated with nodename.
wget: unable to resolve host address ‘github.com’
Exit 4

Is it really necessary to be dependent on Microsoft? It wouldn't hurt when you're finished – but this m oment has not arrived yet.

Last edited 4 years ago by ballapete (Peter "Pete" Dyballa) (previous) (diff)

comment:22 in reply to:  15 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to kencu:

With the updated Portfile, containing now

     92 # tempname.c:290: error: 'for' loop initial declaration used outside C99 mode
     93 configure.cflags-append -std=c99

I now have:

The following ports are currently installed:
  wget @1.20.3_3+gnutls
  wget @1.21.1_0+gnutls (active)

comment:23 Changed 4 years ago by kencu (Ken)

we aim to please :>

Note: See TracTickets for help on using tickets.