diff --git a/ispc.cpp b/ispc.cpp index da86f981..aab79310 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -1102,6 +1102,11 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo #else /* LLVM 3.7+ */ m_targetMachine->Options.MCOptions.AsmVerbose = true; #endif + // Change default version of generated DWARF. + if (g->generateDWARFVersion != 0) { + m_targetMachine->Options.MCOptions.DwarfVersion = g->generateDWARFVersion; + } + // Initialize TargetData/DataLayout in 3 steps. // 1. Get default data layout first std::string dl_string; @@ -1206,7 +1211,7 @@ Target::SupportedTargets() { "avx512skx-i32x16, " #endif "generic-x1, generic-x4, generic-x8, generic-x16, " - "generic-x32, generic-x64, *-generic-x16, " + "generic-x32, generic-x64, *-generic-x16" #ifdef ISPC_ARM_ENABLED ", neon-i8x16, neon-i16x8, neon-i32x4" #endif @@ -1517,6 +1522,7 @@ Globals::Globals() { emitPerfWarnings = true; emitInstrumentation = false; generateDebuggingSymbols = false; + generateDWARFVersion = 0; enableFuzzTest = false; fuzzTestSeed = -1; mangleFunctionsWithTarget = false; diff --git a/ispc.h b/ispc.h index e66c0e62..773476f1 100644 --- a/ispc.h +++ b/ispc.h @@ -606,6 +606,14 @@ struct Globals { program in its output. */ bool generateDebuggingSymbols; + /** Require generation of DWARF of certain version (2, 3, 4). For + default version, this field is set to 0. */ + // Hint: to verify dwarf version in the object file, run on Linux: + // readelf --debug-dump=info object.o | grep -A 2 'Compilation Unit @' + // on Mac: + // xcrun dwarfdump -r0 object.o + int generateDWARFVersion; + /** If true, function names are mangled by appending the target ISA and vector width to them. */ bool mangleFunctionsWithTarget; diff --git a/main.cpp b/main.cpp index 968a3cfc..3ede7e43 100644 --- a/main.cpp +++ b/main.cpp @@ -104,12 +104,13 @@ usage(int ret) { #ifdef ISPC_IS_WINDOWS printf(" [--dllexport]\t\t\tMake non-static functions DLL exported. Windows only.\n"); #endif + printf(" [--dwarf-version={2,3,4}]\t\tGenerate source-level debug information with given DWARF version (triggers -g)\n"); printf(" [--emit-asm]\t\t\tGenerate assembly language file as output\n"); printf(" [--emit-c++]\t\t\tEmit a C++ source file as output\n"); printf(" [--emit-llvm]\t\t\tEmit LLVM bitode file as output\n"); printf(" [--emit-obj]\t\t\tGenerate object file file as output (default)\n"); printf(" [--force-alignment=]\t\tForce alignment in memory allocations routine to be \n"); - printf(" [-g]\t\t\t\tGenerate debugging information\n"); + printf(" [-g]\t\t\t\tGenerate source-level debug information\n"); printf(" [--help]\t\t\t\tPrint help\n"); printf(" [--help-dev]\t\t\tPrint help for developer options\n"); printf(" [--host-stub ]\t\tEmit host-side offload stub functions to file\n"); @@ -121,12 +122,12 @@ usage(int ret) { printf(" fast\t\t\t\tUse high-performance but lower-accuracy math functions\n"); printf(" svml\t\t\t\tUse the Intel(r) SVML math libraries\n"); printf(" system\t\t\t\tUse the system's math library (*may be quite slow*)\n"); - printf(" [-MMM \t\t\t\tWrite #include dependencies to given file.\n"); + printf(" [-MMM \t\t\tWrite #include dependencies to given file.\n"); printf(" [--no-omit-frame-pointer]\t\tDisable frame pointer omission. It may be useful for profiling\n"); printf(" [--nostdlib]\t\t\tDon't make the ispc standard library available\n"); printf(" [--nocpp]\t\t\t\tDon't run the C preprocessor\n"); printf(" [-o /--outfile=]\tOutput filename (may be \"-\" for standard output)\n"); - printf(" [-O0/-O(1/2/3)]\t\t\t\tSet optimization level (off or on). Optimizations are on by default.\n"); + printf(" [-O0/-O(1/2/3)]\t\t\tSet optimization level (off or on). Optimizations are on by default.\n"); printf(" [--opt=