Commit 5218cb82 authored by dons's avatar dons
Browse files

[project @ 2004-06-18 09:02:40 by dons]

Have loadObj ignore requests to load an object more than once, instead
of actually loading the object, then dying.

This change lets user-land loaders safely work inside GHCi, when they
would have no way to know what packages had already been loaded.

Help from SimonM and Andre Pang.
parent a06978c1
...@@ -983,24 +983,25 @@ loadObj( char *path ) ...@@ -983,24 +983,25 @@ loadObj( char *path )
/* fprintf(stderr, "loadObj %s\n", path ); */ /* fprintf(stderr, "loadObj %s\n", path ); */
/* Check that we haven't already loaded this object. Don't give up /* Check that we haven't already loaded this object.
at this stage; ocGetNames_* will barf later. */ Ignore requests to load multiple times */
{ {
ObjectCode *o; ObjectCode *o;
int is_dup = 0; int is_dup = 0;
for (o = objects; o; o = o->next) { for (o = objects; o; o = o->next) {
if (0 == strcmp(o->fileName, path)) if (0 == strcmp(o->fileName, path)) {
is_dup = 1; is_dup = 1;
break; /* don't need to search further */
}
} }
if (is_dup) { if (is_dup) {
fprintf(stderr, IF_DEBUG(linker, belch(
"\n\n"
"GHCi runtime linker: warning: looks like you're trying to load the\n" "GHCi runtime linker: warning: looks like you're trying to load the\n"
"same object file twice:\n" "same object file twice:\n"
" %s\n" " %s\n"
"GHCi will continue, but a duplicate-symbol error may shortly follow.\n" "GHCi will ignore this, but be warned.\n"
"\n" , path));
, path); return 1; /* success */
} }
} }
......
Supports Markdown
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