-
-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Point users to Bugzilla on ICEs #8138
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,25 @@ private void logo() | |
printf("DMD%llu D Compiler %s\n%s %s\n", cast(ulong)size_t.sizeof * 8, global._version, global.copyright, global.written); | ||
} | ||
|
||
/** | ||
Print DMD's logo with more debug information and error-reporting pointers. | ||
|
||
Params: | ||
stream = output stream to print the information on | ||
*/ | ||
extern(C) void printInternalFailure(FILE* stream) | ||
{ | ||
fputs(("---\n" ~ | ||
"ERROR: This is a compiler bug.\n" ~ | ||
"Please report it via https://issues.dlang.org/enter_bug.cgi\n" ~ | ||
"with, preferably, a reduced, reproducible example and the information below.\n" ~ | ||
"DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.\n" ~ | ||
"---\n").ptr, stream); | ||
stream.fprintf("DMD %s\n", global._version); | ||
stream.printPredefinedVersions; | ||
stream.printGlobalConfigs(); | ||
fputs("---\n".ptr, stream); | ||
} | ||
|
||
/** | ||
* Print DMD's usage message on stdout | ||
|
@@ -495,40 +514,10 @@ private int tryMain(size_t argc, const(char)** argv) | |
Objc._init(); | ||
builtin_init(); | ||
|
||
printPredefinedVersions(); | ||
|
||
if (global.params.verbose) | ||
{ | ||
message("binary %s", global.params.argv0); | ||
message("version %s", global._version); | ||
message("config %s", global.inifilename ? global.inifilename : "(none)"); | ||
// Print DFLAGS environment variable | ||
{ | ||
Strings dflags; | ||
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags); | ||
OutBuffer buf; | ||
foreach (flag; dflags.asDArray) | ||
{ | ||
bool needsQuoting; | ||
for (auto flagp = flag; flagp; flagp++) | ||
{ | ||
auto c = flagp[0]; | ||
if (!(isalnum(c) || c == '_')) | ||
{ | ||
needsQuoting = true; | ||
break; | ||
} | ||
} | ||
|
||
if (flag.strchr(' ')) | ||
buf.printf("'%s' ", flag); | ||
else | ||
buf.printf("%s ", flag); | ||
} | ||
|
||
auto res = buf.peekSlice() ? buf.peekSlice()[0 .. $ - 1] : "(none)"; | ||
message("DFLAGS %.*s", res.length, res.ptr); | ||
} | ||
stdout.printPredefinedVersions(); | ||
stdout.printGlobalConfigs(); | ||
} | ||
//printf("%d source files\n",files.dim); | ||
|
||
|
@@ -1094,6 +1083,8 @@ int main() | |
dmd_coverSetMerge(true); | ||
} | ||
|
||
scope(failure) stderr.printInternalFailure; | ||
|
||
auto args = Runtime.cArgs(); | ||
return tryMain(args.argc, cast(const(char)**)args.argv); | ||
} | ||
|
@@ -1406,20 +1397,55 @@ void addDefaultVersionIdentifiers() | |
VersionCondition.addPredefinedGlobalIdent("D_HardFloat"); | ||
} | ||
|
||
private void printPredefinedVersions() | ||
private void printPredefinedVersions(FILE* stream) | ||
{ | ||
if (global.params.verbose && global.versionids) | ||
if (global.versionids) | ||
{ | ||
OutBuffer buf; | ||
foreach (const str; *global.versionids) | ||
{ | ||
buf.writeByte(' '); | ||
buf.writestring(str.toChars()); | ||
} | ||
message("predefs %s", buf.peekString()); | ||
stream.fprintf("predefs %s", buf.peekString()); | ||
} | ||
} | ||
|
||
extern(C) void printGlobalConfigs(FILE* stream) | ||
{ | ||
stream.fprintf("binary %s\n", global.params.argv0); | ||
stream.fprintf("version %s\n", global._version); | ||
stream.fprintf("config %s\n", global.inifilename ? global.inifilename : "(none)"); | ||
// Print DFLAGS environment variable | ||
{ | ||
StringTable environment; | ||
environment._init(0); | ||
Strings dflags; | ||
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags); | ||
environment.reset(1); | ||
OutBuffer buf; | ||
foreach (flag; dflags[]) | ||
{ | ||
bool needsQuoting; | ||
foreach (c; flag[0 .. strlen(flag)]) | ||
{ | ||
if (!(isalnum(c) || c == '_')) | ||
{ | ||
needsQuoting = true; | ||
break; | ||
} | ||
} | ||
|
||
if (flag.strchr(' ')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but I just moved the code - check the red part on the left. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently it's not that easy (breaks a test), so I will modify this in a different PR. |
||
buf.printf("'%s' ", flag); | ||
else | ||
buf.printf("%s ", flag); | ||
} | ||
|
||
auto res = buf.peekSlice() ? buf.peekSlice()[0 .. $ - 1] : "(none)"; | ||
stream.fprintf("DFLAGS %.*s\n", res.length, res.ptr); | ||
} | ||
} | ||
|
||
/**************************************** | ||
* Determine the instruction set to be used. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly
readFrom
callsgetenv
which returns a boring, old C-string.