Commit 3fd30b88 by Geoffrey Keating Committed by Geoffrey Keating

dummy-checksum.c: New.

2005-05-18  Geoffrey Keating  <geoffk@apple.com>

	* dummy-checksum.c: New.
	* genchecksum.c: New.
	* c.opt (print_pch_checksum): New flag.
	* c-pch.c (struct c_pch_validity): Make much shorter.
	(no_checksum): New.
	(host_machine): Remove.
	(target_machine): Remove.
	(get_ident): Change PCH version number.
	(pch_init): When -fverbose-asm, print out the compiler fingerprint.
	Don't put triplets or version string in PCH validity data.
	Do put the compiler checksum in the validity data.
	(c_common_valid_pch): Don't check triplets or version string.  Do
	check checksum.
	(c_common_print_pch_checksum): New.
	* c-opts.c (c_common_handle_option): Add OPT_print_pch_checksum.
	Print fingerprint with -v.
	* c-common.h (c_common_print_pch_checksum): New.
	(executable_checksum): New.
	* Makefile.in (STAGEMOVESTUFF): Add cc1*-dummy, *-checksum.c.
	(cc1-dummy): New rule.
	(cc1-checksum.c): New rule.
	(cc1-checksum.o): New rule.
	(cc1): Add checksum support.
	(build/genchecksum): New.
	(build/genchecksum.o): New.
	(dummy-checksum.o): New.
	(genobjnames): Add genchecksum.o.
	(mostlyclean): Remove *-checksum.c.
	(gnucompare): Add libgcc to list of directories checked.
	Make comparison problems in libgcc/ and with checksum files only
	be warnings.
	* doc/invoke.texi (Precompiled Headers): Remove caution.
	Document that it must be the exact same binary.  Add a few
	known-safe flags to the list.

In cp/:
2005-05-18  Geoffrey Keating  <geoffk@apple.com>

	* Make-lang.in (cc1plus-dummy): New.
	(cc1plus-checksum.c): New.
	(cc1plus-checksum.o): New.
	(cc1plus): Add cc1plus-checksum.o.

In objc/:
2005-05-18  Geoffrey Keating  <geoffk@apple.com>

	* Make-lang.in (cc1obj-dummy): New.
	(cc1obj-checksum.c): New.
	(cc1obj-checksum.o): New.
	(cc1obj): Add cc1obj-checksum.o.

In objcp/:
2005-05-18  Geoffrey Keating  <geoffk@apple.com>

	* Make-lang.in (cc1objplus-dummy): New.
	(cc1objplus-checksum.c): New.
	(cc1objplus-checksum.o): New.
	(cc1objplus): Add cc1objplus-checksum.o.

From-SVN: r99928
parent 045a8eb3
2005-05-18 Geoffrey Keating <geoffk@apple.com> 2005-05-18 Geoffrey Keating <geoffk@apple.com>
* dummy-checksum.c: New.
* genchecksum.c: New.
* c.opt (print_pch_checksum): New flag.
* c-pch.c (struct c_pch_validity): Make much shorter.
(no_checksum): New.
(host_machine): Remove.
(target_machine): Remove.
(get_ident): Change PCH version number.
(pch_init): When -fverbose-asm, print out the compiler fingerprint.
Don't put triplets or version string in PCH validity data.
Do put the compiler checksum in the validity data.
(c_common_valid_pch): Don't check triplets or version string. Do
check checksum.
(c_common_print_pch_checksum): New.
* c-opts.c (c_common_handle_option): Add OPT_print_pch_checksum.
Print fingerprint with -v.
* c-common.h (c_common_print_pch_checksum): New.
(executable_checksum): New.
* Makefile.in (STAGEMOVESTUFF): Add cc1*-dummy, *-checksum.c.
(cc1-dummy): New rule.
(cc1-checksum.c): New rule.
(cc1-checksum.o): New rule.
(cc1): Add checksum support.
(build/genchecksum): New.
(build/genchecksum.o): New.
(dummy-checksum.o): New.
(genobjnames): Add genchecksum.o.
(mostlyclean): Remove *-checksum.c.
(gnucompare): Add libgcc to list of directories checked.
Make comparison problems in libgcc/ and with checksum files only
be warnings.
* doc/invoke.texi (Precompiled Headers): Remove caution.
Document that it must be the exact same binary. Add a few
known-safe flags to the list.
* rs6000/predicates.md (fix_trunc_dest_operand): New. * rs6000/predicates.md (fix_trunc_dest_operand): New.
* rs6000/rs6000.md (fix_truncdfsi2): Use fix_trunc_dest_operand. * rs6000/rs6000.md (fix_truncdfsi2): Use fix_trunc_dest_operand.
Check that a memory operand is valid before trying to use it. Check that a memory operand is valid before trying to use it.
......
...@@ -983,12 +983,12 @@ STAGECOPYSTUFF = insn-flags.h insn-config.h insn-codes.h \ ...@@ -983,12 +983,12 @@ STAGECOPYSTUFF = insn-flags.h insn-config.h insn-codes.h \
# Files to be moved away after each stage in building. # Files to be moved away after each stage in building.
STAGEMOVESTUFF = *$(objext) s-* \ STAGEMOVESTUFF = *$(objext) s-* \
xgcc$(exeext) cpp$(exeext) cc1$(exeext) $(EXTRA_PASSES) \ xgcc$(exeext) cpp$(exeext) cc1$(exeext) cc1*-dummy$(exeext) $(EXTRA_PASSES) \
$(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \ $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
protoize$(exeext) unprotoize$(exeext) \ protoize$(exeext) unprotoize$(exeext) \
$(SPECS) collect2$(exeext) \ $(SPECS) collect2$(exeext) \
gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \ gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
*.[0-9][0-9].* *.[si] libbackend.a libgcc.mk \ *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a libgcc.mk \
$(LANG_STAGESTUFF) $(LANG_STAGESTUFF)
# Defined in libgcc2.c, included only in the static library. # Defined in libgcc2.c, included only in the static library.
...@@ -1213,9 +1213,18 @@ $(SPECS): xgcc$(exeext) ...@@ -1213,9 +1213,18 @@ $(SPECS): xgcc$(exeext)
gcc-cross: xgcc$(exeext) gcc-cross: xgcc$(exeext)
cp xgcc$(exeext) gcc-cross$(exeext) cp xgcc$(exeext) gcc-cross$(exeext)
cc1$(exeext): $(C_OBJS) $(BACKEND) $(LIBDEPS) cc1-dummy$(exeext): $(C_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1$(exeext) \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) dummy-checksum.o \
$(C_OBJS) $(BACKEND) $(LIBS) $(BACKEND) $(LIBS)
cc1-checksum.c : cc1-dummy$(exeext) build/genchecksum$(exeext)
build/genchecksum$(exeext) cc1-dummy$(exeext) > $@
cc1-checksum.o : cc1-checksum.c
cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) cc1-checksum.o \
$(BACKEND) $(LIBS)
# Build the version of limits.h that we will install. # Build the version of limits.h that we will install.
xlimits.h: glimits.h limitx.h limity.h xlimits.h: glimits.h limitx.h limity.h
...@@ -1532,6 +1541,14 @@ gccspec.o: gccspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) ...@@ -1532,6 +1541,14 @@ gccspec.o: gccspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H)
cppspec.o: cppspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) cppspec.o: cppspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H)
build/genchecksum$(build_exeext) : build/genchecksum.o $(BUILD_LIBDEPS)
$(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
build/genchecksum.o $(BUILD_LIBS)
build/genchecksum.o : genchecksum.c $(BCONFIG_H) $(SYSTEM_H) $(MD5_H)
dummy-checksum.o : dummy-checksum.c
tree-check.h: s-check ; @true tree-check.h: s-check ; @true
s-check : build/gencheck$(build_exeext) s-check : build/gencheck$(build_exeext)
$(RUN_GEN) build/gencheck$(build_exeext) > tmp-check.h $(RUN_GEN) build/gencheck$(build_exeext) > tmp-check.h
...@@ -2668,7 +2685,8 @@ genobjnames=$(genprognames:%=%.o) read-rtl.o gensupport.o genattrtab.o \ ...@@ -2668,7 +2685,8 @@ genobjnames=$(genprognames:%=%.o) read-rtl.o gensupport.o genattrtab.o \
genconstants.o gen-protos.o scan.o fix-header.o scan-decls.o \ genconstants.o gen-protos.o scan.o fix-header.o scan-decls.o \
gencheck.o dummy-conditions.o genconditions.o errors.o ggc-none.o \ gencheck.o dummy-conditions.o genconditions.o errors.o ggc-none.o \
min-insn-modes.o rtl.o print-rtl.o varray.o gcov-iov.o \ min-insn-modes.o rtl.o print-rtl.o varray.o gcov-iov.o \
insn-conditions.o gengtype-lex.o gengtype-yacc.o genmddeps.o insn-conditions.o gengtype-lex.o gengtype-yacc.o genmddeps.o \
genchecksum.o
genobjs=$(genobjnames:%=build/%) genobjs=$(genobjnames:%=build/%)
...@@ -3300,6 +3318,8 @@ mostlyclean: lang.mostlyclean ...@@ -3300,6 +3318,8 @@ mostlyclean: lang.mostlyclean
# Delete files generated by gengtype.c # Delete files generated by gengtype.c
-rm -f gtype-* -rm -f gtype-*
-rm -f gt-* -rm -f gt-*
# Delete genchecksum outputs
-rm -f *-checksum.c
# Delete all files made by compilation # Delete all files made by compilation
# that don't exist in the distribution. # that don't exist in the distribution.
...@@ -4068,14 +4088,22 @@ fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcom ...@@ -4068,14 +4088,22 @@ fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcom
gnucompare gnucompare3 gnucompare4 gnucompare-lean gnucompare3-lean gnucompare4-lean: force gnucompare gnucompare3 gnucompare4 gnucompare-lean gnucompare3-lean gnucompare4-lean: force
-rm -f .bad_compare -rm -f .bad_compare
case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \ case "$@" in *compare | *compare-lean ) stage=2 ;; * ) stage=`echo $@ | sed -e 's,^[a-z]*compare\([0-9][0-9]*\).*,\1,'` ;; esac; \
for dir in . $(SUBDIRS); do \ for dir in . $(SUBDIRS) libgcc; do \
if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \ if [ "`echo $$dir/*$(objext)`" != "$$dir/*$(objext)" ] ; then \
for file in $$dir/*$(objext); do \ for file in $$dir/*$(objext); do \
case "$@" in \ case $$file in \
./cc*-checksum$(objext) | libgcc/* ) \
tail +16c ./$$file > tmp-foo1 \
&& tail +16c stage$$stage/$$file > tmp-foo2 \
&& ( cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 \
|| echo warning: $$file differs || true ) \
;; \
*) case "$@" in \
slowcompare* ) \ slowcompare* ) \
tail +16c ./$$file > tmp-foo1; \ tail +16c ./$$file > tmp-foo1; \
tail +16c stage$$stage/$$file > tmp-foo2 \ tail +16c stage$$stage/$$file > tmp-foo2 \
&& (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 || echo $$file differs >> .bad_compare) || true; \ && (cmp tmp-foo1 tmp-foo2 > /dev/null 2>&1 \
|| echo $$file differs >> .bad_compare) || true; \
;; \ ;; \
fastcompare* ) \ fastcompare* ) \
cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \ cmp $$file stage$$stage/$$file 16 16 > /dev/null 2>&1; \
...@@ -4086,6 +4114,7 @@ fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcom ...@@ -4086,6 +4114,7 @@ fastcompare fastcompare3 fastcompare4 fastcompare-lean fastcompare3-lean fastcom
test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \ test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
;; \ ;; \
esac ; \ esac ; \
esac ; \
done; \ done; \
else true; fi; \ else true; fi; \
done done
......
...@@ -859,6 +859,10 @@ extern void c_common_read_pch (cpp_reader *pfile, const char *name, int fd, ...@@ -859,6 +859,10 @@ extern void c_common_read_pch (cpp_reader *pfile, const char *name, int fd,
extern void c_common_write_pch (void); extern void c_common_write_pch (void);
extern void c_common_no_more_pch (void); extern void c_common_no_more_pch (void);
extern void c_common_pch_pragma (cpp_reader *pfile); extern void c_common_pch_pragma (cpp_reader *pfile);
extern void c_common_print_pch_checksum (FILE *f);
/* In *-checksum.c */
extern const unsigned char executable_checksum[16];
extern void builtin_define_with_value (const char *, const char *, int); extern void builtin_define_with_value (const char *, const char *, int);
extern void c_stddef_cpp_builtins (void); extern void c_stddef_cpp_builtins (void);
......
...@@ -863,6 +863,11 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -863,6 +863,11 @@ c_common_handle_option (size_t scode, const char *arg, int value)
print_struct_values = 1; print_struct_values = 1;
break; break;
case OPT_print_pch_checksum:
c_common_print_pch_checksum (stdout);
exit_after_options = true;
break;
case OPT_remap: case OPT_remap:
cpp_opts->remap = 1; cpp_opts->remap = 1;
break; break;
...@@ -1066,6 +1071,9 @@ c_common_init (void) ...@@ -1066,6 +1071,9 @@ c_common_init (void)
are known. */ are known. */
cpp_init_iconv (parse_in); cpp_init_iconv (parse_in);
if (version_flag)
c_common_print_pch_checksum (stderr);
if (flag_preprocess_only) if (flag_preprocess_only)
{ {
finish_options (); finish_options ();
......
...@@ -52,22 +52,17 @@ enum { ...@@ -52,22 +52,17 @@ enum {
MATCH_SIZE = ARRAY_SIZE (pch_matching) MATCH_SIZE = ARRAY_SIZE (pch_matching)
}; };
/* This structure is read very early when validating the PCH, and /* The value of the checksum in the dummy compiler that is actually
might be read for a PCH which is for a completely different compiler checksummed. That compiler should never be run. */
for a different operating system. Thus, it should really only contain static const char no_checksum[16] = { 0 };
'unsigned char' entries, at least in the initial entries.
If you add or change entries before version_length, you should increase /* Information about flags and suchlike that affect PCH validity.
the version number in get_ident().
There are a bunch of fields named *_length; those are lengths of data that Before this structure is read, both an initial 8-character identification
follows this structure in the same order as the fields in the structure. */ string, and a 16-byte checksum, have been read and validated. */
struct c_pch_validity struct c_pch_validity
{ {
unsigned char host_machine_length;
unsigned char target_machine_length;
unsigned char version_length;
unsigned char debug_info_type; unsigned char debug_info_type;
signed char match[MATCH_SIZE]; signed char match[MATCH_SIZE];
void (*pch_init) (void); void (*pch_init) (void);
...@@ -87,10 +82,6 @@ static FILE *pch_outfile; ...@@ -87,10 +82,6 @@ static FILE *pch_outfile;
/* The position in the assembler output file when pch_init was called. */ /* The position in the assembler output file when pch_init was called. */
static long asm_file_startpos; static long asm_file_startpos;
/* The host and target machines. */
static const char host_machine[] = HOST_MACHINE;
static const char target_machine[] = TARGET_MACHINE;
static const char *get_ident (void); static const char *get_ident (void);
/* Compute an appropriate 8-byte magic number for the PCH file, so that /* Compute an appropriate 8-byte magic number for the PCH file, so that
...@@ -102,7 +93,7 @@ static const char * ...@@ -102,7 +93,7 @@ static const char *
get_ident (void) get_ident (void)
{ {
static char result[IDENT_LENGTH]; static char result[IDENT_LENGTH];
static const char template[IDENT_LENGTH] = "gpch.012"; static const char template[IDENT_LENGTH] = "gpch.013";
static const char c_language_chars[] = "Co+O"; static const char c_language_chars[] = "Co+O";
memcpy (result, template, IDENT_LENGTH); memcpy (result, template, IDENT_LENGTH);
...@@ -111,8 +102,10 @@ get_ident (void) ...@@ -111,8 +102,10 @@ get_ident (void)
return result; return result;
} }
/* Prepare to write a PCH file. This is called at the start of /* Prepare to write a PCH file, if one is being written. This is
compilation. */ called at the start of compilation.
Also, print out the executable checksum if -fverbose-asm is in effect. */
void void
pch_init (void) pch_init (void)
...@@ -122,6 +115,15 @@ pch_init (void) ...@@ -122,6 +115,15 @@ pch_init (void)
void *target_validity; void *target_validity;
static const char partial_pch[IDENT_LENGTH] = "gpcWrite"; static const char partial_pch[IDENT_LENGTH] = "gpcWrite";
#ifdef ASM_COMMENT_START
if (flag_verbose_asm)
{
fprintf (asm_out_file, "%s ", ASM_COMMENT_START);
c_common_print_pch_checksum (asm_out_file);
fputc ('\n', asm_out_file);
}
#endif
if (!pch_file) if (!pch_file)
return; return;
...@@ -130,13 +132,8 @@ pch_init (void) ...@@ -130,13 +132,8 @@ pch_init (void)
fatal_error ("can%'t create precompiled header %s: %m", pch_file); fatal_error ("can%'t create precompiled header %s: %m", pch_file);
pch_outfile = f; pch_outfile = f;
gcc_assert (strlen (host_machine) < 256 gcc_assert (memcmp (executable_checksum, no_checksum, 16) != 0);
&& strlen (target_machine) < 256
&& strlen (version_string) < 256);
v.host_machine_length = strlen (host_machine);
v.target_machine_length = strlen (target_machine);
v.version_length = strlen (version_string);
v.debug_info_type = write_symbols; v.debug_info_type = write_symbols;
{ {
size_t i; size_t i;
...@@ -150,10 +147,8 @@ pch_init (void) ...@@ -150,10 +147,8 @@ pch_init (void)
target_validity = targetm.get_pch_validity (&v.target_data_length); target_validity = targetm.get_pch_validity (&v.target_data_length);
if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1 if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
|| fwrite (executable_checksum, 16, 1, f) != 1
|| fwrite (&v, sizeof (v), 1, f) != 1 || fwrite (&v, sizeof (v), 1, f) != 1
|| fwrite (host_machine, v.host_machine_length, 1, f) != 1
|| fwrite (target_machine, v.target_machine_length, 1, f) != 1
|| fwrite (version_string, v.version_length, 1, f) != 1
|| fwrite (target_validity, v.target_data_length, 1, f) != 1) || fwrite (target_validity, v.target_data_length, 1, f) != 1)
fatal_error ("can%'t write to %s: %m", pch_file); fatal_error ("can%'t write to %s: %m", pch_file);
...@@ -234,20 +229,24 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) ...@@ -234,20 +229,24 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
{ {
int sizeread; int sizeread;
int result; int result;
char ident[IDENT_LENGTH]; char ident[IDENT_LENGTH + 16];
char short_strings[256 * 3];
int strings_length;
const char *pch_ident; const char *pch_ident;
struct c_pch_validity v; struct c_pch_validity v;
/* Perform a quick test of whether this is a valid /* Perform a quick test of whether this is a valid
precompiled header for the current language. */ precompiled header for the current language. */
sizeread = read (fd, ident, IDENT_LENGTH); gcc_assert (memcmp (executable_checksum, no_checksum, 16) != 0);
sizeread = read (fd, ident, IDENT_LENGTH + 16);
if (sizeread == -1) if (sizeread == -1)
fatal_error ("can%'t read %s: %m", name); fatal_error ("can%'t read %s: %m", name);
else if (sizeread != IDENT_LENGTH) else if (sizeread != IDENT_LENGTH + 16)
{
cpp_error (pfile, CPP_DL_WARNING, "%s: too short to be a PCH file",
name);
return 2; return 2;
}
pch_ident = get_ident(); pch_ident = get_ident();
if (memcmp (ident, pch_ident, IDENT_LENGTH) != 0) if (memcmp (ident, pch_ident, IDENT_LENGTH) != 0)
...@@ -269,52 +268,20 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) ...@@ -269,52 +268,20 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
} }
return 2; return 2;
} }
if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0)
/* At this point, we know it's a PCH file, so it ought to be long enough
that we can read a c_pch_validity structure. */
if (read (fd, &v, sizeof (v)) != sizeof (v))
fatal_error ("can%'t read %s: %m", name);
strings_length = (v.host_machine_length + v.target_machine_length
+ v.version_length);
if (read (fd, short_strings, strings_length) != strings_length)
fatal_error ("can%'t read %s: %m", name);
if (v.host_machine_length != strlen (host_machine)
|| memcmp (host_machine, short_strings, strlen (host_machine)) != 0)
{
if (cpp_get_options (pfile)->warn_invalid_pch)
cpp_error (pfile, CPP_DL_WARNING,
"%s: created on host '%.*s', but used on host '%s'", name,
v.host_machine_length, short_strings, host_machine);
return 2;
}
if (v.target_machine_length != strlen (target_machine)
|| memcmp (target_machine, short_strings + v.host_machine_length,
strlen (target_machine)) != 0)
{
if (cpp_get_options (pfile)->warn_invalid_pch)
cpp_error (pfile, CPP_DL_WARNING,
"%s: created for target '%.*s', but used for target '%s'",
name, v.target_machine_length,
short_strings + v.host_machine_length, target_machine);
return 2;
}
if (v.version_length != strlen (version_string)
|| memcmp (version_string,
(short_strings + v.host_machine_length
+ v.target_machine_length),
v.version_length) != 0)
{ {
if (cpp_get_options (pfile)->warn_invalid_pch) if (cpp_get_options (pfile)->warn_invalid_pch)
cpp_error (pfile, CPP_DL_WARNING, cpp_error (pfile, CPP_DL_WARNING,
"%s: created by version '%.*s', but this is version '%s'", "%s: created by a different GCC executable", name);
name, v.version_length,
(short_strings + v.host_machine_length
+ v.target_machine_length),
version_string);
return 2; return 2;
} }
/* At this point, we know it's a PCH file created by this
executable, so it ought to be long enough that we can read a
c_pch_validity structure. */
if (read (fd, &v, sizeof (v)) != sizeof (v))
fatal_error ("can%'t read %s: %m", name);
/* The allowable debug info combinations are that either the PCH file /* The allowable debug info combinations are that either the PCH file
was built with the same as is being used now, or the PCH file was was built with the same as is being used now, or the PCH file was
built for some kind of debug info but now none is in use. */ built for some kind of debug info but now none is in use. */
...@@ -346,7 +313,9 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) ...@@ -346,7 +313,9 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
/* If the text segment was not loaded at the same address as it was /* If the text segment was not loaded at the same address as it was
when the PCH file was created, function pointers loaded from the when the PCH file was created, function pointers loaded from the
PCH will not be valid. We could in theory remap all the function PCH will not be valid. We could in theory remap all the function
pointers, but no support for that exists at present. */ pointers, but no support for that exists at present.
Since we have the same executable, it should only be necessary to
check one function. */
if (v.pch_init != &pch_init) if (v.pch_init != &pch_init)
{ {
if (cpp_get_options (pfile)->warn_invalid_pch) if (cpp_get_options (pfile)->warn_invalid_pch)
...@@ -508,3 +477,15 @@ c_common_pch_pragma (cpp_reader *pfile) ...@@ -508,3 +477,15 @@ c_common_pch_pragma (cpp_reader *pfile)
close (fd); close (fd);
} }
/* Print out executable_checksum[]. */
void
c_common_print_pch_checksum (FILE *f)
{
int i;
fputs ("Compiler executable checksum: ", f);
for (i = 0; i < 16; i++)
fprintf (f, "%02x", executable_checksum[i]);
putc ('\n', f);
}
...@@ -791,6 +791,10 @@ print-objc-runtime-info ...@@ -791,6 +791,10 @@ print-objc-runtime-info
ObjC ObjC++ ObjC ObjC++
Generate C header of platform-specific features Generate C header of platform-specific features
print-pch-checksum
C ObjC C++ ObjC++
Print a checksum of the executable for PCH validity checking, and stop.
remap remap
C ObjC C++ ObjC++ C ObjC C++ ObjC++
Remap file names when including files Remap file names when including files
......
2005-05-18 Geoffrey Keating <geoffk@apple.com>
* Make-lang.in (cc1plus-dummy): New.
(cc1plus-checksum.c): New.
(cc1plus-checksum.o): New.
(cc1plus): Add cc1plus-checksum.o.
2005-05-17 H.J. Lu <hongjiu.lu@intel.com> 2005-05-17 H.J. Lu <hongjiu.lu@intel.com>
PR C++/19664 PR C++/19664
......
...@@ -91,9 +91,18 @@ CXX_OBJS = cp/cp-lang.o stub-objc.o $(CXX_AND_OBJCXX_OBJS) ...@@ -91,9 +91,18 @@ CXX_OBJS = cp/cp-lang.o stub-objc.o $(CXX_AND_OBJCXX_OBJS)
# Use strict warnings for this front end. # Use strict warnings for this front end.
cp-warn = $(STRICT_WARN) cp-warn = $(STRICT_WARN)
cc1plus$(exeext): $(CXX_OBJS) $(BACKEND) $(LIBDEPS) cc1plus-dummy$(exeext): $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(CXX_OBJS) $(BACKEND) $(LIBS) $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS)
cc1plus-checksum.c : cc1plus-dummy$(exeext) build/genchecksum$(exeext)
build/genchecksum$(exeext) cc1plus-dummy$(exeext) > $@
cc1plus-checksum.o : cc1plus-checksum.c
cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS)
# Special build rules. # Special build rules.
$(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
......
...@@ -12941,13 +12941,6 @@ build the project. To make builds faster, GCC allows users to ...@@ -12941,13 +12941,6 @@ build the project. To make builds faster, GCC allows users to
`precompile' a header file; then, if builds can use the precompiled `precompile' a header file; then, if builds can use the precompiled
header file they will be much faster. header file they will be much faster.
@strong{Caution:} There are a few known situations where GCC will
crash when trying to use a precompiled header. If you have trouble
with a precompiled header, you should remove the precompiled header
and compile without it. In addition, please use GCC's on-line
defect-tracking system to report any problems you encounter with
precompiled headers. @xref{Bugs}.
To create a precompiled header file, simply compile it as you would any To create a precompiled header file, simply compile it as you would any
other file, if necessary using the @option{-x} option to make the driver other file, if necessary using the @option{-x} option to make the driver
treat it as a C or C++ header file. You will probably want to use a treat it as a C or C++ header file. You will probably want to use a
...@@ -13012,10 +13005,8 @@ the current compilation. You can't use a C precompiled header for a C++ ...@@ -13012,10 +13005,8 @@ the current compilation. You can't use a C precompiled header for a C++
compilation. compilation.
@item @item
The precompiled header file must be produced by the same compiler The precompiled header file must have been produced by the same compiler
version and configuration as the current compilation is using. binary as the current compilation is using.
The easiest way to guarantee this is to use the same compiler binary
for creating and using precompiled headers.
@item @item
Any macros defined before the precompiled header is included must Any macros defined before the precompiled header is included must
...@@ -13052,7 +13043,10 @@ which options are safe to change and which are not; the safest choice ...@@ -13052,7 +13043,10 @@ which options are safe to change and which are not; the safest choice
is to use exactly the same options when generating and using the is to use exactly the same options when generating and using the
precompiled header. The following are known to be safe: precompiled header. The following are known to be safe:
@gccoptlist{-fpreprocessed -pedantic-errors} @gccoptlist{-fpreprocessed
-fsched-interblock -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
-fsched-verbose=<number> -fschedule-insns
-pedantic-errors}
@end itemize @end itemize
......
const unsigned char executable_checksum[16] = { 0 };
/* Generate checksums of executables for PCH validation
Copyright (C) 2005
Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "bconfig.h"
#include "system.h"
#include "md5.h"
static void
usage (void)
{
fputs ("Usage: genchecksums <filename>\n", stderr);
}
static void
dosum (const char *file)
{
FILE *f;
unsigned char result[16];
int i;
f = fopen (file, "rb");
if (!f)
{
fprintf (stderr, "opening %s: %s\n", file, xstrerror (errno));
exit (1);
}
/* Some executable formats have timestamps in the first 16 bytes, yuck. */
if (fseek (f, 16, SEEK_SET) != 0)
{
fprintf (stderr, "seeking in %s: %s\n", file, xstrerror (errno));
exit (1);
}
if (md5_stream (f, result) != 0
|| fclose (f) != 0)
{
fprintf (stderr, "reading %s: %s\n", file, xstrerror (errno));
exit (1);
}
fputs ("const unsigned char executable_checksum[16] = { ", stdout);
for (i = 0; i < 16; i++)
printf ("%#02x%s", result[i], i == 15 ? " };\n" : ", ");
}
int
main (int argc, char ** argv)
{
if (argc != 2)
{
usage ();
return 1;
}
dosum (argv[1]);
return 0;
}
2005-05-18 Geoffrey Keating <geoffk@apple.com>
* Make-lang.in (cc1obj-dummy): New.
(cc1obj-checksum.c): New.
(cc1obj-checksum.o): New.
(cc1obj): Add cc1obj-checksum.o.
2005-05-18 Mike Stump <mrs@apple.com> 2005-05-18 Mike Stump <mrs@apple.com>
PR objc/21641 PR objc/21641
......
...@@ -50,9 +50,20 @@ objc-warn = $(STRICT_WARN) ...@@ -50,9 +50,20 @@ objc-warn = $(STRICT_WARN)
# Language-specific object files for Objective C. # Language-specific object files for Objective C.
OBJC_OBJS = objc/objc-lang.o objc/objc-act.o OBJC_OBJS = objc/objc-lang.o objc/objc-act.o
cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS) cc1obj-dummy$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBS) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) dummy-checksum.o \
$(BACKEND) $(LIBS)
cc1obj-checksum.c : cc1obj-dummy$(exeext) build/genchecksum$(exeext)
build/genchecksum$(exeext) cc1obj-dummy$(exeext) > $@
cc1obj-checksum.o : cc1obj-checksum.c
cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \
$(BACKEND) $(LIBS)
# Objective C language specific files. # Objective C language specific files.
......
2005-05-18 Geoffrey Keating <geoffk@apple.com>
* Make-lang.in (cc1objplus-dummy): New.
(cc1objplus-checksum.c): New.
(cc1objplus-checksum.o): New.
(cc1objplus): Add cc1objplus-checksum.o.
2005-05-17 Mike Stump <mrs@apple.com> 2005-05-17 Mike Stump <mrs@apple.com>
Yet more Objective-C++... Yet more Objective-C++...
......
...@@ -51,9 +51,19 @@ objcp-warn = $(STRICT_WARN) -DOBJCPLUS -I$(srcdir)/objc -I$(srcdir)/cp ...@@ -51,9 +51,19 @@ objcp-warn = $(STRICT_WARN) -DOBJCPLUS -I$(srcdir)/objc -I$(srcdir)/cp
OBJCXX_OBJS = objcp/objcp-act.o objcp/objcp-lang.o objcp/objcp-decl.o \ OBJCXX_OBJS = objcp/objcp-act.o objcp/objcp-lang.o objcp/objcp-decl.o \
$(CXX_AND_OBJCXX_OBJS) $(CXX_AND_OBJCXX_OBJS)
cc1objplus$(exeext): $(OBJCXX_OBJS) $(BACKEND) $(LIBDEPS) cc1objplus-dummy$(exeext): $(OBJCXX_OBJS) dummy-checksum.o $(BACKEND) \
$(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(OBJCXX_OBJS) $(BACKEND) $(LIBS) $(OBJCXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS)
cc1objplus-checksum.c : cc1objplus-dummy$(exeext) build/genchecksum$(exeext)
build/genchecksum$(exeext) cc1objplus-dummy$(exeext) > $@
cc1objplus-checksum.o : cc1objplus-checksum.c
cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
$(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBS)
# Objective C++ language specific files. # Objective C++ language specific files.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment