[cfe-commits] [PATCH] [clang] add --supported-targets option for clang
Alex Rosenberg
alexr at leftfield.org
Fri Dec 21 16:52:31 PST 2012
The backend supports an "=help" choice to provide lists like this. Should we match that for consistency, e.g. -target=help ?
Sent from my iPad
On Dec 20, 2012, at 11:25 PM, Saleem Abdulrasool <compnerd at compnerd.org> wrote:
> Add a new driver-only option `--supported-targets` which enumerates the supported targets to stdout. This is an often requested feature, allowing for a quick inspection of supported target architectures supported by a particular build of clang.
>
> http://llvm-reviews.chandlerc.com/D233
>
> Files:
> include/clang/Driver/Options.td
> lib/Driver/Driver.cpp
>
> Index: include/clang/Driver/Options.td
> ===================================================================
> --- include/clang/Driver/Options.td
> +++ include/clang/Driver/Options.td
> @@ -1142,6 +1142,8 @@
> HelpText<"Serialize compiler diagnostics to a file">;
> // We give --version different semantics from -version.
> def _version : Flag<["--"], "version">, Flags<[CC1Option]>;
> +def _supported_targets : Flag<["--"], "supported-targets">,
> + Flags<[DriverOption]>, HelpText<"Display supported targets">;
> def _signed_char : Flag<["--"], "signed-char">, Alias<fsigned_char>;
> def _std : Separate<["--"], "std">, Alias<std_EQ>;
> def _stdlib : Separate<["--"], "stdlib">, Alias<stdlib_EQ>;
> Index: lib/Driver/Driver.cpp
> ===================================================================
> --- lib/Driver/Driver.cpp
> +++ lib/Driver/Driver.cpp
> @@ -27,9 +27,11 @@
> #include "llvm/ADT/StringSet.h"
> #include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/FileSystem.h"
> +#include "llvm/Support/Host.h"
> #include "llvm/Support/Path.h"
> #include "llvm/Support/PrettyStackTrace.h"
> #include "llvm/Support/Program.h"
> +#include "llvm/Support/TargetRegistry.h"
> #include "llvm/Support/raw_ostream.h"
> #include <map>
>
> @@ -628,6 +630,34 @@
> return false;
> }
>
> + if (C.getArgs().hasArg(options::OPT__supported_targets)) {
> + std::string CPU = llvm::sys::getHostCPUName();
> + llvm::raw_ostream &OS = llvm::outs();
> + llvm::TargetRegistry Registry;
> +
> + if (CPU == "generic")
> + CPU = "(unknown)";
> +
> + OS << getClangFullVersion() << " ("
> +#if defined(__OPTIMIZE__)
> + << "optimized"
> +#else
> + << "debug"
> +#endif
> +#if !defined(NDEBUG)
> + << "+asserts"
> +#endif
> + << ")\n"
> + << "Host CPU: " << CPU << "\n"
> + << "Default Target: " << llvm::sys::getDefaultTargetTriple() << "\n"
> + << "Supported Target Architectures:\n";
> + for (llvm::TargetRegistry::iterator TI = Registry.begin(),
> + TE = Registry.end(); TI != TE; ++TI)
> + OS << "\t" << TI->getName() << "\n";
> +
> + return false;
> + }
> +
> if (C.getArgs().hasArg(options::OPT_v) ||
> C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
> PrintVersion(C, llvm::errs());
> <D233.1.patch>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list