do not hide stderr when building native optimizer, and option parsing improvements

This commit is contained in:
Alon Zakai 2014-11-28 10:26:40 -08:00
Родитель 130e55fdf9
Коммит 24a6676c0c
2 изменённых файлов: 18 добавлений и 7 удалений

Просмотреть файл

@ -32,7 +32,6 @@ def get_native_optimizer():
shared.logging.debug('building native optimizer')
output = shared.Cache.get_path('optimizer.exe')
shared.try_delete(output)
errs = []
for compiler in [shared.CLANG, 'g++', 'clang++']: # try our clang first, otherwise hope for a system compiler in the path
shared.logging.debug(' using ' + compiler)
out, err = subprocess.Popen([compiler,
@ -40,11 +39,10 @@ def get_native_optimizer():
shared.path_from_root('tools', 'optimizer', 'parser.cpp'),
shared.path_from_root('tools', 'optimizer', 'simple_ast.cpp'),
shared.path_from_root('tools', 'optimizer', 'optimizer.cpp'),
'-O3', '-std=c++11', '-fno-exceptions', '-fno-rtti', '-o', output], stderr=subprocess.PIPE).communicate()
'-O3', '-std=c++11', '-fno-exceptions', '-fno-rtti', '-o', output]).communicate()
# for profiling/debugging: '-g', '-fno-omit-frame-pointer'
if os.path.exists(output): return output
errs.append(err)
raise Exception('failed to build native optimizer, errors from each attempt: ' + '\n=================\n'.join(errs))
raise Exception('failed to build native optimizer')
return shared.Cache.get('optimizer.exe', create_optimizer, extension='exe')
# Check if we should run a pass or set of passes natively. if a set of passes, they must all be valid to run in the native optimizer at once.

Просмотреть файл

@ -855,7 +855,10 @@ int measureCost(Ref ast) {
// Params
//==================
bool preciseF32 = false;
bool preciseF32 = false,
receiveJSON = false,
emitJSON = false,
minifyWhitespace = false;
//=====================
// Optimization passes
@ -2675,6 +2678,16 @@ void minifyLocals(Ref ast) {
#include <string.h> // only use this for param checking
int main(int argc, char **argv) {
// Read directives
for (int i = 2; i < argc; i++) {
std::string str(argv[i]);
if (str == "asm") {} // the only possibility for us
else if (str == "asmPreciseF32") preciseF32 = true;
else if (str == "receiveJSON") receiveJSON = true;
else if (str == "emitJSON") emitJSON = true;
else if (str == "minifyWhitespace") minifyWhitespace = true;
}
// Read input file
FILE *f = fopen(argv[1], "r");
assert(f);
@ -2704,8 +2717,8 @@ int main(int argc, char **argv) {
for (int i = 2; i < argc; i++) {
std::string str(argv[i]);
if (str == "asm") {} // the default for us
else if (str == "asmPreciseF32") preciseF32 = true;
else if (str == "receiveJSON" || str == "emitJSON") {} // the default for us
else if (str == "asmPreciseF32") {}
else if (str == "receiveJSON" || str == "emitJSON") {}
else if (str == "eliminate") eliminate(doc);
else if (str == "eliminateMemSafe") eliminateMemSafe(doc);
else if (str == "simplifyExpressions") simplifyExpressions(doc);