Closed ultra-violets closed 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.
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
Reported to openSUSE: https://bugzilla.opensuse.org/show_bug.cgi?id=1156949
@eastspidar: a better workaround is to use
make CC=cc
(or clang
if that's your preference), to avoid the broken c99
.
@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.
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}
@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.
@eastspidar Alternatively, check out the filter-O2
branch and let me know if that builds. :-)
@cperciva @eastspidar I already checked, and make CFLAGS=-O
works on OpenSUSE. The posixfail-cflags
and filter-O2
branches are both fine.
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.
We get the expected cpusupport when using
make CC=cc
and of course they're also supported with gcc
or clang
.
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.
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,
-O2
with -O
if it originates from CFLAGS_DEFAULT
, but if you want to mostly-silently reject it, ok. ("mostly-silently" because very few people will notice the warning flying by their screen.)cflags-filter.sh
on the vast majority of platforms? I'd rather put that functionality in posix-flags.sh
..gitignore
.echo "WARNING: POSIX violation: ${CC} does not accept -O2" 1>&2
as the error message (instead of "make's CC
")
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
.
@eastspidar: a better workaround is to use
make CC=cc
(or
clang
if that's your preference), to avoid the brokenc99
.
@gperciva thanks a lot. It worked fine.
The src can not build successfully in SELS/openSUSE. Maybe the paramteters of gcc.
But it can be successful in redhat/centos.