From 9d6108994ddf1c566ac347be355c9b7d2656da73 Mon Sep 17 00:00:00 2001 From: weissms Date: Sun, 8 Jan 2012 10:41:00 +0000 Subject: [PATCH] Build fix, let configure check for compiler options used for delinting. Not all gcc versions support those options and the build may therefor stop. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@43520 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- config/target.cfg.in | 4 ++ configure | 134 ++++++++++++++++++++++++++++++++++++----- configure.in | 49 +++++++++++++++ tools/crosstools/mmakefile.src | 6 ++ 4 files changed, 179 insertions(+), 14 deletions(-) diff --git a/config/target.cfg.in b/config/target.cfg.in index ab997dffaf..3e8b4a043c 100644 --- a/config/target.cfg.in +++ b/config/target.cfg.in @@ -56,6 +56,10 @@ NIX_LDFLAGS := @aros_target_nix_ldflags@ DETACH_LDFLAGS := @aros_target_detach_ldflags@ NOSTDLIB_LDFLAGS := @aros_target_nostdlib_ldflags@ +UNUSED_BUT_SET_VARIABLE_CFLAGS := @aros_cflags_unused_but_set_variable@ +ARRAY_BOUNDS_CFLAGS := @aros_cflags_array_bounds@ +ENUM_COMPARE_CFLAGS := @aros_cflags_enum_compare@ + COMPILER_LIBS := @aros_compiler_libs@ ARCH_LIBS := @aros_arch_libs@ diff --git a/configure b/configure index ec1550b54c..1c5d7c68fc 100755 --- a/configure +++ b/configure @@ -635,6 +635,9 @@ oss_library_target pci_hidd_target sdl_hidd_target x11_hidd_target +aros_cflags_enum_compare +aros_cflags_array_bounds +aros_cflags_unused_but_set_variable crosstools_cxx_target crosstools_target aros_target_strip_flags @@ -2438,7 +2441,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2586,7 +2589,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -2619,7 +2622,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -2989,7 +2992,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3104,7 +3107,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3147,7 +3150,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3206,7 +3209,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3258,7 +3261,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3899,7 +3902,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -11175,6 +11178,104 @@ if test "x-$use_no_stack_protector" = "x-yes" ; then aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector" fi + +#----------------------------------------------------------------------------- + +# Check if the target compiler supports some options used for delinting: +# -Wunused-but-set-variable +# -Warray-bounds +# -Wenum-compare + +if test "x-$crosstools" != "x-yes"; then + if test "$orig_target_cc" != "$aros_kernel_cc"; then + CC="$orig_target_cc" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} accepts -Wunused-but-set-variable" >&5 +$as_echo_n "checking whether ${CC} accepts -Wunused-but-set-variable... " >&6; } + CFLAGS=-Wunused-but-set-variable + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + aros_unused_but_set_variable="yes" +else + aros_unused_but_set_variable="no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $aros_unused_but_set_variable" >&5 +$as_echo "$aros_unused_but_set_variable" >&6; } + if test "x-$aros_unused_but_set_variable" = "x-yes" ; then + aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} accepts -Warray-bounds" >&5 +$as_echo_n "checking whether ${CC} accepts -Warray-bounds... " >&6; } + CFLAGS=-Warray-bounds + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + aros_array_bounds="yes" +else + aros_array_bounds="no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $aros_array_bounds" >&5 +$as_echo "$aros_array_bounds" >&6; } + if test "x-$aros_array_bounds" = "x-yes" ; then + aros_cflags_array_bounds=-Wno-array-bounds + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} accepts -Wenum-compare" >&5 +$as_echo_n "checking whether ${CC} accepts -Wenum-compare... " >&6; } + CFLAGS=-Wenum-compare + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + aros_enum_compare="yes" +else + aros_enum_compare="no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $aros_enum_compare" >&5 +$as_echo "$aros_enum_compare" >&6; } + if test "x-$aros_enum_compare" = "x-yes" ; then + aros_cflags_enum_compare=-Wno-enum-compare + fi +else + # We do not know which gcc version we are going to build and what we need to know + # here is different for different versions so this will be set later during the + # build of crosstools. + aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@ + aros_cflags_array_bounds=@aros_cflags_array_bounds@ + aros_cflags_enum_compare=@aros_cflags_enum_compare@ +fi + #----------------------------------------------------------------------------- # Check if we can explicitly choose older version of symbol hashing @@ -11437,7 +11538,7 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : $as_echo_n "(cached) " >&6 else @@ -12226,6 +12327,11 @@ fi +# Delinting target compiler flags + + + + # Graphics Related @@ -13089,7 +13195,7 @@ do "tools/collect-aros/env.h") CONFIG_FILES="$CONFIG_FILES tools/collect-aros/env.h" ;; "${aros_gendir}/arch/all-android/bootstrap/app/default.properties") CONFIG_FILES="$CONFIG_FILES ${aros_gendir}/arch/all-android/bootstrap/app/default.properties:arch/all-android/bootstrap/app/default.properties.in" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -13407,7 +13513,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -13435,7 +13541,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -13462,7 +13568,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac diff --git a/configure.in b/configure.in index bc1129ad48..01da4995f0 100644 --- a/configure.in +++ b/configure.in @@ -2030,6 +2030,50 @@ if test "x-$use_no_stack_protector" = "x-yes" ; then aros_kernel_cflags="$aros_kernel_cflags -fno-stack-protector" fi + +#----------------------------------------------------------------------------- + +# Check if the target compiler supports some options used for delinting: +# -Wunused-but-set-variable +# -Warray-bounds +# -Wenum-compare + +if test "x-$crosstools" != "x-yes"; then + if test "$orig_target_cc" != "$aros_kernel_cc"; then + CC="$orig_target_cc" + fi + AC_MSG_CHECKING([whether ${CC} accepts -Wunused-but-set-variable]) + CFLAGS=-Wunused-but-set-variable + AC_TRY_COMPILE(,, aros_unused_but_set_variable="yes", aros_unused_but_set_variable="no") + AC_MSG_RESULT($aros_unused_but_set_variable) + if test "x-$aros_unused_but_set_variable" = "x-yes" ; then + aros_cflags_unused_but_set_variable=-Wno-unused-but-set-variable + fi + + AC_MSG_CHECKING([whether ${CC} accepts -Warray-bounds]) + CFLAGS=-Warray-bounds + AC_TRY_COMPILE(,, aros_array_bounds="yes", aros_array_bounds="no") + AC_MSG_RESULT($aros_array_bounds) + if test "x-$aros_array_bounds" = "x-yes" ; then + aros_cflags_array_bounds=-Wno-array-bounds + fi + + AC_MSG_CHECKING([whether ${CC} accepts -Wenum-compare]) + CFLAGS=-Wenum-compare + AC_TRY_COMPILE(,, aros_enum_compare="yes", aros_enum_compare="no") + AC_MSG_RESULT($aros_enum_compare) + if test "x-$aros_enum_compare" = "x-yes" ; then + aros_cflags_enum_compare=-Wno-enum-compare + fi +else + # We do not know which gcc version we are going to build and what we need to know + # here is different for different versions so this will be set later during the + # build of crosstools. + aros_cflags_unused_but_set_variable=@aros_cflags_unused_but_set_variable@ + aros_cflags_array_bounds=@aros_cflags_array_bounds@ + aros_cflags_enum_compare=@aros_cflags_enum_compare@ +fi + #----------------------------------------------------------------------------- # Check if we can explicitly choose older version of symbol hashing @@ -2440,6 +2484,11 @@ AC_SUBST(aros_target_strip_flags) AC_SUBST(crosstools_target) AC_SUBST(crosstools_cxx_target) +# Delinting target compiler flags +AC_SUBST(aros_cflags_unused_but_set_variable) +AC_SUBST(aros_cflags_array_bounds) +AC_SUBST(aros_cflags_enum_compare) + # Graphics Related AC_SUBST(x11_hidd_target) AC_SUBST(sdl_hidd_target) diff --git a/tools/crosstools/mmakefile.src b/tools/crosstools/mmakefile.src index 0664c0630a..0c35eb420b 100644 --- a/tools/crosstools/mmakefile.src +++ b/tools/crosstools/mmakefile.src @@ -32,6 +32,9 @@ ifeq ($(AROS_TARGET_CPU), m68k) GCC_INCLUDES = $(CROSSTOOLSDIR)/lib/gcc/$(AROS_TARGET_CPU)-aros/$(GCC_VERSION)/include GCC_PATH = `LANG=en_US $(CROSSTOOLSDIR)/$(AROS_TARGET_CPU)-aros-gcc -print-search-dirs | grep "programs: =" | cut -c 12-` GCC_LANGUAGES := $(GCC_LANGUAGES),objc + GCC_UNUSED_BUT_SET_VARIABLE := -Wno-unused-but-set-variable + GCC_ARRAY_BOUNDS := -Wno-array-bounds + GCC_ENUM_COMPARE := -Wno-enum-compare else GCC_VERSION = 4.2.4 GCC_EXTRA_OPTS += --with-sysroot=$(AROS_DEVELOPMENT) @@ -108,6 +111,9 @@ tools-crosstools-gcc : tools-crosstools-includes fi @$(IF) $(TEST) -f $(gcc-installflag); then \ $(SED) -i -e "s|@aros_target_cc_path@|$(GCC_PATH)|g" $(TOOLDIR)/$(AROS_TARGET_CPU)-$(AROS_TARGET_ARCH)$(AROS_TARGET_SUFFIX)-aros-ld ; \ + $(SED) -i -e "s|@aros_cflags_unused_but_set_variable@|$(GCC_UNUSED_BUT_SET_VARIABLE)|g" $(GENDIR)/config/target.cfg ; \ + $(SED) -i -e "s|@aros_cflags_array_bounds@|$(GCC_ARRAY_BOUNDS)|g" $(GENDIR)/config/target.cfg ; \ + $(SED) -i -e "s|@aros_cflags_enum_compare@|$(GCC_ENUM_COMPARE)|g" $(GENDIR)/config/target.cfg ; \ fi %fetch_and_build mmake=crosstools-gcc package=gcc version=$(GCC_VERSION) compiler=host \ -- 2.11.4.GIT