[clang] [flang] [llvm] [flang] Add -fbacktrace and -fno-backtrace (PR #241967)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 17 02:37:06 PST 2026


================
@@ -326,6 +326,19 @@ void ExecutionEnvironment::Configure(int ac, const char *av[],
     }
   }
 
+  // FLANG_ERROR_BACKTRACE overrides the -fbacktrace default. Only the first
+  // character is significant, matching gfortran: 1/Y/y enables, 0/N/n disables.
+  // Any other value is ignored. -fno-backtrace supplies "0" when the variable
+  // is not already set.
+  backtrace = true;
+  if (auto *x{std::getenv("FLANG_ERROR_BACKTRACE")}) {
+    if (*x == '1' || *x == 'Y' || *x == 'y') {
+      backtrace = true;
+    } else if (*x == '0' || *x == 'N' || *x == 'n') {
+      backtrace = false;
+    }
+  }
----------------
shivaramaarao wrote:

Sure. I will incorporate this change. I have followed the gfortran environment variable setting for GFORTRAN_ERROR_BACKTRACE that supports 0/N/n and 1/Y/y. 

https://github.com/llvm/llvm-project/pull/241967


More information about the cfe-commits mailing list