xxHash icon indicating copy to clipboard operation
xxHash copied to clipboard

RHEL7 make issue,I can build it from source,but I can't test it.

Open ddknight opened this issue 6 months ago • 3 comments

My Environment is Red Hat Enterprise Linux Server release 7.9 (Maipo) x86_64 version. [PVVMOF0026:root][/opt/src/xxHash-0.8.3]>gcc -version gcc: error: unrecognized command line option ‘-version’ gcc: fatal error: no input files compilation terminated. [PVVMOF0026:root][/opt/src/xxHash-0.8.3]>gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I build xxHash-0.8.3 from tar ball source. [PVVMOF0026:root][/opt/src/xxHash-0.8.3]>make CFLAGS="-std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic" cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -c -o xxhash.o xxhash.c ar rcs libxxhash.a xxhash.o cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic xxhash.c -shared -Wl,-soname=libxxhash.so.0 -o libxxhash.so.0.8.3 ln -sf libxxhash.so.0.8.3 libxxhash.so.0 ln -sf libxxhash.so.0.8.3 libxxhash.so cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xxhsum.o cli/xxhsum.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_os_specific.o cli/xsum_os_specific.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_arch.o cli/xsum_arch.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_output.o cli/xsum_output.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_sanity_check.o cli/xsum_sanity_check.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_bench.o cli/xsum_bench.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o xxh_x86dispatch.o xxh_x86dispatch.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 xxhash.o cli/xxhsum.o cli/xsum_os_specific.o cli/xsum_arch.o cli/xsum_output.o cli/xsum_sanity_check.o cli/xsum_bench.o xxh_x86dispatch.o -o xxhsum ln -sf xxhsum xxh32sum ln -sf xxhsum xxh64sum ln -sf xxhsum xxh128sum ln -sf xxhsum xxh3sum

When I start make test,it show this: [PVVMOF0026:root][/opt/src/xxHash-0.8.3]>make CFLAGS="-std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic" cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -c -o xxhash.o xxhash.c ar rcs libxxhash.a xxhash.o cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic xxhash.c -shared -Wl,-soname=libxxhash.so.0 -o libxxhash.so.0.8.3 ln -sf libxxhash.so.0.8.3 libxxhash.so.0 ln -sf libxxhash.so.0.8.3 libxxhash.so cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xxhsum.o cli/xxhsum.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_os_specific.o cli/xsum_os_specific.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_arch.o cli/xsum_arch.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_output.o cli/xsum_output.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_sanity_check.o cli/xsum_sanity_check.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o cli/xsum_bench.o cli/xsum_bench.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 -c -o xxh_x86dispatch.o xxh_x86dispatch.c cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXHSUM_DISPATCH=1 xxhash.o cli/xxhsum.o cli/xsum_os_specific.o cli/xsum_arch.o cli/xsum_output.o cli/xsum_sanity_check.o cli/xsum_bench.o xxh_x86dispatch.o -o xxhsum ln -sf xxhsum xxh32sum ln -sf xxhsum xxh64sum ln -sf xxhsum xxh128sum ln -sf xxhsum xxh3sum [PVVMOF0026:root][/opt/src/xxHash-0.8.3]>make CFLAGS="-std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic" test cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXH_INLINE_ALL cli/xxhsum.c -o xxhsum_inlinedXXH cc -c xxhash.c cc -DXXH_NAMESPACE=TEST_ -c xxhash.c -o xxhash2.o cc xxhash.o xxhash2.o cli/xxhsum.c cli/xsum_os_specific.c cli/xsum_arch.c cli/xsum_output.c cli/xsum_sanity_check.c cli/xsum_bench.c -o xxhsum2 # will fail if one namespace missing (symbol collision) rm -f *.o xxhsum2 # clean make -C tests test_sanity make[1]: Entering directory /opt/src/xxHash-0.8.3/tests' cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic sanity_test.c -o sanity_test ./sanity_test OK. (passes 49948 tests) make[1]: Leaving directory `/opt/src/xxHash-0.8.3/tests'

stdin

If you get "Wrong parameters" on Emscripten+Node.js, recompile with NODE_JS=1

./xxhsum < xxhash.c 5ffb01494ce73724 stdin

multiple files

./xxhsum xxhash.* 5ffb01494ce73724 xxhash.c 33c1f3c9184bb74a xxhash.h

internal bench

./xxhsum -bi0 xxhsum 0.8.3 by Yann Collet compiled as 64-bit x86 autoVec (SSE2 detected) little endian with GCC 4.8.5 20150623 (Red Hat 4.8.5-44) Sample of 100 KB...
1#XXH32 : 102400 -> inf it/s ( inf MB/s)
3#XXH64 : 102400 -> inf it/s ( inf MB/s)
5#XXH3_64b : 102400 -> inf it/s ( inf MB/s)
11#XXH128 : 102400 -> inf it/s ( inf MB/s)

long bench command

./xxhsum --benchmark-all -i0 xxhsum 0.8.3 by Yann Collet compiled as 64-bit x86 autoVec (SSE2 detected) little endian with GCC 4.8.5 20150623 (Red Hat 4.8.5-44) Sample of 100 KB...
1#XXH32 : 102400 -> inf it/s ( inf MB/s)
2#XXH32 unaligned : 102400 -> inf it/s ( inf MB/s)
3#XXH64 : 102400 -> inf it/s ( inf MB/s)
4#XXH64 unaligned : 102400 -> inf it/s ( inf MB/s)
5#XXH3_64b : 102400 -> inf it/s ( inf MB/s)
6#XXH3_64b unaligned : 102400 -> inf it/s ( inf MB/s)
7#XXH3_64b w/seed : 102400 -> inf it/s ( inf MB/s)
8#XXH3_64b w/seed unaligned : 102400 -> inf it/s ( inf MB/s)
9#XXH3_64b w/secret : 102400 -> inf it/s ( inf MB/s)
10#XXH3_64b w/secret unaligned : 102400 -> inf it/s ( inf MB/s)
11#XXH128 : 102400 -> inf it/s ( inf MB/s)
12#XXH128 unaligned : 102400 -> inf it/s ( inf MB/s)
13#XXH128 w/seed : 102400 -> inf it/s ( inf MB/s)
14#XXH128 w/seed unaligned : 102400 -> inf it/s ( inf MB/s)
15#XXH128 w/secret : 102400 -> inf it/s ( inf MB/s)
16#XXH128 w/secret unaligned : 102400 -> inf it/s ( inf MB/s)
17#XXH32_stream : 102400 -> inf it/s ( inf MB/s)
18#XXH32_stream unaligned : 102400 -> inf it/s ( inf MB/s)
19#XXH64_stream : 102400 -> inf it/s ( inf MB/s)
20#XXH64_stream unaligned : 102400 -> inf it/s ( inf MB/s)
21#XXH3_stream : 102400 -> inf it/s ( inf MB/s)
22#XXH3_stream unaligned : 102400 -> inf it/s ( inf MB/s)
23#XXH3_stream w/seed : 102400 -> inf it/s ( inf MB/s)
24#XXH3_stream w/seed unaligned : 102400 -> inf it/s ( inf MB/s)
25#XXH128_stream : 102400 -> inf it/s ( inf MB/s)
26#XXH128_stream unaligned : 102400 -> inf it/s ( inf MB/s)
27#XXH128_stream w/seed : 102400 -> inf it/s ( inf MB/s)
28#XXH128_stream w/seed unaligne : 102400 -> inf it/s ( inf MB/s)

bench multiple variants

./xxhsum -b1,2,3 -i0 xxhsum 0.8.3 by Yann Collet compiled as 64-bit x86 autoVec (SSE2 detected) little endian with GCC 4.8.5 20150623 (Red Hat 4.8.5-44) Sample of 100 KB...
1#XXH32 : 102400 -> inf it/s ( inf MB/s)
2#XXH32 unaligned : 102400 -> 10300 it/s ( 1005.9 MB/s)
3#XXH64 : 102400 -> inf it/s ( inf MB/s)

file bench

./xxhsum -bi0 xxhash.c xxhsum 0.8.3 by Yann Collet compiled as 64-bit x86 autoVec (SSE2 detected) little endian with GCC 4.8.5 20150623 (Red Hat 4.8.5-44) 1#XXH32 : 1855 -> inf it/s ( inf MB/s)
3#XXH64 : 1855 -> inf it/s ( inf MB/s)
5#XXH3_64b : 1855 -> inf it/s ( inf MB/s)
11#XXH128 : 1855 -> inf it/s ( inf MB/s)

32-bit

./xxhsum -H0 xxhash.c 623b23d3 xxhash.c

128-bit

./xxhsum -H2 xxhash.c 7615c59c2d746e27e873a692555aca2b xxhash.c

XXH3 (enforce BSD style)

./xxhsum -H3 xxhash.c | grep "XXH3" XXH3_e873a692555aca2b xxhash.c

request incorrect variant

./xxhsum -H9 xxhash.c ; test $? -eq 1 Wrong parameters

xxhsum 0.8.3 by Yann Collet Create or verify checksums using fast non-cryptographic algorithm xxHash

Usage: xxhsum [options] [files]

When no filename provided or when '-' is provided, uses stdin as input.

Options: -H# select an xxhash algorithm (default: 1) 0: XXH32 1: XXH64 2: XXH128 (also called XXH3_128bits) 3: XXH3 (also called XXH3_64bits) -c, --check read xxHash checksum from [files] and check them --filelist generate hashes for files listed in [files] -h, --help display a long help page about advanced options

....... checks completed successfully .......

xxhsum to/from pipe

./xxhsum xxhsum xxhash.c xxhash.h | ./xxhsum -c - xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -H0 xxhsum xxhash.c xxhash.h | ./xxhsum -c - xxhsum: OK xxhash.c: OK xxhash.h: OK

xxhsum -c is unable to verify checksum of file from STDIN (#470)

./xxhsum < README.md > .test.README.md.xxh ./xxhsum -c .test.README.md.xxh < README.md stdin: OK

xxhsum -q does not display "Loading" message into stderr (#251)

! ./xxhsum -q xxhsum xxhash.c xxhash.h 2>&1 | grep Loading

xxhsum does not display "Loading" message into stderr either

! ./xxhsum xxhsum xxhash.c xxhash.h 2>&1 | grep Loading

Check that xxhsum do display filename that it failed to open.

LC_ALL=C ./xxhsum nonexistent 2>&1 | grep "Error: Could not open 'nonexistent'" Error: Could not open 'nonexistent': No such file or directory.

xxhsum to/from file, shell redirection

./xxhsum xxhsum xxhash.c xxhash.h > .test.xxh64 ./xxhsum --tag xxhsum xxhash.c xxhash.h > .test.xxh64_tag ./xxhsum --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh64 ./xxhsum --tag --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh64_tag ./xxhsum -H0 xxhsum xxhash.c xxhash.h > .test.xxh32 ./xxhsum -H0 --tag xxhsum xxhash.c xxhash.h > .test.xxh32_tag ./xxhsum -H0 --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh32 ./xxhsum -H0 --tag --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh32_tag ./xxhsum -H2 xxhsum xxhash.c xxhash.h > .test.xxh128 ./xxhsum -H2 --tag xxhsum xxhash.c xxhash.h > .test.xxh128_tag ./xxhsum -H2 --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh128 ./xxhsum -H2 --tag --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh128_tag ./xxhsum -H3 xxhsum xxhash.c xxhash.h > .test.xxh3 ./xxhsum -H3 --tag xxhsum xxhash.c xxhash.h > .test.xxh3_tag ./xxhsum -H3 --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh3 ./xxhsum -H3 --tag --little-endian xxhsum xxhash.c xxhash.h > .test.le_xxh3_tag ./xxhsum -c .test.xxh* xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -c --little-endian .test.le_xxh* xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -c .test.*_tag xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK

read list of files from stdin

./xxhsum -c < .test.xxh32 xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -c < .test.xxh64 xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -c < .test.xxh128 xxhsum: OK xxhash.c: OK xxhash.h: OK ./xxhsum -c < .test.xxh3 xxhsum: OK xxhash.c: OK xxhash.h: OK cat .test.xxh* | ./xxhsum -c - xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK xxhsum: OK xxhash.c: OK xxhash.h: OK

check variant with '*' marker as second separator

sed 's/ / */' .test.xxh32 | ./xxhsum -c xxhsum: OK xxhash.c: OK xxhash.h: OK

bsd-style output

./xxhsum --tag xxhsum* | grep XXH64 XXH64 (xxhsum) = ba48433e01b4956f XXH64 (xxhsum_inlinedXXH) = 7f4bae47c43e8ff2 ./xxhsum --tag -H0 xxhsum* | grep XXH32 XXH32 (xxhsum) = 637731d9 XXH32 (xxhsum_inlinedXXH) = a3b729d2 ./xxhsum --tag -H1 xxhsum* | grep XXH64 XXH64 (xxhsum) = ba48433e01b4956f XXH64 (xxhsum_inlinedXXH) = 7f4bae47c43e8ff2 ./xxhsum --tag -H2 xxhsum* | grep XXH128 XXH128 (xxhsum) = 8866da35af12e96fd093387702096c89 XXH128 (xxhsum_inlinedXXH) = 8f77027f8fbf5af55780f8271a354c2a ./xxhsum --tag -H3 xxhsum* | grep XXH3 XXH3 (xxhsum) = d093387702096c89 XXH3 (xxhsum_inlinedXXH) = 5780f8271a354c2a ./xxhsum -H3 xxhsum* | grep XXH3_ # prefix for GNU format XXH3_d093387702096c89 xxhsum XXH3_5780f8271a354c2a xxhsum_inlinedXXH ./xxhsum --tag -H32 xxhsum* | grep XXH32 XXH32 (xxhsum) = 637731d9 XXH32 (xxhsum_inlinedXXH) = a3b729d2 ./xxhsum --tag -H64 xxhsum* | grep XXH64 XXH64 (xxhsum) = ba48433e01b4956f XXH64 (xxhsum_inlinedXXH) = 7f4bae47c43e8ff2 ./xxhsum --tag -H128 xxhsum* | grep XXH128 XXH128 (xxhsum) = 8866da35af12e96fd093387702096c89 XXH128 (xxhsum_inlinedXXH) = 8f77027f8fbf5af55780f8271a354c2a ./xxhsum --tag -H0 --little-endian xxhsum* | grep XXH32_LE XXH32_LE (xxhsum) = d9317763 XXH32_LE (xxhsum_inlinedXXH) = d229b7a3 ./xxhsum --tag -H1 --little-endian xxhsum* | grep XXH64_LE XXH64_LE (xxhsum) = 6f95b4013e4348ba XXH64_LE (xxhsum_inlinedXXH) = f28f3ec447ae4b7f ./xxhsum --tag -H2 --little-endian xxhsum* | grep XXH128_LE XXH128_LE (xxhsum) = 896c0902773893d06fe912af35da6688 XXH128_LE (xxhsum_inlinedXXH) = 2a4c351a27f88057f55abf8f7f02778f ./xxhsum --tag -H3 --little-endian xxhsum* | grep XXH3_LE XXH3_LE (xxhsum) = 896c0902773893d0 XXH3_LE (xxhsum_inlinedXXH) = 2a4c351a27f88057 ./xxhsum --tag -H32 --little-endian xxhsum* | grep XXH32_LE XXH32_LE (xxhsum) = d9317763 XXH32_LE (xxhsum_inlinedXXH) = d229b7a3 ./xxhsum --tag -H64 --little-endian xxhsum* | grep XXH64_LE XXH64_LE (xxhsum) = 6f95b4013e4348ba XXH64_LE (xxhsum_inlinedXXH) = f28f3ec447ae4b7f ./xxhsum --tag -H128 --little-endian xxhsum* | grep XXH128_LE XXH128_LE (xxhsum) = 896c0902773893d06fe912af35da6688 XXH128_LE (xxhsum_inlinedXXH) = 2a4c351a27f88057f55abf8f7f02778f

check bsd-style

./xxhsum --tag xxhsum* | ./xxhsum -c xxhsum: OK xxhsum_inlinedXXH: OK ./xxhsum --tag -H32 --little-endian xxhsum* | ./xxhsum -c xxhsum: OK xxhsum_inlinedXXH: OK

xxhsum -c warns improperly format lines.

echo '12345678 ' >>.test.xxh32 ./xxhsum -c .test.xxh32 | grep improperly 1 line is improperly formatted echo '123456789 file' >>.test.xxh64 ./xxhsum -c .test.xxh64 | grep improperly 1 line is improperly formatted

Expects "FAILED"

echo "0000000000000000 LICENSE" | ./xxhsum -c -; test $? -eq 1 LICENSE: FAILED 1 computed checksum did NOT match echo "00000000 LICENSE" | ./xxhsum -c -; test $? -eq 1 LICENSE: FAILED 1 computed checksum did NOT match

Expects "FAILED open or read"

echo "0000000000000000 test-expects-file-not-found" | ./xxhsum -c -; test $? -eq 1 stdin:1: Could not open or read 'test-expects-file-not-found': No such file or directory. 1 listed file could not be read echo "00000000 test-expects-file-not-found" | ./xxhsum -c -; test $? -eq 1 stdin:1: Could not open or read 'test-expects-file-not-found': No such file or directory. 1 listed file could not be read

--filelist

echo xxhash.c > .test.filenames ./xxhsum --filelist .test.filenames 5ffb01494ce73724 xxhash.c

--filelist from stdin

cat .test.filenames | ./xxhsum --filelist 5ffb01494ce73724 xxhash.c ---- test strict C90 compilation [xxh32 only] ---- rm -f xxhash.o cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -DXXH_NO_LONG_LONG xxhash.c -c nm xxhash.o | grep XXH64 ; test $? -eq 1 rm -f xxhash.o CFLAGS=-Werror make -C tests/bench make[1]: Entering directory /opt/src/xxHash-0.8.3/tests/bench' cc -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -I../.. -c -o main.o main.c main.c: In function ‘readIntFromChar’: main.c:57:9: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion] result += (unsigned)(**stringPtr - '0'); ^ main.c:57:16: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion] result += (unsigned)(**stringPtr - '0'); ^ cc1: all warnings being treated as errors make[1]: *** [main.o] Error 1 make[1]: Leaving directory /opt/src/xxHash-0.8.3/tests/bench' make: *** [test-tools] Error 2`

What can I do with this, I just want to use xxHash for rsync upgrade.

ddknight avatar Aug 19 '25 03:08 ddknight

I think this warning (as an error) is simply gcc-4.8's bug. Please refer "C99 §6.3.1.8 Usual arithmetic conversions".

  • By §6.3.1.8 p2, rank of unsigned and signed int is same.
  • Therefore signed int is implicitly converted to unsigned.
  • So result is implicitly converted to unsigned.
  • As a result, it's interpreted as unsinged + unsigned arithmetic.
  • After that, unsigned int is converted to int.
  • But rhs unsigned is always [0,255], by C language standards, this is generally regarded as safe.

What can I do with this, I just want to use xxHash for rsync upgrade.

This error is caused by a bug of your compiler (gcc-4.8 from RHEL). Technically, it's not our failure. Please ask RHEL team directly.


If you can understand and change the Makefile, removing -Werror from CFLAGS should be fine.


Some thoughts:

  • Since we've been testing gcc 4.8, this is a surprise issue.
  • result += (int)(**stringPtr - '0') would be nice for buggy compilers such as gcc 4.8.
  • Although wider compatibility is absolutely good, should we test gcc 4.8? Note that RedHat will "support" RHEL 7 (with gcc 4.8) until 2029.

t-mat avatar Aug 19 '25 15:08 t-mat

My casual rule of thumb for compiler support is ~ 10 years, or until practical, which is more commonly the main driver.

gcc 4.8 is both > 10 years old (2013) and not simple to test (not bundled with any of the runner images). So, I would prefer not to.

Regarding the fix itself, if what it takes is just change one line of code, and it doesn't make the resulting code look ugly or unreadable, then yes sure, this is a modification we can do.

Cyan4973 avatar Aug 19 '25 16:08 Cyan4973

I was wrong. I think we should recommend to use MOREFLAGS for compatibility issue. In this case, MOREFLAGS=-std=c99 should be fine.

Setup gcc-4.8 in Ubuntu 24.04

I've followed this answer by karel.

cd
mkdir install_g++-4.8
cd    install_g++-4.8
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/g++-4.8_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libstdc++-4.8-dev_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/gcc-4.8-base_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/gcc-4.8_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libgcc-4.8-dev_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/cpp-4.8_4.8.5-4ubuntu8_amd64.deb
curl -sOL http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-4.8/libasan0_4.8.5-4ubuntu8_amd64.deb
chmod 777 *.deb
sudo apt update
sudo apt install ./gcc-4.8_4.8.5-4ubuntu8_amd64.deb ./gcc-4.8-base_4.8.5-4ubuntu8_amd64.deb ./libstdc++-4.8-dev_4.8.5-4ubuntu8_amd64.deb ./cpp-4.8_4.8.5-4ubuntu8_amd64.deb ./libgcc-4.8-dev_4.8.5-4ubuntu8_amd64.deb ./libasan0_4.8.5-4ubuntu8_amd64.deb ./g++-4.8_4.8.5-4ubuntu8_amd64.deb

git clone --depth 1 --branch v0.8.3 https://github.com/Cyan4973/xxHash

We should not change our code to fix this issue

The error can be reproduced by the following command:

# ~/install_g++-4.8/xxHash$ ( cd tests/bench; gcc-4.8 -std=c99 -fPIC -O3 -Wall -Wextra -Wconversion -Werror -pedantic -I../.. -c -o main.o main.c )
main.c: In function ‘readIntFromChar’:
main.c:57:9: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
         result += (unsigned)(**stringPtr - '0');
         ^
main.c:57:16: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
         result += (unsigned)(**stringPtr - '0');
                ^
cc1: all warnings being treated as errors

Actually, this warning as an error is caused by -Wconversion which is explicitly given by user. Since we don't use -Wconversion for tests/bench/main.c. We can't keep compatibility with it (and should not change it).

Possible solution

In this case, using MOREFLAGS may be better option.

make CC=gcc-4.8 CXX=g++-4.8 MOREFLAGS="-std=c99"
make CC=gcc-4.8 CXX=g++-4.8 MOREFLAGS="-std=c99" test

# OK.  0 error/warning

t-mat avatar Aug 20 '25 11:08 t-mat