From bbb5f07626835f063fd7e10427dec383e6ad0adf Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 25 Apr 2014 16:24:19 +0000 Subject: [PATCH] clang-cl: pass -debug flag to the linker when compiling with debug info llvm-svn: 207233 --- clang/lib/Driver/Tools.cpp | 4 ++++ clang/test/Driver/cl-link.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 0a45fa190a1c..924e040246db 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -7435,6 +7435,10 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-nologo"); + if (Args.hasArg(options::OPT_g_Group)) { + CmdArgs.push_back("-debug"); + } + bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd); if (DLL) { diff --git a/clang/test/Driver/cl-link.c b/clang/test/Driver/cl-link.c index 24e0702c8ab3..309c27dab145 100644 --- a/clang/test/Driver/cl-link.c +++ b/clang/test/Driver/cl-link.c @@ -31,3 +31,7 @@ // ASAN-DLL: "-incremental:no" // ASAN-DLL: "{{.*}}clang_rt.asan_dll_thunk-i386.lib" // ASAN-DLL: "{{.*}}cl-link{{.*}}.obj" + +// RUN: %clang_cl /Zi /Tc%s -### 2>&1 | FileCheck --check-prefix=DEBUG %s +// DEBUG: link.exe +// DEBUG: "-debug"