diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-21 12:03:21 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-10-21 12:03:21 +0000 |
commit | 6ea7ed3e747841f1484d8fe7539cb0633121b603 (patch) | |
tree | 29e2e609b76c6706d6eade266c76dbbd6faa724a /lto-plugin | |
parent | a44fa5565a54d06b65783cf4ecd5594e63c13ce6 (diff) | |
download | gcc-6ea7ed3e747841f1484d8fe7539cb0633121b603.tar.gz |
2009-10-21 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 153054
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@153056 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'lto-plugin')
-rw-r--r-- | lto-plugin/ChangeLog | 16 | ||||
-rwxr-xr-x | lto-plugin/configure | 94 | ||||
-rw-r--r-- | lto-plugin/configure.ac | 1 | ||||
-rw-r--r-- | lto-plugin/lto-plugin.c | 107 |
4 files changed, 171 insertions, 47 deletions
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog index c8616fa2938..110c79e93ad 100644 --- a/lto-plugin/ChangeLog +++ b/lto-plugin/ChangeLog @@ -1,3 +1,19 @@ +2009-10-19 Rafael Avila de Espindola <espindola@google.com> + + PR40790 + * configure: Regenerate. + * configure.ac: Add AC_TYPE_UINT64_T. + +2009-10-16 Rafael Avila de Espindola <espindola@google.com> + + * lto-plugin.c (message): New variable. + (check): New function. + (parse_table_entry, translate, write_resolution,add_output_files, + exec_lto_wrapper,claim_file_handler, onload): Use check instead of + assert. + (cleanup_handler): Use check instead of assert. Remove the arguments + file if it exists. + 2009-10-15 Rafael Avila de Espindola <espindola@google.com> * lto-plugin.c (resolution_file): New. diff --git a/lto-plugin/configure b/lto-plugin/configure index e701ee1aa10..c7ecf3e85fe 100755 --- a/lto-plugin/configure +++ b/lto-plugin/configure @@ -1864,6 +1864,58 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_func + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> ($2 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + eval as_val=\$$3 + if test "x$as_val" = x""no; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -4400,13 +4452,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4403: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4455: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4406: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4458: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4409: output\"" >&5) + (eval echo "\"\$as_me:4461: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5612,7 +5664,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5615 "configure"' > conftest.$ac_ext + echo '#line 5667 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7142,11 +7194,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7145: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7197: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7149: \$? = $ac_status" >&5 + echo "$as_me:7201: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7481,11 +7533,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7484: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7536: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7488: \$? = $ac_status" >&5 + echo "$as_me:7540: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7586,11 +7638,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7589: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7641: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7593: \$? = $ac_status" >&5 + echo "$as_me:7645: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7641,11 +7693,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7644: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7696: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7648: \$? = $ac_status" >&5 + echo "$as_me:7700: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10023,7 +10075,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10026 "configure" +#line 10078 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10119,7 +10171,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10122 "configure" +#line 10174 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10347,6 +10399,20 @@ CC="$lt_save_CC" +ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" +case $ac_cv_c_uint64_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT64_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint64_t $ac_cv_c_uint64_t +_ACEOF +;; + esac + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac index 277d31135fe..2956ed06c5f 100644 --- a/lto-plugin/configure.ac +++ b/lto-plugin/configure.ac @@ -7,6 +7,7 @@ AC_ARG_VAR(LIBELFLIBS,[How to link libelf]) AC_ARG_VAR(LIBELFINC,[How to find libelf include files]) AM_PROG_LIBTOOL AC_SUBST(target_noncanonical) +AC_TYPE_UINT64_T AC_CONFIG_FILES(Makefile) AC_OUTPUT AC_SYS_LARGEFILE diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index ae484a9efab..0cf1ab4ec69 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -82,6 +82,7 @@ static ld_plugin_get_symbols get_symbols; static ld_plugin_register_cleanup register_cleanup; static ld_plugin_add_input_file add_input_file; static ld_plugin_add_input_library add_input_library; +static ld_plugin_message message; static struct plugin_file_info *claimed_files = NULL; static unsigned int num_claimed_files = 0; @@ -99,6 +100,23 @@ static bool debug; static bool nop; static char *resolution_file = NULL; +static void +check (bool gate, enum ld_plugin_level level, const char *text) +{ + if (gate) + return; + + if (message) + message (level, text); + else + { + /* If there is no nicer way to inform the user, fallback to stderr. */ + fprintf (stderr, "%s\n", text); + if (level == LDPL_FATAL) + abort (); + } +} + /* Parse an entry of the IL symbol table. The data to be parsed is pointed by P and the result is written in ENTRY. The slot number is stored in SLOT. Returns the address of the next entry. */ @@ -142,12 +160,12 @@ parse_table_entry (char *p, struct ld_plugin_symbol *entry, uint32_t *slot) entry->comdat_key = strdup (entry->comdat_key); t = *p; - assert (t <= 4); + check (t <= 4, LDPL_FATAL, "invalid symbol kind found"); entry->def = translate_kind[t]; p++; t = *p; - assert (t <= 3); + check (t <= 3, LDPL_FATAL, "invalid symbol visibility found"); entry->visibility = translate_visibility[t]; p++; @@ -218,9 +236,9 @@ translate (Elf_Data *symtab, struct plugin_symtab *out) { n++; syms = realloc (syms, n * sizeof (struct ld_plugin_symbol)); - assert (syms); + check (syms, LDPL_FATAL, "could not allocate memory"); slots = realloc (slots, n * sizeof (uint32_t)); - assert (slots); + check (slots, LDPL_FATAL, "could not allocate memory"); data = parse_table_entry (data, &syms[n - 1], &slots[n - 1]); } @@ -297,7 +315,7 @@ write_resolution (void) return; f = fopen (resolution_file, "w"); - assert (f); + check (f, LDPL_FATAL, "could not open file"); fprintf (f, "%d\n", num_claimed_files); @@ -329,7 +347,7 @@ write_resolution (void) static void add_output_files (FILE *f) { - char fname[1000]; /* FIXME: Is this big enough? */ + char fname[1000]; /* FIXME: Remove this restriction. */ for (;;) { @@ -339,7 +357,7 @@ add_output_files (FILE *f) break; len = strlen (s); - assert (s[len - 1] == '\n'); + check (s[len - 1] == '\n', LDPL_FATAL, "file name too long"); s[len - 1] = '\0'; num_output_files++; @@ -367,16 +385,16 @@ exec_lto_wrapper (char *argv[]) /* Write argv to a file to avoid a command line that is too long. */ t = asprintf (&at_args, "@%s/arguments", temp_obj_dir_name); - assert (t >= 0); + check (t >= 0, LDPL_FATAL, "asprintf failed"); args_name = at_args + 1; args = fopen (args_name, "w"); - assert (args); + check (args, LDPL_FATAL, "could not open arguments file"); t = writeargv (&argv[1], args); - assert (t == 0); + check (t == 0, LDPL_FATAL, "could not write arguments"); t = fclose (args); - assert (t == 0); + check (t == 0, LDPL_FATAL, "could not close arguments file"); new_argv[0] = argv[0]; new_argv[1] = at_args; @@ -392,25 +410,26 @@ exec_lto_wrapper (char *argv[]) pex = pex_init (PEX_USE_PIPES, "lto-wrapper", NULL); - assert (pex != NULL); + check (pex != NULL, LDPL_FATAL, "could not pex_init lto-wrapper"); errmsg = pex_run (pex, 0, new_argv[0], new_argv, NULL, NULL, &t); - assert (errmsg == NULL); - assert (t == 0); + check (errmsg == NULL, LDPL_FATAL, "could not run lto-wrapper"); + check (t == 0, LDPL_FATAL, "could not run lto-wrapper"); wrapper_output = pex_read_output (pex, 0); - assert (wrapper_output); + check (wrapper_output, LDPL_FATAL, "could not read lto-wrapper output"); add_output_files (wrapper_output); t = pex_get_status (pex, 1, &status); - assert (t == 1); - assert (WIFEXITED (status) && WEXITSTATUS (status) == 0); + check (t == 1, LDPL_FATAL, "could not get lto-wrapper exit status"); + check (WIFEXITED (status) && WEXITSTATUS (status) == 0, LDPL_FATAL, + "lto-wrapper failed"); pex_free (pex); t = unlink (args_name); - assert (t == 0); + check (t == 0, LDPL_FATAL, "could not unlink arguments file"); free (at_args); } @@ -493,8 +512,12 @@ all_symbols_read_handler (void) static enum ld_plugin_status cleanup_handler (void) { + /* Note: we cannot use LDPL_FATAL in here as that would produce + an infinite loop. */ int t; unsigned i; + char *arguments; + struct stat buf; for (i = 0; i < num_claimed_files; i++) { @@ -502,11 +525,23 @@ cleanup_handler (void) if (info->temp) { t = unlink (info->name); - assert (t == 0); + check (t == 0, LDPL_ERROR, "could not unlink temporary file"); } } + + /* If we are being called from an error handler, it is possible + that the arguments file is still exists. */ + t = asprintf (&arguments, "%s/arguments", temp_obj_dir_name); + check (t >= 0, LDPL_ERROR, "asprintf failed"); + if (stat(arguments, &buf) == 0) + { + t = unlink (arguments); + check (t == 0, LDPL_ERROR, "could not unlink arguments file"); + } + free (arguments); + t = rmdir (temp_obj_dir_name); - assert (t == 0); + check (t == 0, LDPL_ERROR, "could not remove temporary directory"); free_2 (); return LDPS_OK; @@ -535,13 +570,13 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) char *objname; int t = asprintf (&objname, "%s/obj%d.o", temp_obj_dir_name, objnum); - assert (t >= 0); + check (t >= 0, LDPL_FATAL, "asprintf failed"); objnum++; fd = open (objname, O_RDWR | O_CREAT, 0666); - assert (fd > 0); + check (fd > 0, LDPL_FATAL, "could not open/create temporary file"); offset = lseek (file->fd, file->offset, SEEK_SET); - assert (offset == file->offset); + check (offset == file->offset, LDPL_FATAL, "could not seek"); while (size > 0) { ssize_t r, written; @@ -549,7 +584,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) off_t s = sizeof (buf) < size ? sizeof (buf) : size; r = read (file->fd, buf, s); written = write (fd, buf, r); - assert (written = r); + check (written == r, LDPL_FATAL, "could not write to temporary file"); size -= r; } lto_file.name = objname; @@ -579,7 +614,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) status = add_symbols (file->handle, lto_file.symtab.nsyms, lto_file.symtab.syms); - assert (status == LDPS_OK); + check (status == LDPS_OK, LDPL_FATAL, "could not add symbols"); *claimed = 1; num_claimed_files++; @@ -594,7 +629,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) if (file->offset != 0) { int t = unlink (lto_file.name); - assert (t == 0); + check (t == 0, LDPL_FATAL, "could not unlink file"); } free (lto_file.name); @@ -646,13 +681,16 @@ onload (struct ld_plugin_tv *tv) char *t; unsigned version = elf_version (EV_CURRENT); - assert (version != EV_NONE); + check (version != EV_NONE, LDPL_FATAL, "invalid ELF version"); p = tv; while (p->tv_tag) { switch (p->tv_tag) { + case LDPT_MESSAGE: + message = p->tv_u.tv_message; + break; case LDPT_REGISTER_CLAIM_FILE_HOOK: register_claim_file = p->tv_u.tv_register_claim_file; break; @@ -683,22 +721,25 @@ onload (struct ld_plugin_tv *tv) p++; } - assert (register_claim_file); - assert (add_symbols); + check (register_claim_file, LDPL_FATAL, "register_claim_file not found"); + check (add_symbols, LDPL_FATAL, "add_symbols not found"); status = register_claim_file (claim_file_handler); - assert (status == LDPS_OK); + check (status == LDPS_OK, LDPL_FATAL, + "could not register the claim_file callback"); if (register_cleanup) { status = register_cleanup (cleanup_handler); - assert (status == LDPS_OK); + check (status == LDPS_OK, LDPL_FATAL, + "could not register the cleanup callback"); } if (register_all_symbols_read) { - assert (get_symbols); + check (get_symbols, LDPL_FATAL, "get_symbols not found"); status = register_all_symbols_read (all_symbols_read_handler); - assert (status == LDPS_OK); + check (status == LDPS_OK, LDPL_FATAL, + "could not register the all_symbols_read callback"); } temp_obj_dir_name = strdup ("tmp_objectsXXXXXX"); |