AFAICT getrandom does not exist on Darwin/macOS; I can reproduce the first problem.

I can’t reproduce the second problem on macOS 13.

debbie  3:36PM tz ?2 % make CFLAGS="-DHAVE_GETRANDOM=0"

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o zic.o zic.c

cc -DTZDIR='"/usr/share/zoneinfo"' -o zic -DHAVE_GETRANDOM=0  zic.o 

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o zdump.o zdump.c

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o localtime.o localtime.c

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o asctime.o asctime.c

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o strftime.o strftime.c

cc -DTZDIR='"/usr/share/zoneinfo"' -o zdump -DHAVE_GETRANDOM=0  zdump.o localtime.o asctime.o strftime.o 

cc -DTZDIR='"/usr/share/zoneinfo"' -DHAVE_GETRANDOM=0   -c -o difftime.o difftime.c

rm -f libtz.a

ar -rc libtz.a localtime.o asctime.o difftime.o strftime.o

: libtz.a


Debbie

On Oct 29, 2022, at 3:29 PM, Gilmore Davidson via tz <tz@iana.org> wrote:

Hi, I’m getting errors when running make on the 2022f release, on my macOS Monterrey (12.6.1) machine.

There are two separate errors. When I run `make` with no arguments, I get the following:

cc -DTZDIR='"/usr/share/zoneinfo"'    -c -o zic.o zic.c
zic.c:1194:11: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      s = getrandom(entropy_buffer, sizeof entropy_buffer, 0);
          ^
1 error generated.


After some digging, I tried running `make CFLAGS="-DHAVE_GETRANDOM=0”`, which then presents a different error:

cc -DTZDIR='"/usr/share/zoneinfo"' -o zic -DHAVE_GETRANDOM=0  zic.o
Undefined symbols for architecture x86_64:
  "_libintl_gettext", referenced from:
      _main in zic.o
      _close_file in zic.o
      _usage in zic.o
      _warning in zic.o
      _infile in zic.o
      _adjleap in zic.o
      _associate in zic.o
      ...
  "_libintl_setlocale", referenced from:
      _main in zic.o
  "_libintl_textdomain", referenced from:
      _main in zic.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


I’m not a C programmer so I’m out of my depth with trying to diagnose workarounds. Possibly there’s just another CFLAGS argument I need to provide, or I’ve got something else weird in my environment?

Some extra bits of context:

  • These errors also happen on latest `main` branch (commit 9f1f40cd).
  • I can compile 2022e without issue.
  • The getrandom error appears in commit 0733c65c ("Improve randomness of zic temp file names”).
  • The linking error appears in commit e5b2ee63 ("Use C23 __has_include if available”).
  • masOS 12.6.1 / Make 3.81 / clang 14.0.0

Also, the Makefile comment for the HAVE_GETRANDOM flag says "-DHAVE_GETRANDOM if getgrandom works (e.g., GNU/Linux)*” — is “getgrandom” a typo?

Cheers,
Gil