Skip to content

Commit 3e25ca7

Browse files
committed
[flang][Driver] When linking with the Fortran runtime also link with libexecinfo
Also link with libexecinfo on FreeBSD, NetBSD, OpenBSD and DragonFly for the backtrace functions.
1 parent efa287d commit 3e25ca7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,11 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13401340
CmdArgs.push_back("-lFortranRuntime");
13411341
CmdArgs.push_back("-lFortranDecimal");
13421342
addArchSpecificRPath(TC, Args, CmdArgs);
1343+
1344+
// needs libexecinfo for backtrace functions
1345+
if (TC.getTriple().isOSFreeBSD() || TC.getTriple().isOSNetBSD() ||
1346+
TC.getTriple().isOSOpenBSD() || TC.getTriple().isOSDragonFly())
1347+
CmdArgs.push_back("-lexecinfo");
13431348
}
13441349

13451350
// libomp needs libatomic for atomic operations if using libgcc

flang/test/Driver/backtrace.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!RUN: %flang --target=aarch64-unknown-openbsd -### %s 2>&1 | FileCheck --check-prefixes=BACKTRACE %s
2+
3+
!BACKTRACE: -lexecinfo

0 commit comments

Comments
 (0)