Skip to content

Commit

Permalink
Fix compiler flag checks
Browse files Browse the repository at this point in the history
Ref #34
  • Loading branch information
animetosho authored and dnzbk committed Nov 12, 2024
1 parent a802d06 commit f2658a7
Show file tree
Hide file tree
Showing 11 changed files with 441 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ perf.*
.#*
\#*#
.~lock.*#

.vscode
9 changes: 7 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ libpar2_a_SOURCES = src/crc.cpp src/crc.h \
src/reedsolomon.cpp src/reedsolomon.h \
src/verificationhashtable.cpp src/verificationhashtable.h \
src/verificationpacket.cpp src/verificationpacket.h \
src/libpar2.cpp src/libpar2.h src/libpar2internal.h
src/libpar2.cpp src/libpar2.h src/libpar2internal.h \
src/utf8.cpp src/utf8.h
libpar2_a_DEPENDENCIES = \
libparpar_gf16.a libparpar_gf16_sse2.a libparpar_gf16_ssse3.a libparpar_gf16_avx.a libparpar_gf16_avx2.a libparpar_gf16_avx512.a libparpar_gf16_vbmi.a libparpar_gf16_gfni.a libparpar_gf16_gfni_avx2.a libparpar_gf16_gfni_avx512.a libparpar_gf16_gfni_avx10.a libparpar_gf16_clmul.a libparpar_gf16_avx2_clmul.a libparpar_gf16_vpclmul.a libparpar_gf16_vpclgfni.a libparpar_gf16_neon.a libparpar_gf16_neonsha3.a libparpar_gf16_sve.a libparpar_gf16_sve2.a libparpar_gf16_rvv.a libparpar_gf16_rvv_zvbc.a \
libparpar_hasher.a libparpar_hasher_sse2.a libparpar_hasher_clmul.a libparpar_hasher_xop.a libparpar_hasher_bmi1.a libparpar_hasher_avx2.a libparpar_hasher_avx512.a libparpar_hasher_avx512vl.a libparpar_hasher_armcrc.a libparpar_hasher_neon.a libparpar_hasher_neoncrc.a libparpar_hasher_sve2.a libparpar_hasher_zbkc.a
Expand Down Expand Up @@ -277,7 +278,7 @@ EXTRA_DIST = ROADMAP \

# Programs that need to be compiled for the test suite.
# These are the unit tests.
check_PROGRAMS = tests/letype_test tests/crc_test tests/md5_test tests/diskfile_test tests/libpar2_test tests/commandline_test tests/descriptionpacket_test tests/criticalpacket_test tests/reedsolomon_test tests/galois_test
check_PROGRAMS = tests/letype_test tests/crc_test tests/md5_test tests/diskfile_test tests/libpar2_test tests/commandline_test tests/descriptionpacket_test tests/criticalpacket_test tests/reedsolomon_test tests/galois_test tests/utf8_test

tests_letype_test_SOURCES = src/letype_test.cpp src/letype.h

Expand All @@ -288,6 +289,7 @@ tests_md5_test_SOURCES = src/md5_test.cpp src/md5.cpp src/md5.h
tests_md5_test_LDADD = libpar2.a

tests_diskfile_test_SOURCES = src/diskfile_test.cpp src/diskfile.cpp src/diskfile.h
tests_diskfile_test_LDADD = libpar2.a

tests_libpar2_test_SOURCES = src/libpar2_test.cpp src/libpar2.h
tests_libpar2_test_LDADD = libpar2.a
Expand All @@ -305,6 +307,8 @@ tests_reedsolomon_test_SOURCES = src/reedsolomon_test.cpp src/reedsolomon.cpp sr

tests_galois_test_SOURCES = src/galois_test.cpp src/galois.cpp src/galois.h

tests_utf8_test_SOURCES = src/utf8_test.cpp src/utf8.cpp src/utf8.h


# List of all tests.
# tests/test* are integration tests that use the binary.
Expand Down Expand Up @@ -338,6 +342,7 @@ TESTS = tests/test1 \
tests/test26 \
tests/test27 \
tests/test28 \
tests/utf8_test \
tests/unit_tests

install-exec-hook :
Expand Down
48 changes: 24 additions & 24 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -85,78 +85,78 @@ AC_LANG_PUSH(C)
dnl Platform detection / flags supported by compiler
m4_include([m4/ax_check_compile_flag.m4])
AX_CHECK_COMPILE_FLAG([-msse2], , , [-Werror])
AM_CONDITIONAL([HAS_SSE2], [test x$ax_cv_check_cxxflags__Werror__msse2 = xyes])
AM_CONDITIONAL([HAS_SSE2], [test x$ax_cv_check_cflags__Werror__msse2 = xyes])
AM_COND_IF([HAS_SSE2], [AC_SUBST(CFLAGS_SSE2, "-msse2")])
AX_CHECK_COMPILE_FLAG([-mssse3], , , [-Werror])
AM_CONDITIONAL([HAS_SSSE3], [test x$ax_cv_check_cxxflags__Werror__mssse3 = xyes])
AM_CONDITIONAL([HAS_SSSE3], [test x$ax_cv_check_cflags__Werror__mssse3 = xyes])
AM_COND_IF([HAS_SSSE3], [AC_SUBST(CFLAGS_SSSE3, "-mssse3")])
AX_CHECK_COMPILE_FLAG([-mpclmul], , , [-Werror])
AM_CONDITIONAL([HAS_PCLMUL], [test x$ax_cv_check_cxxflags__Werror__mpclmul = xyes])
AM_CONDITIONAL([HAS_PCLMUL], [test x$ax_cv_check_cflags__Werror__mpclmul = xyes])
AM_COND_IF([HAS_PCLMUL], [AC_SUBST(CFLAGS_PCLMUL, "-mpclmul -msse4.1")])
AX_CHECK_COMPILE_FLAG([-mavx], , , [-Werror])
AM_CONDITIONAL([HAS_AVX], [test x$ax_cv_check_cxxflags__Werror__mavx = xyes])
AM_CONDITIONAL([HAS_AVX], [test x$ax_cv_check_cflags__Werror__mavx = xyes])
AM_COND_IF([HAS_AVX], [AC_SUBST(CFLAGS_AVX, "-mavx")])
AX_CHECK_COMPILE_FLAG([-mxop], , , [-Werror])
AM_CONDITIONAL([HAS_XOP], [test x$ax_cv_check_cxxflags__Werror__mxop = xyes])
AM_CONDITIONAL([HAS_XOP], [test x$ax_cv_check_cflags__Werror__mxop = xyes])
AM_COND_IF([HAS_XOP], [AC_SUBST(CFLAGS_XOP, "-mavx -mxop")])
AX_CHECK_COMPILE_FLAG([-mbmi], , , [-Werror])
AM_CONDITIONAL([HAS_BMI1], [test x$ax_cv_check_cxxflags__Werror__mbmi = xyes])
AM_CONDITIONAL([HAS_BMI1], [test x$ax_cv_check_cflags__Werror__mbmi = xyes])
AM_COND_IF([HAS_BMI1], [AC_SUBST(CFLAGS_BMI1, "-mavx -mbmi -mpclmul")])
AX_CHECK_COMPILE_FLAG([-mavx2], , , [-Werror])
AM_CONDITIONAL([HAS_AVX2], [test x$ax_cv_check_cxxflags__Werror__mavx2 = xyes])
AM_CONDITIONAL([HAS_AVX2], [test x$ax_cv_check_cflags__Werror__mavx2 = xyes])
AM_COND_IF([HAS_AVX2], [AC_SUBST(CFLAGS_AVX2, "-mavx2")])
AX_CHECK_COMPILE_FLAG([-mavx512vl -mavx512bw], , , [-Werror])
AM_CONDITIONAL([HAS_AVX512], [test x$ax_cv_check_cxxflags__Werror__mavx512vl__mavx512bw = xyes])
AM_CONDITIONAL([HAS_AVX512], [test x$ax_cv_check_cflags__Werror__mavx512vl__mavx512bw = xyes])
AM_COND_IF([HAS_AVX512], [AC_SUBST(CFLAGS_AVX512, "-mavx512vl -mavx512bw")])
AM_COND_IF([HAS_AVX512], [AC_SUBST(CFLAGS_AVX512F, "-mavx512f")])
AM_COND_IF([HAS_AVX512], [AC_SUBST(CFLAGS_AVX512_HASHER, "-mavx512vl -mavx512bw -mbmi2 -mpclmul")])
AX_CHECK_COMPILE_FLAG([-mavx512vbmi], , , [-Werror])
AM_CONDITIONAL([HAS_VBMI], [test x$ax_cv_check_cxxflags__Werror__mavx512vbmi = xyes])
AM_CONDITIONAL([HAS_VBMI], [test x$ax_cv_check_cflags__Werror__mavx512vbmi = xyes])
AM_COND_IF([HAS_VBMI], [AC_SUBST(CFLAGS_VBMI, "-mavx512vl -mavx512vbmi")])
AX_CHECK_COMPILE_FLAG([-mgfni], , , [-Werror])
AM_CONDITIONAL([HAS_GFNI], [test x$ax_cv_check_cxxflags__Werror__mgfni = xyes])
AM_CONDITIONAL([HAS_GFNI], [test x$ax_cv_check_cflags__Werror__mgfni = xyes])
AM_COND_IF([HAS_GFNI], [AC_SUBST(CFLAGS_GFNI, "-mgfni -mssse3")])
AX_CHECK_COMPILE_FLAG([-mvpclmulqdq], , , [-Werror])
AM_CONDITIONAL([HAS_VPCLMUL], [test x$ax_cv_check_cxxflags__Werror__mvpclmulqdq = xyes])
AM_CONDITIONAL([HAS_VPCLMUL], [test x$ax_cv_check_cflags__Werror__mvpclmulqdq = xyes])
AM_COND_IF([HAS_VPCLMUL], [AC_SUBST(CFLAGS_VPCLMUL, "-mvpclmulqdq -mavx2")])
AX_CHECK_COMPILE_FLAG([-mno-evex512], , , [-Werror])
AM_CONDITIONAL([HAS_AVX10], [test x$ax_cv_check_cxxflags__Werror__mno_evex512 = xyes])
AM_CONDITIONAL([HAS_AVX10], [test x$ax_cv_check_cflags__Werror__mno_evex512 = xyes])
AM_COND_IF([HAS_AVX10], [AC_SUBST(CFLAGS_AVX10, "-mavx512vl -mavx512bw -mno-evex512")])
AX_CHECK_COMPILE_FLAG([-mfpu=neon -march=armv7-a], , , [-Werror])
AM_CONDITIONAL([HAS_NEON], [test x$ax_cv_check_cxxflags__Werror__mfpu_neon__march_armv7_a = xyes])
AM_CONDITIONAL([HAS_NEON], [test x$ax_cv_check_cflags__Werror__mfpu_neon__march_armv7_a = xyes])
AM_COND_IF([HAS_NEON], [AC_SUBST(CFLAGS_NEON, "-mfpu=neon -fno-lto -march=armv7-a")])
AX_CHECK_COMPILE_FLAG([-mfpu=fp-armv8], , , [-Werror])
AM_CONDITIONAL([HAS_FPARMv8], [test x$ax_cv_check_cxxflags__Werror__mfpu_fp_armv8 = xyes])
AM_CONDITIONAL([HAS_FPARMv8], [test x$ax_cv_check_cflags__Werror__mfpu_fp_armv8 = xyes])
AM_COND_IF([HAS_FPARMv8], [AC_SUBST(CFLAGS_ARMCRC_FP, "-mfpu=fp-armv8")])
AX_CHECK_COMPILE_FLAG([-march=armv8-a+sve], , , [-Werror])
AM_CONDITIONAL([HAS_SVE], [test x$ax_cv_check_cxxflags__Werror__march_armv8_apsve = xyes])
AM_CONDITIONAL([HAS_SVE], [test x$ax_cv_check_cflags__Werror__march_armv8_apsve = xyes])
AM_COND_IF([HAS_SVE], [AC_SUBST(CFLAGS_SVE, "-march=armv8-a+sve")])
AX_CHECK_COMPILE_FLAG([-march=armv8-a+sve2], , , [-Werror])
AM_CONDITIONAL([HAS_SVE2], [test x$ax_cv_check_cxxflags__Werror__march_armv8_apsve2 = xyes])
AM_CONDITIONAL([HAS_SVE2], [test x$ax_cv_check_cflags__Werror__march_armv8_apsve2 = xyes])
AM_COND_IF([HAS_SVE2], [AC_SUBST(CFLAGS_SVE2, "-march=armv8-a+sve2")])
AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc], , , [-Werror])
AM_CONDITIONAL([HAS_ARMCRC], [test x$ax_cv_check_cxxflags__Werror__march_armv8_apcrc = xyes])
AM_CONDITIONAL([HAS_ARMCRC], [test x$ax_cv_check_cflags__Werror__march_armv8_apcrc = xyes])
AM_COND_IF([HAS_ARMCRC], [AC_SUBST(CFLAGS_ARMCRC, "-march=armv8-a+crc")])
AX_CHECK_COMPILE_FLAG([-march=armv8.2-a+sha3], , , [-Werror])
AM_CONDITIONAL([HAS_NEONSHA3], [test x$ax_cv_check_cxxflags__Werror__march_armv8_2_apsha3 = xyes])
AM_CONDITIONAL([HAS_NEONSHA3], [test x$ax_cv_check_cflags__Werror__march_armv8_2_apsha3 = xyes])
AM_COND_IF([HAS_NEONSHA3], [AC_SUBST(CFLAGS_NEONSHA3, "-march=armv8.2-a+sha3")])
AX_CHECK_COMPILE_FLAG([-march=rv64gcv], , , [-Werror])
AM_CONDITIONAL([HAS_RV64V], [test x$ax_cv_check_cxxflags__Werror__march_rv64gcv = xyes])
AM_CONDITIONAL([HAS_RV64V], [test x$ax_cv_check_cflags__Werror__march_rv64gcv = xyes])
AM_COND_IF([HAS_RV64V], [AC_SUBST(CFLAGS_RV64V, "-march=rv64gcv")])
AX_CHECK_COMPILE_FLAG([-march=rv32gcv], , , [-Werror])
AM_CONDITIONAL([HAS_RV32V], [test x$ax_cv_check_cxxflags__Werror__march_rv32gcv = xyes])
AM_CONDITIONAL([HAS_RV32V], [test x$ax_cv_check_cflags__Werror__march_rv32gcv = xyes])
AM_COND_IF([HAS_RV32V], [AC_SUBST(CFLAGS_RV32V, "-march=rv32gcv")])
AX_CHECK_COMPILE_FLAG([-march=rv64gc_zbkc], , , [-Werror])
AM_CONDITIONAL([HAS_RV64ZBKC], [test x$ax_cv_check_cxxflags__Werror__march_rv64gc_zbkc = xyes])
AM_CONDITIONAL([HAS_RV64ZBKC], [test x$ax_cv_check_cflags__Werror__march_rv64gc_zbkc = xyes])
AM_COND_IF([HAS_RV64ZBKC], [AC_SUBST(CFLAGS_RV64ZBKC, "-march=rv64gc_zbkc")])
AX_CHECK_COMPILE_FLAG([-march=rv32gc_zbkc], , , [-Werror])
AM_CONDITIONAL([HAS_RV32ZBKC], [test x$ax_cv_check_cxxflags__Werror__march_rv32gc_zbkc = xyes])
AM_CONDITIONAL([HAS_RV32ZBKC], [test x$ax_cv_check_cflags__Werror__march_rv32gc_zbkc = xyes])
AM_COND_IF([HAS_RV32ZBKC], [AC_SUBST(CFLAGS_RV32ZBKC, "-march=rv32gc_zbkc")])
AX_CHECK_COMPILE_FLAG([-march=rv64gcv_zvbc], , , [-Werror])
AM_CONDITIONAL([HAS_RV64ZVBC], [test x$ax_cv_check_cxxflags__Werror__march_rv64gcv_zvbc = xyes])
AM_CONDITIONAL([HAS_RV64ZVBC], [test x$ax_cv_check_cflags__Werror__march_rv64gcv_zvbc = xyes])
AM_COND_IF([HAS_RV64ZVBC], [AC_SUBST(CFLAGS_RV64ZVBC, "-march=rv64gcv_zvbc")])
AX_CHECK_COMPILE_FLAG([-march=rv32gcv_zvbc], , , [-Werror])
AM_CONDITIONAL([HAS_RV32VBC], [test x$ax_cv_check_cxxflags__Werror__march_rv32gcv_zvbc = xyes])
AM_CONDITIONAL([HAS_RV32VBC], [test x$ax_cv_check_cflags__Werror__march_rv32gcv_zvbc = xyes])
AM_COND_IF([HAS_RV32VBC], [AC_SUBST(CFLAGS_RV32ZVBC, "-march=rv32gcv_zvbc")])

AC_CHECK_DECLS([posix_memalign], [], [AC_SUBST(CFLAGS_POSIX_SOURCE, "-D_POSIX_C_SOURCE=200112L")], [[#include <stdlib.h>]])
Expand Down
8 changes: 5 additions & 3 deletions par2cmdline.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down Expand Up @@ -144,6 +144,7 @@
<ClCompile Include="src\reedsolomon.cpp" />
<ClCompile Include="src\verificationhashtable.cpp" />
<ClCompile Include="src\verificationpacket.cpp" />
<ClCompile Include="src\utf8.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commandline.h" />
Expand Down Expand Up @@ -172,6 +173,7 @@
<ClInclude Include="src\reedsolomon.h" />
<ClInclude Include="src\verificationhashtable.h" />
<ClInclude Include="src\verificationpacket.h" />
<ClInclude Include="src\utf8.h" />
</ItemGroup>
<ItemGroup>
<None Include="AUTHORS" />
Expand Down
6 changes: 6 additions & 0 deletions par2cmdline.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
<ClCompile Include="src\libpar2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\utf8.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commandline.h">
Expand Down Expand Up @@ -170,6 +173,9 @@
<ClInclude Include="src\libpar2internal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\utf8.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="AUTHORS" />
Expand Down
8 changes: 0 additions & 8 deletions src/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,14 +1316,6 @@ bool CommandLine::ComputeRecoveryBlockCount(u32 *recoveryblockcount,
bool CommandLine::SetParFilename(string filename)
{
bool result = false;
string::size_type where;

if ((where = filename.find_first_of('*')) != string::npos ||
(where = filename.find_first_of('?')) != string::npos)
{
cerr << "par2 file must not have a wildcard in it." << endl;
return result;
}

// If we are verifying or repairing, the PAR2 file must
// already exist
Expand Down
Loading

0 comments on commit f2658a7

Please sign in to comment.