Page MenuHome GnuPG

GnuPG build on Apple with Clang
Closed, ResolvedPublic

Description

Hi Everyone,

I'm testing on an Intel Mac-mini with OS X 10.12. The machine is modern and has Apple Clang 9.0.0 (Apple versioning does not follow LLVM versioning). I'm using the latest config.guess and config.sub. System Integrity Protection (SIP) is enabled.

GnuPG is a little dirty on its compile. But the reason for the bug report is, some of the items look non-trivial:

I think each source file produces a warning for -fno-delete-null-pointer-checks:

libtool: compile:  /usr/bin/clang -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/Users/jwalton/ok2delete/include -I/Users/jwalton/ok2delete/include -DNDEBUG -g2 -O2 -fno-common -march=native -fPIC -pthread -fno-delete-null-pointer-checks -Wall -MT compat.lo -MD -MP -MF .deps/compat.Tpo -c compat.c  -fno-common -DPIC -o .libs/compat.o
clang: warning: optimization flag '-fno-delete-null-pointer-checks' is not supported [-Wignored-optimization-argument]

And this one looks suspicious, too:

libtool: compile:  /usr/bin/clang -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/Users/jwalton/ok2delete/include -DNDEBUG -I/Users/jwalton/ok2delete/include -g2 -O0 -fno-common -march=native -fPIC -pthread -fno-delete-null-pointer-checks -Wall -c ./rndjent.c  -fno-common -DPIC -o .libs/rndjent.o
clang: warning: optimization flag '-fno-delete-null-pointer-checks' is not supported [-Wignored-optimization-argument]
In file included from ./rndjent.c:86:
./jitterentropy-base.c:53:13: warning: unknown pragma ignored
      [-Wunknown-pragmas]
#pragma GCC optimize ("O0")
            ^

For the optimization issue, I believe a better choice would be... modify the makefile recipe for rndjent.c and always apply -O0, -xO0, etc. According to the GNU Make manual, you are allowed to apply flags that are necessary to compile the source file. (This is not a case of ignoring a user's choice if -O0 is required).

So the recipe might look something like this. Autoconf would determine the flag to use for NO_OPT.

rndjent.o:
    $(CC) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(NO_OPT) -c rndjent.c -o rndjent.o

Details

Version
2.2.27

Event Timeline

JW updated the task description. (Show Details)
werner added a project: MacOS.

Note that rndjent.c is already build with -O0 as can be seen in example above. That warning could be silenced by surrounding pragma with #ifdef __OPTIMIZE__ (with should be supported by GCC and Clang).

gniibe claimed this task.
gniibe added a subscriber: gniibe.

That warning could be silenced by surrounding pragma with #ifdef __OPTIMIZE__ (with should be supported by GCC and Clang).

Done in rCf6a4e22d86d2: random: Silence a warning for building rndjent by Clang..

werner added a subscriber: werner.

I don't think that it is a good idea to silence this warning. The pragma is esssential for proper random numbers and if clang hijacks a GCC's name space but implements something different it is better to have a warning than to fall into the pit full of dragons.

jitterentropy is also used in Linux kernel, and some people use clang to build it these days. So, I checked the kernel's one. It is simply compiled -O0 by Makefile, and there's no pragma line now (as of v5.13).

Also, I checked the primary site:
http://www.chronox.de/jent.html

In the recent version (3.0.2), it is compiled with -O0 and there is no pragma line any more.

So, I think that removing the line is best.

gniibe edited projects, added libgcrypt; removed gnupg.

Fixed in libgcrypt 1.9.4.