diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -677,9 +677,10 @@ HelpText<"Filename to write DOT-formatted header dependencies to">; def module_dependency_dir : Separate<["-"], "module-dependency-dir">, Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">; -def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">, +def dsym_dir : Separate<["--"], "dsym-dir">, Flags<[DriverOption, RenderAsInput]>, HelpText<"Directory to output dSYM's (if any) to">, MetaVarName<"">; +def dsym_dir_EQ : Joined<["--"], "dsym-dir=">, Alias; def dumpmachine : Flag<["-"], "dumpmachine">; def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>; def dumpversion : Flag<["-"], "dumpversion">; diff --git a/clang/test/Driver/darwin-dsymutil.c b/clang/test/Driver/darwin-dsymutil.c --- a/clang/test/Driver/darwin-dsymutil.c +++ b/clang/test/Driver/darwin-dsymutil.c @@ -35,7 +35,7 @@ // RUN: -check-prefix=CHECK-OUTPUT-NAME < %t %s // // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \ -// RUN: -o bar/foo -dsym-dir external %s -g 2> %t +// RUN: -o bar/foo --dsym-dir external %s -g 2> %t // RUN: FileCheck -Doutfile=bar/foo -Ddsymfile=external/foo.dSYM \ // RUN: -check-prefix=CHECK-OUTPUT-NAME < %t %s // diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1981,21 +1981,29 @@ set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " ${empty_src}") if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) - # clang can currently only emit dSYM's to the same directory as the output - # binary. Workaround this by moving it after the build. - set(output_name "$.${file_ext}") - set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") - add_custom_command(TARGET ${name} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}" - # Remove any old versions if present - COMMAND ${CMAKE_COMMAND} -E rm "-rf" "${output_path}" - # Move the dSYM clang emitted next to the output binary where we want it - # to be. - COMMAND ${CMAKE_COMMAND} - -DFROM="$.${file_ext}" - -DTO="${output_path}" - -P ${LLVM_CMAKE_PATH}/MoveIfExists.cmake - ) + check_cxx_compiler_flag("--dsym-dir=foo" HAS_DSYM_DIR) + if (HAS_DSYM_DIR) + set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " --dsym-dir=${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}") + add_custom_command(TARGET ${name} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}") + else() + # clang can currently only emit dSYM's to the same directory as the output + # binary. Workaround this by moving it after the build. + set(output_name "$.${file_ext}") + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + add_custom_command(TARGET ${name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}" + # Remove any old versions if present + COMMAND ${CMAKE_COMMAND} -E rm "-rf" "${output_path}" + # Move the dSYM clang emitted next to the output binary where we want it + # to be. + COMMAND ${CMAKE_COMMAND} + -DFROM="$.${file_ext}" + -DTO="${output_path}" + -P ${LLVM_CMAKE_PATH}/MoveIfExists.cmake + ) + endif() endif() add_custom_command(TARGET ${name} POST_BUILD COMMAND ${strip_command}