Skip to content

Commit

Permalink
Remove redundant suggestions on linker errors (dlang#16711)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorpel authored and thewilsonator committed Oct 7, 2024
1 parent 0880ff2 commit 7879619
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions compiler/src/dmd/link.d
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,8 @@ void parseLinkerOutput(const(char)[] linkerOutput, ErrorSink eSink)
return s;
}

bool missingSymbols = false;
bool missingDfunction = false;
bool missingCSymbols = false;
bool missingDsymbols = false;
bool missingMain = false;

void missingSymbol(const(char)[] name, const(char)[] referencedFrom)
Expand All @@ -1437,11 +1437,12 @@ void parseLinkerOutput(const(char)[] linkerOutput, ErrorSink eSink)
name = name[1 .. $]; // MS LINK prepends underscore to the existing one
auto sym = demangle(name);

missingSymbols = true;
if (sym == "main")
missingMain = true;
if (sym != name)
missingDfunction = true;
else if (sym != name)
missingDsymbols = true;
else
missingCSymbols = true;

eSink.error(Loc.initial, "undefined reference to `%.*s`", cast(int) sym.length, sym.ptr);
if (referencedFrom.length > 0)
Expand Down Expand Up @@ -1513,10 +1514,9 @@ void parseLinkerOutput(const(char)[] linkerOutput, ErrorSink eSink)

if (missingMain)
eSink.errorSupplemental(Loc.initial, "perhaps define a `void main() {}` function or use the `-main` switch");

if (missingDfunction)
else if (missingDsymbols)
eSink.errorSupplemental(Loc.initial, "perhaps `.d` files need to be added on the command line, or use `-i` to compile imports");
else if (missingSymbols)
else if (missingCSymbols)
eSink.errorSupplemental(Loc.initial, "perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`");
}

Expand Down

0 comments on commit 7879619

Please sign in to comment.