Files containing the MELT translated to C code were not loaded correctly due to bad search path when working with an installed plugin. Present commit fixes this by: - using a melt find to search in current dir - ensuring the melt_modulename in melt descriptor only contains the module name, and no path component --- gcc/ChangeLog.MELT | 6 ++++++ gcc/melt-runtime.c | 24 ++++++++++++++++++++++-- gcc/melt/warmelt-outobj.melt | 7 ++++++- 3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/gcc/ChangeLog.MELT b/gcc/ChangeLog.MELT index cfdac12..241c862 100644 --- a/gcc/ChangeLog.MELT +++ b/gcc/ChangeLog.MELT @@ -1,3 +1,9 @@ +2011-08-29 Alexandre Lissy <ali...@mandriva.com> + * melt-runtime.c (melt_load_module_index): Fix loading path of .c + files. + * melt/warmelt-outobj.melt (output_melt_descriptor): Fix generation + of melt_modulename (taking basename). + 2011-08-27 Pierre Vittet <pier...@pvittet.com> * melt-build.tpl (warmelt-upgrade-translator): replace move-if-change diff --git a/gcc/melt-runtime.c b/gcc/melt-runtime.c index dd11a6e..cf8e0cc 100644 --- a/gcc/melt-runtime.c +++ b/gcc/melt-runtime.c @@ -8683,6 +8683,8 @@ melt_load_module_index (const char*srcbase, const char*flavor) { FILE *sfil = 0; char *curpath = 0; + char *srcpath = 0; + const char* srcpathstr = melt_argument ("source-path"); int nbsecfile = 0; int cursecix = 0; time_t gentim = 0; @@ -8701,7 +8703,15 @@ melt_load_module_index (const char*srcbase, const char*flavor) melt_run_preprocessed_md5); nbsecfile = *(MELTDESCR_REQUIRED(melt_lastsecfileindex)); debugeprintf ("melt_load_module_index descmodulename %s nbsecfile %d", descmodulename, nbsecfile); - curpath = concat (descmodulename, ".c", NULL); + srcpath = concat (descmodulename, ".c", NULL); + curpath = + MELT_FIND_FILE (srcpath, + MELT_FILE_IN_DIRECTORY, ".", + MELT_FILE_IN_PATH, srcpathstr, + MELT_FILE_IN_PATH, getenv ("GCCMELT_SOURCE_PATH"), + MELT_FILE_IN_DIRECTORY, melt_source_dir, + NULL); + debugeprintf ("melt_load_module_index srcpath %s ", srcpath); sfil = fopen (curpath, "r"); if (!sfil) warning (0, @@ -8714,6 +8724,7 @@ melt_load_module_index (const char*srcbase, const char*flavor) curpath, MELTDESCR_REQUIRED (melt_primaryhexmd5)); fclose (sfil), sfil = NULL; }; + free (srcpath), srcpath = NULL; free (curpath), curpath = NULL; for (cursecix = 1; cursecix < nbsecfile; cursecix++) { @@ -8722,7 +8733,15 @@ melt_load_module_index (const char*srcbase, const char*flavor) continue; memset (suffixbuf, 0, sizeof(suffixbuf)); snprintf (suffixbuf, sizeof(suffixbuf)-1, "+%02d.c", cursecix); - curpath = concat (descmodulename, suffixbuf, NULL); + srcpath = concat (descmodulename, suffixbuf, NULL); + curpath = + MELT_FIND_FILE (srcpath, + MELT_FILE_IN_DIRECTORY, ".", + MELT_FILE_IN_PATH, srcpathstr, + MELT_FILE_IN_PATH, getenv ("GCCMELT_SOURCE_PATH"), + MELT_FILE_IN_DIRECTORY, melt_source_dir, + NULL); + debugeprintf ("melt_load_module_index srcpath %s ", srcpath); sfil = fopen (curpath, "r"); if (!sfil) warning (0, @@ -8737,6 +8756,7 @@ melt_load_module_index (const char*srcbase, const char*flavor) curpath, MELTDESCR_REQUIRED(melt_secondaryhexmd5tab)[cursecix]); fclose (sfil), sfil = NULL; }; + free (srcpath), srcpath = NULL; free (curpath), curpath = NULL; }; if (MELTDESCR_OPTIONAL(melt_genversionstr) diff --git a/gcc/melt/warmelt-outobj.melt b/gcc/melt/warmelt-outobj.melt index 0a63efb..a8b9650 100644 --- a/gcc/melt/warmelt-outobj.melt +++ b/gcc/melt/warmelt-outobj.melt @@ -3791,7 +3791,12 @@ (add2sbuf_strconst debuf " */") (add2sbuf_indentnl debuf 0) (add2sbuf_strconst debuf "const char melt_modulename[]=\"") - (add2sbuf_cencstring debuf modnamstr) + (code_chunk + genmodnamstr + #{ /* output_melt_descriptor $GENMODNAMSTR + */ + meltgc_add_strbuf_cstr ($DEBUF, lbasename (melt_string_str($MODNAMSTR))); + }# + ) (add2sbuf_strconst debuf "\";") (add2sbuf_indentnl debuf 0) (add2sbuf_strconst debuf "const char melt_modulerealpath[]=\"") -- 1.7.6