Backtrace property with swift

Hi there, i am interested to know how is backtrace (Backtraces (The GNU C Library)) enabled in Swift. From what i understand, flag like -rdynamic or --export-dynamic is need to pass to the linker when building swift/swiftc. However, when I look for those flags in the CMake files within swift source directory and the build.ninja file in the building directory , i could not find any.

I wonder what makes backtrace work without those flags being passed. Further, where should i pass those flags if i need to?

Still cannot obtain the backtrace when a swift app crashes on s390x. The following is the test code and it should cause a crash in the runtime and print the backtrace.

func main() {
  let x = UnsafePointer<Int>(bitPattern: 0)!
  print("\(x.pointee)")
}

main()

However, the output is

Fatal error: Unexpectedly found nil while unwrapping an Optional value: file backtrace.swift, line 2
Current stack trace:
Illegal instruction (core dumped)

The error happens at stdlib/public/runtime/Errors.cpp, line 203.

195 LLVM_ATTRIBUTE_NOINLINE
196 void swift::printCurrentBacktrace(unsigned framesToSkip) {
197 #if SWIFT_SUPPORTS_BACKTRACE_REPORTING
198   constexpr unsigned maxSupportedStackDepth =     128;
199   void *addrs[maxSupportedStackDepth];
200 #if defined(_WIN32)
201   int symbolCount = CaptureStackBackTrace(0, maxSupportedStackDepth, addrs, NULL);
202 #else
203   int symbolCount = backtrace(addrs, maxSupportedStackDepth);
204 #endif
205   for (int i = framesToSkip; i < symbolCount; ++i) {
206     dumpStackTraceEntry(i - framesToSkip, addrs[i]);
207   }
208 #else
209   fprintf(stderr, "<backtrace unavailable>\n")    ;
210 #endif
211 }

The backtrace function from glibc returns 1 instead of the number of buffer entries. The backtrace function itself seems fine since it works elsewhere (not with swift). Any ideas what the root cause is? Thanks.