dsanders created this revision. dsanders added reviewers: JDevlieghere, beanz, bogner. Herald added subscribers: cfe-commits, dang, mgorny. Herald added projects: clang, LLVM. dsanders requested review of this revision.
As part of this, a couple tweaks to --dsym-dir have been made. It now starts with a double dash since CMake is unable to detect it's availability otherwise. clang's that lack it ended up passing the check anyway because of the -d group accepting anything. Also added the --dsym-dir= variant as the behaviour of Joined surprised me by including the = in the value otherwise. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D85213 Files: clang/include/clang/Driver/Options.td clang/test/Driver/darwin-dsymutil.c llvm/cmake/modules/AddLLVM.cmake Index: llvm/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/cmake/modules/AddLLVM.cmake +++ 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 "$<TARGET_FILE_NAME:${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="$<TARGET_FILE:${name}>.${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 "$<TARGET_FILE_NAME:${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="$<TARGET_FILE:${name}>.${file_ext}" + -DTO="${output_path}" + -P ${LLVM_CMAKE_PATH}/MoveIfExists.cmake + ) + endif() endif() add_custom_command(TARGET ${name} POST_BUILD COMMAND ${strip_command} Index: clang/test/Driver/darwin-dsymutil.c =================================================================== --- clang/test/Driver/darwin-dsymutil.c +++ 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 // Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ 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<"<dir>">; +def dsym_dir_EQ : Joined<["--"], "dsym-dir=">, Alias<dsym_dir>; def dumpmachine : Flag<["-"], "dumpmachine">; def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>; def dumpversion : Flag<["-"], "dumpversion">;
Index: llvm/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/cmake/modules/AddLLVM.cmake +++ 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 "$<TARGET_FILE_NAME:${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="$<TARGET_FILE:${name}>.${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 "$<TARGET_FILE_NAME:${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="$<TARGET_FILE:${name}>.${file_ext}" + -DTO="${output_path}" + -P ${LLVM_CMAKE_PATH}/MoveIfExists.cmake + ) + endif() endif() add_custom_command(TARGET ${name} POST_BUILD COMMAND ${strip_command} Index: clang/test/Driver/darwin-dsymutil.c =================================================================== --- clang/test/Driver/darwin-dsymutil.c +++ 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 // Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ 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<"<dir>">; +def dsym_dir_EQ : Joined<["--"], "dsym-dir=">, Alias<dsym_dir>; def dumpmachine : Flag<["-"], "dumpmachine">; def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>; def dumpversion : Flag<["-"], "dumpversion">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits