Skip to content

Commit

Permalink
Add compilation options in the faustassert message.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Nov 29, 2017
1 parent 0586cfa commit c1ece9d
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 54 deletions.
13 changes: 13 additions & 0 deletions compiler/errors/errormsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ using namespace std;

const char* yyfilename = "????";

void faustassert(bool cond)
{
if (!cond) {
#ifndef EMCC
stacktrace(20);
#endif
std::stringstream str;
str << "ASSERT : please report the stack trace and the failing DSP file to Faust developers (";
gGlobal->printCompilationOptions(str); str << ")\n";
throw faustexception(str.str());
}
}

void lexerror(const char* msg)
{
string fullmsg = "ERROR : " + string(msg) + '\n';
Expand Down
4 changes: 2 additions & 2 deletions compiler/errors/errormsg.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "tlib.hh"

extern int yylineno;
extern const char * yyfilename;
extern int yylineno;
extern const char* yyfilename;

// associate and retrieve file and line properties to a symbol definition
void setDefProp(Tree sym, const char* filename, int lineno);
Expand Down
10 changes: 1 addition & 9 deletions compiler/errors/exception.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ inline void stacktrace(int val)
#endif
}

inline void faustassert(bool cond)
{
if (!cond) {
#ifndef EMCC
stacktrace(20);
#endif
throw faustexception("ASSERT : please report the stack trace and the failing DSP file to Faust developers.\n");
}
}
void faustassert(bool cond);

#endif
2 changes: 1 addition & 1 deletion compiler/generator/code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void CodeContainer::generateJSON(JSONInstVisitor* visitor)
{
// Prepare compilation options
stringstream options;
printCompilationOptions(options);
gGlobal->printCompilationOptions(options);

visitor->init("", fNumInputs, fNumOutputs, "", "", FAUSTVERSION, options.str(), "", std::map<std::string, int>());
generateUserInterface(visitor);
Expand Down
38 changes: 1 addition & 37 deletions compiler/generator/code_container.hh
Original file line number Diff line number Diff line change
Expand Up @@ -130,42 +130,6 @@ class CodeContainer : public virtual Garbageable {
void generateDAGLoopAux(CodeLoop* loop, BlockInst* loop_code, DeclareVarInst* count, int loop_num, bool omp = false);
void generateDAGLoopInternal(CodeLoop* loop, BlockInst* block, DeclareVarInst* count, bool omp);

void printCompilationOptions(ostream& dst)
{
if (gGlobal->gSchedulerSwitch) {
dst << "-sch"
<< " -vs " << gGlobal->gVecSize
<< ((gGlobal->gFunTaskSwitch) ? " -fun" : "")
<< ((gGlobal->gGroupTaskSwitch) ? " -g" : "")
<< ((gGlobal->gDeepFirstSwitch) ? " -dfs" : "")
<< ((gGlobal->gFloatSize == 2) ? " -double" : (gGlobal->gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gGlobal->gFTZMode
<< ((gGlobal->gMemoryManager) ? " -mem" : "");
} else if (gGlobal->gVectorSwitch) {
dst << "-vec" << " -lv " << gGlobal->gVectorLoopVariant
<< " -vs " << gGlobal->gVecSize
<< ((gGlobal->gFunTaskSwitch) ? " -fun" : "")
<< ((gGlobal->gGroupTaskSwitch) ? " -g" : "")
<< ((gGlobal->gDeepFirstSwitch) ? " -dfs" : "")
<< ((gGlobal->gFloatSize == 2) ? " -double" : (gGlobal->gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gGlobal->gFTZMode
<< ((gGlobal->gMemoryManager) ? " -mem" : "");
} else if (gGlobal->gOpenMPSwitch) {
dst << "-omp" << " -vs " << gGlobal->gVecSize
<< " -vs " << gGlobal->gVecSize
<< ((gGlobal->gFunTaskSwitch) ? " -fun" : "")
<< ((gGlobal->gGroupTaskSwitch) ? " -g" : "")
<< ((gGlobal->gDeepFirstSwitch) ? " -dfs" : "")
<< ((gGlobal->gFloatSize == 2) ? " -double" : (gGlobal->gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gGlobal->gFTZMode
<< ((gGlobal->gMemoryManager) ? " -mem" : "");
} else {
dst << ((gGlobal->gFloatSize == 1) ? "-scal" : ((gGlobal->gFloatSize == 2) ? "-double" : (gGlobal->gFloatSize == 3) ? "-quad" : ""))
<< " -ftz " << gGlobal->gFTZMode
<< ((gGlobal->gMemoryManager) ? " -mem" : "");
}
}

void printHeader(ostream& dst)
{
// defines the metadata we want to print as comments at the begin of in the file
Expand All @@ -191,7 +155,7 @@ class CodeContainer : public virtual Garbageable {

dst << "Code generated with Faust " << FAUSTVERSION << " (https://faust.grame.fr)" << endl;
dst << "Compilation options: ";
printCompilationOptions(dst);
gGlobal->printCompilationOptions(dst);
dst << "\n------------------------------------------------------------ */" << endl;
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/wasm/wasm_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void WASMCodeContainer::produceClass()

// Prepare compilation options
stringstream options;
printCompilationOptions(options);
gGlobal->printCompilationOptions(options);

stringstream size;
size << gGlobal->gWASMVisitor->getStructSize();
Expand Down Expand Up @@ -359,7 +359,7 @@ void WASMCodeContainer::produceClass()
// Generate JSON and getSize
tab(n, fHelper); fHelper << "/*\n" << "Code generated with Faust version " << FAUSTVERSION << endl;
fHelper << "Compilation options: ";
printCompilationOptions(fHelper);
gGlobal->printCompilationOptions(fHelper);
fHelper << "\n*/\n";

// Generate JSON
Expand Down
4 changes: 2 additions & 2 deletions compiler/generator/wasm/wast_code_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void WASTCodeContainer::produceClass()

// Prepare compilation options
stringstream options;
printCompilationOptions(options);
gGlobal->printCompilationOptions(options);

stringstream size;
size << gGlobal->gWASTVisitor->getStructSize();
Expand Down Expand Up @@ -330,7 +330,7 @@ void WASTCodeContainer::produceClass()
// Generate JSON and getSize
tab(n, fHelper); fHelper << "/*\n" << "Code generated with Faust version " << FAUSTVERSION << endl;
fHelper << "Compilation options: ";
printCompilationOptions(fHelper);
gGlobal->printCompilationOptions(fHelper);
fHelper << "\n*/\n";

// Generate JSON
Expand Down
39 changes: 38 additions & 1 deletion compiler/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,44 @@ void global::init()
gInjectFlag = false; // inject an external source file into the architecture file
gInjectFile = ""; // instead of a compiled dsp file
}


void global::printCompilationOptions(ostream& dst)
{
if (gSchedulerSwitch) {
dst << "-sch"
<< " -vs " << gVecSize
<< ((gFunTaskSwitch) ? " -fun" : "")
<< ((gGroupTaskSwitch) ? " -g" : "")
<< ((gDeepFirstSwitch) ? " -dfs" : "")
<< ((gFloatSize == 2) ? " -double" : (gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gFTZMode
<< ((gMemoryManager) ? " -mem" : "");
} else if (gVectorSwitch) {
dst << "-vec" << " -lv " << gVectorLoopVariant
<< " -vs " << gVecSize
<< ((gFunTaskSwitch) ? " -fun" : "")
<< ((gGroupTaskSwitch) ? " -g" : "")
<< ((gDeepFirstSwitch) ? " -dfs" : "")
<< ((gFloatSize == 2) ? " -double" : (gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gFTZMode
<< ((gMemoryManager) ? " -mem" : "");
} else if (gOpenMPSwitch) {
dst << "-omp" << " -vs " << gVecSize
<< " -vs " << gVecSize
<< ((gFunTaskSwitch) ? " -fun" : "")
<< ((gGroupTaskSwitch) ? " -g" : "")
<< ((gDeepFirstSwitch) ? " -dfs" : "")
<< ((gFloatSize == 2) ? " -double" : (gFloatSize == 3) ? " -quad" : "")
<< " -ftz " << gFTZMode
<< ((gMemoryManager) ? " -mem" : "");
} else {
dst << ((gFloatSize == 1) ? "-scal" : ((gFloatSize == 2) ? "-double" : (gFloatSize == 3) ? "-quad" : ""))
<< " -ftz " << gFTZMode
<< ((gMemoryManager) ? " -mem" : "");
}
}


global::~global()
{
Garbageable::cleanup();
Expand Down
2 changes: 2 additions & 0 deletions compiler/global.hh
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ struct global {
{
return gVarTypeTable[name]->getType();
}

void printCompilationOptions(ostream& dst);
};

// Unique shared global pointer
Expand Down

0 comments on commit c1ece9d

Please sign in to comment.