diff options
-rw-r--r-- | include/clang/Driver/Types.def | 1 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 33 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 42 | ||||
-rw-r--r-- | test/Driver/darwin-dsymutil.c | 31 | ||||
-rw-r--r-- | test/Driver/darwin-ld.c | 4 |
5 files changed, 62 insertions, 49 deletions
diff --git a/include/clang/Driver/Types.def b/include/clang/Driver/Types.def index 61a5043b34..111262e712 100644 --- a/include/clang/Driver/Types.def +++ b/include/clang/Driver/Types.def @@ -77,5 +77,6 @@ TYPE("precompiled-header", PCH, INVALID, "gch", "A") TYPE("object", Object, INVALID, "o", "") TYPE("treelang", Treelang, INVALID, 0, "u") TYPE("image", Image, INVALID, "out", "") +TYPE("dSYM", dSYM, INVALID, "dSYM", "") TYPE("dependencies", Dependencies, INVALID, "d", "") TYPE("none", Nothing, INVALID, 0, "u") diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index da83803dd7..cae2243b2e 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -504,7 +504,8 @@ void Driver::BuildUniversalActions(const ArgList &Args, ActionList SingleActions; BuildActions(Args, SingleActions); - // Add in arch binding and lipo (if necessary) for every top level action. + // Add in arch bindings for every top level action, as well as lipo and + // dsymutil steps if needed. for (unsigned i = 0, e = SingleActions.size(); i != e; ++i) { Action *Act = SingleActions[i]; @@ -531,6 +532,19 @@ void Driver::BuildUniversalActions(const ArgList &Args, Actions.append(Inputs.begin(), Inputs.end()); else Actions.push_back(new LipoJobAction(Inputs, Act->getType())); + + // Add a 'dsymutil' step if necessary. + if (Act->getType() == types::TY_Image) { + Arg *A = Args.getLastArg(options::OPT_g_Group); + if (A && !A->getOption().matches(options::OPT_g0) && + !A->getOption().matches(options::OPT_gstabs)) { + ActionList Inputs; + Inputs.push_back(Actions.back()); + Actions.pop_back(); + + Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM)); + } + } } } @@ -992,9 +1006,17 @@ void Driver::BuildJobsForAction(Compilation &C, InputInfoList InputInfos; for (ActionList::const_iterator it = Inputs->begin(), ie = Inputs->end(); it != ie; ++it) { + // Treat dsymutil sub-jobs as being at the top-level too, they shouldn't get + // temporary output names. + // + // FIXME: Clean this up. + bool SubJobAtTopLevel = false; + if (AtTopLevel && isa<DsymutilJobAction>(A)) + SubJobAtTopLevel = true; + InputInfo II; BuildJobsForAction(C, *it, TC, BoundArch, TryToUsePipeInput, - /*AtTopLevel*/false, LinkingOutput, II); + SubJobAtTopLevel, LinkingOutput, II); InputInfos.push_back(II); } @@ -1023,6 +1045,11 @@ void Driver::BuildJobsForAction(Compilation &C, // Always use the first input as the base input. const char *BaseInput = InputInfos[0].getBaseInput(); + // ... except dsymutil actions, which use their actual input as the base + // input. + if (JA->getType() == types::TY_dSYM) + BaseInput = InputInfos[0].getFilename(); + // Determine the place to write output to (nothing, pipe, or filename) and // where to put the new job. if (JA->getType() == types::TY_Nothing) { @@ -1065,7 +1092,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, bool AtTopLevel) const { llvm::PrettyStackTraceString CrashInfo("Computing output path"); // Output to a user requested destination? - if (AtTopLevel) { + if (AtTopLevel && !isa<DsymutilJobAction>(JA)) { if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o)) return C.addResultFile(FinalOutput->getValue(C.getArgs())); } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 518debce93..78f2d70073 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2215,26 +2215,6 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, Dest.addCommand(new Command(JA, *this, Exec, CmdArgs)); } -/// Helper routine for seeing if we should use dsymutil; this is a -/// gcc compatible hack, we should remove it and use the input -/// type information. -static bool isSourceSuffix(const char *Str) { - // match: 'C', 'CPP', 'c', 'cc', 'cp', 'c++', 'cpp', 'cxx', 'm', - // 'mm'. - return llvm::StringSwitch<bool>(Str) - .Case("C", true) - .Case("c", true) - .Case("m", true) - .Case("cc", true) - .Case("cp", true) - .Case("mm", true) - .Case("CPP", true) - .Case("c++", true) - .Case("cpp", true) - .Case("cxx", true) - .Default(false); -} - void darwin::DarwinTool::AddDarwinArch(const ArgList &Args, ArgStringList &CmdArgs) const { llvm::StringRef ArchName = getDarwinToolChain().getDarwinArchName(Args); @@ -2555,28 +2535,6 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, break; } } - - // Run dsymutil if we are making an executable in a single step. - // - // FIXME: Currently we don't want to do this when we are part of a - // universal build step, as this would end up creating stray temp - // files. - if (!LinkingOutput && - Args.getLastArg(options::OPT_g_Group) && - !Args.getLastArg(options::OPT_gstabs) && - !Args.getLastArg(options::OPT_g0)) { - // FIXME: This is gross, but matches gcc. The test only considers - // the suffix (not the -x type), and then only of the first - // source input. Awesome. - const char *Suffix = strrchr(BaseInput, '.'); - if (Suffix && isSourceSuffix(Suffix + 1)) { - const char *Exec = - Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil")); - ArgStringList CmdArgs; - CmdArgs.push_back(Output.getFilename()); - C.getJobs().addCommand(new Command(JA, *this, Exec, CmdArgs)); - } - } } void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, diff --git a/test/Driver/darwin-dsymutil.c b/test/Driver/darwin-dsymutil.c new file mode 100644 index 0000000000..fd236dd60c --- /dev/null +++ b/test/Driver/darwin-dsymutil.c @@ -0,0 +1,31 @@ +// Check that we run dsymutil properly with multiple -arch options. +// +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-phases \ +// RUN: -arch i386 -arch x86_64 %s -g 2> %t +// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s +// +// CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-dsymutil.c", c +// CHECK-MULTIARCH-ACTIONS: 1: preprocessor, {0}, cpp-output +// CHECK-MULTIARCH-ACTIONS: 2: compiler, {1}, assembler +// CHECK-MULTIARCH-ACTIONS: 3: assembler, {2}, object +// CHECK-MULTIARCH-ACTIONS: 4: linker, {3}, image +// CHECK-MULTIARCH-ACTIONS: 5: bind-arch, "i386", {4}, image +// CHECK-MULTIARCH-ACTIONS: 6: bind-arch, "x86_64", {4}, image +// CHECK-MULTIARCH-ACTIONS: 7: lipo, {5, 6}, image +// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM +// +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \ +// RUN: -arch i386 -arch x86_64 %s -g 2> %t +// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s +// +// CHECK-MULTIARCH-BINDINGS: "x86_64-apple-darwin10" - "darwin::Lipo", inputs: [{{.*}}, {{.*}}], output: "a.out" +// CHECK-MULTIARCH-BINDINGS: # "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.dSYM" + +// Check output name derivation. +// +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \ +// RUN: -o foo %s -g 2> %t +// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s +// +// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Link", inputs: [{{.*}}], output: "foo" +// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["foo"], output: "foo.dSYM" diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 76ddaa8732..8bee7f213c 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -35,10 +35,6 @@ // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO -l FOO 2> %t.log // RUN: grep '".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp".* "-filelist" "FOO" "-lFOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log -// Don't run dsymutil on a fat build of an executable. -// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log -// RUN: grep dsymutil %t.log | count 0 - // Check linker changes that came with new linkedit format. // RUN: touch %t.o // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log |