aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLayne Gustafson <lgustaf1@binghamton.edu>2019-12-17 09:45:30 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-01-19 20:53:18 -0500
commit5bc4690d85bfaade48393c182b2b3aa207ebebc7 (patch)
tree5ab2de0fba2b7b20601d99a1effb9da69f8db750 /src
parent21908e100e42c5630e1e4253167496fb76238670 (diff)
downloadzig-5bc4690d85bfaade48393c182b2b3aa207ebebc7.tar.gz
zig-5bc4690d85bfaade48393c182b2b3aa207ebebc7.zip
Make targets cmd able to list CPUs and features
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp33
-rw-r--r--src/userland.cpp3
-rw-r--r--src/userland.h6
3 files changed, 40 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d89ac352a5..5c0a0b23fc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -129,6 +129,11 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
" --test-name-prefix [text] add prefix to all tests\n"
" --test-cmd [arg] specify test execution command one arg at a time\n"
" --test-cmd-bin appends test binary path to test cmd args\n"
+ "\n"
+ "Targets Options:\n"
+ " --list-features [arch] list available features for the given architecture\n"
+ " --list-cpus [arch] list available cpus for the given architecture\n"
+ " --show-subfeatures list subfeatures for each entry from --list-features or --list-cpus\n"
, arg0);
return return_code;
}
@@ -529,6 +534,10 @@ int main(int argc, char **argv) {
WantCSanitize want_sanitize_c = WantCSanitizeAuto;
bool function_sections = false;
+ const char *targets_list_features_arch = nullptr;
+ const char *targets_list_cpus_arch = nullptr;
+ bool targets_show_subfeatures = false;
+
ZigList<const char *> llvm_argv = {0};
llvm_argv.append("zig (LLVM option parsing)");
@@ -779,6 +788,8 @@ int main(int argc, char **argv) {
cur_pkg = cur_pkg->parent;
} else if (strcmp(arg, "-ffunction-sections") == 0) {
function_sections = true;
+ } else if (strcmp(arg, "--show-subfeatures") == 0) {
+ targets_show_subfeatures = true;
} else if (i + 1 >= argc) {
fprintf(stderr, "Expected another argument after %s\n", arg);
return print_error_usage(arg0);
@@ -936,7 +947,11 @@ int main(int argc, char **argv) {
, argv[i]);
return EXIT_FAILURE;
}
- } else {
+ } else if (strcmp(arg, "--list-features") == 0) {
+ targets_list_features_arch = argv[i];
+ } else if (strcmp(arg, "--list-cpus") == 0) {
+ targets_list_cpus_arch = argv[i];
+ }else {
fprintf(stderr, "Invalid argument: %s\n", arg);
return print_error_usage(arg0);
}
@@ -1413,7 +1428,21 @@ int main(int argc, char **argv) {
return main_exit(root_progress_node, EXIT_SUCCESS);
}
case CmdTargets:
- return print_target_list(stdout);
+ if (targets_list_features_arch != nullptr) {
+ stage2_list_features_for_arch(
+ targets_list_features_arch,
+ strlen(targets_list_features_arch),
+ targets_show_subfeatures);
+ return 0;
+ } else if (targets_list_cpus_arch != nullptr) {
+ stage2_list_cpus_for_arch(
+ targets_list_cpus_arch,
+ strlen(targets_list_cpus_arch),
+ targets_show_subfeatures);
+ return 0;
+ } else {
+ return print_target_list(stdout);
+ }
case CmdNone:
return print_full_usage(arg0, stderr, EXIT_FAILURE);
}
diff --git a/src/userland.cpp b/src/userland.cpp
index 263ef0cbc3..87ef99c03a 100644
--- a/src/userland.cpp
+++ b/src/userland.cpp
@@ -88,3 +88,6 @@ void stage2_progress_end(Stage2ProgressNode *node) {}
void stage2_progress_complete_one(Stage2ProgressNode *node) {}
void stage2_progress_disable_tty(Stage2Progress *progress) {}
void stage2_progress_update_node(Stage2ProgressNode *node, size_t completed_count, size_t estimated_total_items){}
+
+void stage2_list_features_for_arch(const char *arch_name_ptr, size_t arch_name_len, bool show_subfeatures) {}
+void stage2_list_cpus_for_arch(const char *arch_name_ptr, size_t arch_name_len, bool show_subfeatures) {}
diff --git a/src/userland.h b/src/userland.h
index fe3f072ae5..c85684cb36 100644
--- a/src/userland.h
+++ b/src/userland.h
@@ -174,4 +174,10 @@ ZIG_EXTERN_C void stage2_progress_complete_one(Stage2ProgressNode *node);
ZIG_EXTERN_C void stage2_progress_update_node(Stage2ProgressNode *node,
size_t completed_count, size_t estimated_total_items);
+// ABI warning
+ZIG_EXTERN_C void stage2_list_features_for_arch(const char *arch_name_ptr, size_t arch_name_len, bool show_subfeatures);
+
+// ABI warning
+ZIG_EXTERN_C void stage2_list_cpus_for_arch(const char *arch_name_ptr, size_t arch_name_len, bool show_subfeatures);
+
#endif