Skip to content

Commit

Permalink
Globally add -std=c99 to compiler flags, but only if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
magnumripper committed Dec 2, 2024
1 parent 7c2dbe9 commit 4a9230c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ zip2john.o: zip2john.c arch.h common.h memory.h jumbo.h formats.h params.h misc.
######## End auto-generated

princeprocessor:
$(CC) @CFLAGS@ @JOHN_NO_SIMD@ @CFLAGS_EXTRA@ @OPENSSL_CFLAGS@ @OPENMP_CFLAGS@ @HAVE_MPI@ @PTHREAD_CFLAGS@ $(CPPFLAGS) $(OPT_NORMAL) -std=c99 -DLINUX pp.c $(LDFLAGS) -o ../run/pp
$(CC) @CFLAGS@ @JOHN_NO_SIMD@ @CFLAGS_EXTRA@ @OPENSSL_CFLAGS@ @OPENMP_CFLAGS@ @HAVE_MPI@ @PTHREAD_CFLAGS@ $(CPPFLAGS) $(OPT_NORMAL) -DLINUX pp.c $(LDFLAGS) -o ../run/pp

pp.o: pp.c autoconfig.h arch.h mem_map.h os.h os-autoconf.h jumbo.h mmap-windows.c memory.h mpz_int128.h int128.h misc.h config.h params.h common.h path.h signals.h loader.h list.h formats.h logger.h status.h recovery.h options.h getopt.h external.h compiler.h cracker.h john.h unicode.h prince.h rpp.h rules.h mask.h
$(CC) $(CFLAGS) $(OPT_NORMAL) -DJTR_MODE -std=c99 -c pp.c
$(CC) $(CFLAGS) $(OPT_NORMAL) -DJTR_MODE -c pp.c

version.h: find_version

Expand Down
50 changes: 50 additions & 0 deletions src/configure
Original file line number Diff line number Diff line change
Expand Up @@ -6075,6 +6075,56 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu



if test 1 -gt 0; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -std=c99" >&5
$as_echo_n "checking if $CC supports -std=c99... " >&6; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

ac_saved_cflags="$CFLAGS"
CFLAGS="-Werror -std=c99"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
if test "1" -gt 0; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
CFLAGS_EX="$CFLAGS_EX -std=c99"

else
if test 1 -gt 0; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "1" = 2; then :
as_fn_error $? "Not supported by compiler" "$LINENO" 5
fi

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$ac_saved_cflags"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu



if (test "x$asan" != xyes); then
warn="-Wstringop-truncation"
nowarn="-Wno-stringop-truncation"
Expand Down
3 changes: 3 additions & 0 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ fi
CFLAGS_EX=""
JTR_FLAG_CHECK([-Wall], 1)
dnl Add -std=c99 if supported
JTR_FLAG_CHECK([-std=c99], 1)
dnl False positives from gcc 8
if (test "x$asan" != xyes); then
JTR_NOWARN_CHECK([stringop-truncation], 1)
Expand Down
2 changes: 1 addition & 1 deletion src/mbedtls/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CC = @CC@
AS = @CC@
LD = @CC@
CPP = @CC@
CFLAGS = -c -DAC_BUILT @CC_CPU@ @CC_MAIN_CPU@ @CFLAGS@ @JOHN_NO_SIMD@ @CFLAGS_EXTRA@ @OPENSSL_CFLAGS@ @OPENMP_CFLAGS@ @HAVE_MPI@ @PTHREAD_CFLAGS@ @CPPFLAGS@ -std=c99
CFLAGS = -c -DAC_BUILT @CC_CPU@ @CC_MAIN_CPU@ @CFLAGS@ @JOHN_NO_SIMD@ @CFLAGS_EXTRA@ @OPENSSL_CFLAGS@ @OPENMP_CFLAGS@ @HAVE_MPI@ @PTHREAD_CFLAGS@ @CPPFLAGS@
ASFLAGS = @ASFLAGS@ -c @EXTRA_AS_FLAGS@
LDFLAGS = @LDFLAGS@
AR = @AR@
Expand Down

0 comments on commit 4a9230c

Please sign in to comment.