Tarsnap / spiped

Spiped is a utility for creating symmetrically encrypted and authenticated pipes between socket addresses.
http://www.tarsnap.com/spiped.html
Other
858 stars 56 forks source link

Can not make in SUSE/openSUSE #235

Closed ultra-violets closed 4 years ago

ultra-violets commented 4 years ago
The src can not build successfully in SELS/openSUSE. Maybe the paramteters of gcc.
But it can be successful in redhat/centos.

c99  -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\"  -I.. -I../proto -I../libcperciva/alg -I../libcperciva/datastruct -I../lib/dnsthread -I../lib/util -I../libcperciva/util -I../libcperciva/cpusupport -I../libcperciva/events -I../libcperciva/network -I../libcperciva/crypto  -O2 -c main.c -o main.o
c99: invalid option -- '2'
usage: c99 [-c] [-D name[=value]] [...] [-E] [-g] [-I directory ...]
       [-L directory ...] [-o outfile] [-O] [-s] [-U name ...] operand ...
       where operand is one or more of file.c, file.o, file.a
       or -llibrary
Makefile:42: recipe for target 'main.o' failed
make: *** [all] Error 2

gperciva commented 4 years ago

This arose earlier: https://github.com/Tarsnap/spiped/issues/181. At the time we ended up closing the issue, but I'm downloading openSUSE now to investigate further.

gperciva commented 4 years ago

Yes, I can confirm that openSUSE violates the POSIX spec for c99 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html. I'm looking into options.

For now, please use:

make CFLAGS=-O
cperciva commented 4 years ago

Reported to openSUSE: https://bugzilla.opensuse.org/show_bug.cgi?id=1156949

gperciva commented 4 years ago

@eastspidar: a better workaround is to use

make CC=cc

(or clang if that's your preference), to avoid the broken c99.

gperciva commented 4 years ago

@cperciva I don't think there's much more that we can do with this, other than warning people with https://github.com/Tarsnap/spiped/pull/236. It might be worth leaving this as an open issue for the next few weeks so that if anybody else runs into it they can easily find the answer.

Code-wise, I have a branch with posix-cflags-default.sh, which checks the $CFLAGS_DEFAULT and replaces them with -O if necessary... but it's not necessarily a POSIX issue. I mean, in this particular case, sure it is -- but if somebody decides that they'd like to set CFLAGS_DEFAULT=-fsantizer=address, it's not a POSIX failure if their compiler doesn't understand it, and automatically replacing that with -O would be rather surprising.

Then I considered just removing the "POSIX" string from those checks, and making a generic "your compiler doesn't understand the CFLAGS that you selected"... but that's very close to the existing build failure. It doesn't seem worth it to increase the build-system complexity just to have a (potentially) clearer warning for this case.

cperciva commented 4 years ago

We could check for "c99 -O2 fails" and "c99 -O succeeds" and remove -O2 from CFLAGS_DEFAULT in that case. It's easy to strip out a single option: FOO=${FOO%%-O2*}${FOO#*-O2}

cperciva commented 4 years ago

@eastspidar Can you check whether "make CFLAGS=-O" works? I just realized that stripping out -O2 might not be enough, since openSUSE's broken "c99" (which is actually c89) is probably disabling other C99 functionality (vardic macros, inline functions...) which we rely upon.

cperciva commented 4 years ago

@eastspidar Alternatively, check out the filter-O2 branch and let me know if that builds. :-)

gperciva commented 4 years ago

@cperciva @eastspidar I already checked, and make CFLAGS=-O works on OpenSUSE. The posixfail-cflags and filter-O2 branches are both fine.

gperciva commented 4 years ago

Both branches fail to build any of the non-CPUID cpusupport files, because OpenSUSE's c99 doesn't recognize any -m compiler options (such as -maes, -msse4.2).

That's not necessarily a dealbreaker, but some people might find it surprising if they were expecting to have hardware support.

gperciva commented 4 years ago

We get the expected cpusupport when using

make CC=cc

and of course they're also supported with gcc or clang.

cperciva commented 4 years ago

I don't mind if OpenSUSE users don't get CPU feature support; if they have a compiler which doesn't support -O2 they shouldn't expect to get good performance anyway! As long as we're warning them about their c99 being broken, I think it's fine.

gperciva commented 4 years ago

Their cc supports -O2 perfectly fine. It's only c99 that's broken. (On a tangent: I'm intrigued that FreeBSD uses cc rather than c99 for POSIX makefiles.)

About filter-O2 in particular,

cperciva commented 4 years ago

FreeBSD's ${CC} is currently cc due to a decades-old bug in our .POSIX handling. Basically, we set the standard definitions before "tasting" the Makefile to determine whether it wants to be treated as strict POSIX or not. :-/

But I believe that FreeBSD's cc now does everything which c99 is supposed to do (I added special handling for -lxnet in 2015, which was a problem for a long time) and I don't think POSIX requires that ${CC} is c99, only that you get the same results as if it were -- so I don't consider that to be a critical problem.

I considered replacing -O2 with -O but thought that "strip out option which causes problems" might be a mechanism which would be useful in the future. Also, users are more likely to notice and complain if they get a big performance hit than a small one. ;-)

I don't mind having a separate file, and I thought it would be clearer this way. Yes, it should be in .gitignore.

I went with "make's CC" because that's the phrasing we use in posix-l.sh.

ultra-violets commented 4 years ago

@eastspidar: a better workaround is to use

make CC=cc

(or clang if that's your preference), to avoid the broken c99.

@gperciva thanks a lot. It worked fine.