From 34bac1f7b1ad8018b0d456f38744891c4bf56f63 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 12 Apr 2011 23:59:20 +0000 Subject: [PATCH] Driver/no-integrated-as: Fix forwarding of -g flag to assembler, when .s input undergoes preprocessing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129414 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 287056fc7b..86c0fe8932 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2604,11 +2604,16 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, assert(Inputs.size() == 1 && "Unexpected number of inputs."); const InputInfo &Input = Inputs[0]; - // Bit of a hack, this is only used for original inputs. - // - // FIXME: This is broken for preprocessed .s inputs. - if (Input.isFilename() && - strcmp(Input.getFilename(), Input.getBaseInput()) == 0) { + // Determine the original source input. + const Action *SourceAction = &JA; + while (SourceAction->getKind() != Action::InputClass) { + assert(!SourceAction->getInputs().empty() && "unexpected root action!"); + SourceAction = SourceAction->getInputs()[0]; + } + + // Forward -g, assuming we are dealing with an actual assembly file. + if (SourceAction->getType() == types::TY_Asm || + SourceAction->getType() == types::TY_PP_Asm) { if (Args.hasArg(options::OPT_gstabs)) CmdArgs.push_back("--gstabs"); else if (Args.hasArg(options::OPT_g_Group)) -- 2.40.0