Author: vasi Date: Thu Oct 5 03:22:26 2006 New Revision: 85 URL: <http://svn.finkproject.org/websvn/listing.php?sc=1&rev=85&repname=user%3a+vasi> Log: support default arch display better messages
Modified: ccache-multiarch/trunk/ccache.c ccache-multiarch/trunk/config.h.in ccache-multiarch/trunk/configure ccache-multiarch/trunk/configure.in Modified: ccache-multiarch/trunk/ccache.c URL: <http://svn.finkproject.org/websvn/diff.php?path=/ccache-multiarch/trunk/ccache.c&rev=85&repname=user%3a+vasi> ============================================================================== --- ccache-multiarch/trunk/ccache.c (original) +++ ccache-multiarch/trunk/ccache.c Thu Oct 5 03:22:26 2006 @@ -23,6 +23,11 @@ #include "ccache.h" + +#ifdef HAVE_MACH_O_ARCH_H +#include <mach-o/arch.h> +#endif + /* the base cache directory */ char *cache_dir = NULL; @@ -75,6 +80,8 @@ /* The output filename being used for the current arch, may be intermediate */ static char *current_out = NULL; +/* A string to identify the arch in error messages */ +static char *arch_str = NULL; /* a list of supported file extensions, and the equivalent @@ -215,7 +222,7 @@ args_pop(args, 3); if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { - cc_log("compiler produced stdout for %s\n", final_out); + cc_log("compiler produced stdout for %s%s\n", final_out, arch_str); stats_update(STATS_STDOUT); unlink(tmp_stdout); unlink(tmp_stderr); @@ -226,7 +233,8 @@ if (status != 0) { int fd; - cc_log("compile of %s gave status = %d\n", final_out, status); + cc_log("compile of %s gave status = %d%s\n", final_out, status, + arch_str); stats_update(STATS_STATUS); fd = open(tmp_stderr, O_RDONLY | O_BINARY); @@ -272,7 +280,7 @@ failed(); } - cc_log("Placed %s into cache\n", final_out); + cc_log("Placed %s into cache%s\n", final_out, arch_str); stats_tocache(file_size(&st1) + file_size(&st2)); free(tmp_hashname); @@ -419,7 +427,7 @@ unlink(path_stdout); } unlink(path_stderr); - cc_log("the preprocessor gave %d\n", status); + cc_log("the preprocessor gave %d%s\n", status, arch_str); stats_update(STATS_PREPROCESSOR); failed(); } @@ -578,7 +586,7 @@ /* and return with true */ if (first) { - cc_log("got cached result for %s\n", final_out); + cc_log("got cached result for %s%s\n", final_out, arch_str); stats_update(STATS_CACHED); } @@ -650,6 +658,48 @@ return NULL; } + +/* Get the default arch. + * By default, uses a heuristic to try to determine the arch that the compiler + * will choose in the absence of any -arch options. + * + * To predetermine the default arch, set the CCACHE_DEFAULT_ARCH env var. + * Setting it to the empty string is a good way to disable the use of any + * default arch. + * + * The result is allocated memory, and should be freed after use. + */ +static char *default_arch(void) +{ + char *arch; + + if ((arch = getenv("CCACHE_DEFAULT_ARCH"))) { + // it's the user's fault if it breaks, yay! + if (*arch == '\0') { + return NULL; // empty string -> no default + } else { + return x_strdup(arch); + } + } else { +#ifdef HAVE_MACH_O_ARCH_H + // Do some darwin mojo + cpu_type_t cpu; + const NXArchInfo *local, *general; + + local = NXGetLocalArchInfo(); + if (!local) return NULL; + + // Darwin doesn't seem to ever default to 64-bit + cpu = local->cputype & ~CPU_ARCH_ABI64; + general = NXGetArchInfoFromCpuType(cpu, CPU_SUBTYPE_MULTIPLE); + if (!general) return NULL; + + return x_strdup(general->name); +#else + return NULL; +#endif + } +} /* process the compiler options to form the correct set of options @@ -875,15 +925,20 @@ args_add_prefix(stripped_args, p); } - if (arches) { - /* if we have just one arch, don't do any special multi-arch stuff */ - if (arches->argc == 1) { + /* if we have just zero or one arch, don't do any multi-arch stuff */ + if (!arches) { + char *dflt; + if (( dflt = default_arch() )) { args_add(stripped_args, "-arch"); - args_add(stripped_args, arches->argv[0]); - args_pop(arches, 1); - free(arches); - arches = NULL; - } + args_add(stripped_args, dflt); + free(dflt); + } + } else if (arches->argc == 1) { + args_add(stripped_args, "-arch"); + args_add(stripped_args, arches->argv[0]); + args_pop(arches, 1); + free(arches); + arches = NULL; } } @@ -896,6 +951,7 @@ if (current_out) { free(current_out); args_pop(stripped_args, 2); + free(arch_str); } /* set up a temporary one-arch output file */ @@ -909,8 +965,11 @@ /* add the -arch argument for this step */ args_add(stripped_args, "-arch"); args_add(stripped_args, arches->argv[i]); + + x_asprintf(&arch_str, " (arch %s)", arches->argv[i]); } else { current_out = final_out; + arch_str = ""; } } @@ -922,14 +981,13 @@ int i; if (!arches) { - exit(0); + exit(0); // we're not needed } /* clean up from setup_arch */ - if (current_out) { - free(current_out); - args_pop(stripped_args, 2); - } + free(current_out); + args_pop(stripped_args, 2); + free(arch_str); /* find a lipo executable */ lipo = find_executable("lipo", ""); Modified: ccache-multiarch/trunk/config.h.in URL: <http://svn.finkproject.org/websvn/diff.php?path=/ccache-multiarch/trunk/config.h.in&rev=85&repname=user%3a+vasi> ============================================================================== --- ccache-multiarch/trunk/config.h.in (original) +++ ccache-multiarch/trunk/config.h.in Thu Oct 5 03:22:26 2006 @@ -19,8 +19,14 @@ /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `getpwuid' function. */ +#undef HAVE_GETPWUID + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H + +/* Define to 1 if you have the <mach-o/arch.h> header file. */ +#undef HAVE_MACH_O_ARCH_H /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -30,6 +36,9 @@ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ #undef HAVE_NDIR_H + +/* Define to 1 if you have the <pwd.h> header file. */ +#undef HAVE_PWD_H /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH Modified: ccache-multiarch/trunk/configure URL: <http://svn.finkproject.org/websvn/diff.php?path=/ccache-multiarch/trunk/configure&rev=85&repname=user%3a+vasi> ============================================================================== --- ccache-multiarch/trunk/configure (original) +++ ccache-multiarch/trunk/configure Thu Oct 5 03:22:26 2006 @@ -936,7 +936,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -1859,7 +1859,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -1917,7 +1918,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2033,7 +2035,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2087,7 +2090,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2132,7 +2136,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2176,7 +2181,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2609,7 +2615,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2681,7 +2688,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2735,7 +2743,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2806,7 +2815,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2860,7 +2870,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2927,7 +2938,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2997,7 +3009,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3078,7 +3091,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3248,7 +3262,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3286,7 +3301,8 @@ -for ac_header in ctype.h strings.h stdlib.h string.h pwd.h + +for ac_header in ctype.h strings.h stdlib.h string.h pwd.h mach-o/arch.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then @@ -3319,7 +3335,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3509,7 +3526,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3611,7 +3629,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3676,7 +3695,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4568,6 +4588,11 @@ *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -4606,12 +4631,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub Modified: ccache-multiarch/trunk/configure.in URL: <http://svn.finkproject.org/websvn/diff.php?path=/ccache-multiarch/trunk/configure.in&rev=85&repname=user%3a+vasi> ============================================================================== --- ccache-multiarch/trunk/configure.in (original) +++ ccache-multiarch/trunk/configure.in Thu Oct 5 03:22:26 2006 @@ -27,7 +27,7 @@ AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) +AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h mach-o/arch.h) AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) AC_CHECK_FUNCS(gethostname getpwuid) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Fink-commits mailing list Fink-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fink-commits