Skip to content

Commit 7a85853

Browse files
committed
Point users to Bugzilla on ICEs
1 parent 408c468 commit 7a85853

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

src/dmd/backend/util2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ void *ph_calloc(size_t nbytes);
3838
void ph_free(void *p);
3939
void *ph_realloc(void *p , size_t nbytes);
4040

41+
extern "C" void printInternalFailure(FILE* stream); // from dmd/mars.d
42+
4143

4244
void util_exit(int exitcode);
4345

@@ -52,6 +54,7 @@ void file_progress()
5254
void util_assert(const char *file, int line)
5355
{
5456
fflush(stdout);
57+
printInternalFailure(stdout);
5558
printf("Internal error: %s %d\n",file,line);
5659
err_exit();
5760
#if __clang__

src/dmd/mars.d

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ private void logo()
7070
printf("DMD%llu D Compiler %s\n%s %s\n", cast(ulong)size_t.sizeof * 8, global._version, global.copyright, global.written);
7171
}
7272

73+
/**
74+
Print DMD's logo with more debug information and error-reporting pointers.
75+
76+
Params:
77+
stream = output stream to print the information on
78+
*/
79+
extern(C) void printInternalFailure(FILE* stream)
80+
{
81+
fputs(("---\n" ~
82+
"ERROR: This is a compiler bug.\n" ~
83+
"Please report it via https://issues.dlang.org/enter_bug.cgi\n" ~
84+
"with, preferably, a reduced, reproducible example and the information below.\n" ~
85+
"DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.\n" ~
86+
"---\n").ptr, stream);
87+
stream.fprintf("DMD %s\n", global._version);
88+
stream.printPredefinedVersions;
89+
stream.printGlobalConfigs();
90+
fputs("---\n".ptr, stream);
91+
}
7392

7493
/**
7594
* Print DMD's usage message on stdout
@@ -495,40 +514,10 @@ private int tryMain(size_t argc, const(char)** argv)
495514
Objc._init();
496515
builtin_init();
497516

498-
printPredefinedVersions();
499-
500517
if (global.params.verbose)
501518
{
502-
message("binary %s", global.params.argv0);
503-
message("version %s", global._version);
504-
message("config %s", global.inifilename ? global.inifilename : "(none)");
505-
// Print DFLAGS environment variable
506-
{
507-
Strings dflags;
508-
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags);
509-
OutBuffer buf;
510-
foreach (flag; dflags.asDArray)
511-
{
512-
bool needsQuoting;
513-
for (auto flagp = flag; flagp; flagp++)
514-
{
515-
auto c = flagp[0];
516-
if (!(isalnum(c) || c == '_'))
517-
{
518-
needsQuoting = true;
519-
break;
520-
}
521-
}
522-
523-
if (flag.strchr(' '))
524-
buf.printf("'%s' ", flag);
525-
else
526-
buf.printf("%s ", flag);
527-
}
528-
529-
auto res = buf.peekSlice() ? buf.peekSlice()[0 .. $ - 1] : "(none)";
530-
message("DFLAGS %.*s", res.length, res.ptr);
531-
}
519+
stdout.printPredefinedVersions();
520+
stdout.printGlobalConfigs();
532521
}
533522
//printf("%d source files\n",files.dim);
534523

@@ -1094,6 +1083,8 @@ int main()
10941083
dmd_coverSetMerge(true);
10951084
}
10961085

1086+
scope(failure) stderr.printInternalFailure;
1087+
10971088
auto args = Runtime.cArgs();
10981089
return tryMain(args.argc, cast(const(char)**)args.argv);
10991090
}
@@ -1406,20 +1397,55 @@ void addDefaultVersionIdentifiers()
14061397
VersionCondition.addPredefinedGlobalIdent("D_HardFloat");
14071398
}
14081399

1409-
private void printPredefinedVersions()
1400+
private void printPredefinedVersions(FILE* stream)
14101401
{
1411-
if (global.params.verbose && global.versionids)
1402+
if (global.versionids)
14121403
{
14131404
OutBuffer buf;
14141405
foreach (const str; *global.versionids)
14151406
{
14161407
buf.writeByte(' ');
14171408
buf.writestring(str.toChars());
14181409
}
1419-
message("predefs %s", buf.peekString());
1410+
stream.fprintf("predefs %s", buf.peekString());
14201411
}
14211412
}
14221413

1414+
extern(C) void printGlobalConfigs(FILE* stream)
1415+
{
1416+
stream.fprintf("binary %s\n", global.params.argv0);
1417+
stream.fprintf("version %s\n", global._version);
1418+
stream.fprintf("config %s\n", global.inifilename ? global.inifilename : "(none)");
1419+
// Print DFLAGS environment variable
1420+
{
1421+
StringTable environment;
1422+
environment._init(0);
1423+
Strings dflags;
1424+
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags);
1425+
environment.reset(1);
1426+
OutBuffer buf;
1427+
foreach (flag; dflags[])
1428+
{
1429+
bool needsQuoting;
1430+
foreach (c; flag[0 .. strlen(flag)])
1431+
{
1432+
if (!(isalnum(c) || c == '_' || c == '-' || c == '/' || c == '.'))
1433+
{
1434+
needsQuoting = true;
1435+
break;
1436+
}
1437+
}
1438+
1439+
if (needsQuoting)
1440+
buf.printf("'%s' ", flag);
1441+
else
1442+
buf.printf("%s ", flag);
1443+
}
1444+
1445+
auto res = buf.peekSlice() ? buf.peekSlice()[0 .. $ - 1] : "(none)";
1446+
stream.fprintf("DFLAGS %.*s\n", res.length, res.ptr);
1447+
}
1448+
}
14231449

14241450
/****************************************
14251451
* Determine the instruction set to be used.

test/runnable/test18141.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ else
66
expected="Posix"
77
fi
88

9-
echo "void main(){}" | "${DMD}" -v -o- - | grep "predefs" | grep "${expected}"
9+
out=$(echo "void main(){}" | "${DMD}" -v -o- -)
10+
echo "$out" | grep "predefs" | grep "${expected}"

0 commit comments

Comments
 (0)