bool options_parse_early_target(options_state_t *s) { const char *full_option = s->argv[s->i]; if (full_option[0] != '-') return false; const char *option = &full_option[1]; const char *arg; if (simple_arg("pthread", s)) { /* set flags for the preprocessor */ driver_add_flag(&cppflags_obst, "-D_REENTRANT"); /* set flags for the linker */ driver_add_flag(&ldflags_obst, "-lpthread"); } else if ((arg = spaced_arg("target", s)) != NULL) { if (!parse_target_triple(arg)) s->argument_errors = true; /* remove argument so we do not parse it again in later phases */ s->argv[s->i-1] = NULL; } else if ((arg = equals_arg("-target", s)) != NULL) { if (!parse_target_triple(arg)) s->argument_errors = true; } else if (simple_arg("m64", s) || simple_arg("m32", s) || simple_arg("m16", s)) { driver_add_flag(&cppflags_obst, full_option); driver_add_flag(&asflags_obst, full_option); driver_add_flag(&ldflags_obst, full_option); target_size_override = atoi(option+1); } else { bool truth_value; const char *fopt; if ((fopt = f_no_arg(&truth_value, s)) != NULL) { if (f_yesno_arg("-fprofile-generate", s)) { profile_generate = truth_value; } else if (f_yesno_arg("-fprofile-use", s)) { profile_use = truth_value; } else { return false; } } else { return false; } } /* Remove argument so we do not parse it again in later phases */ return true; }
bool options_parse_c_dialect(options_state_t *s) { const char *full_option = s->argv[s->i]; if (full_option[0] != '-') return false; bool truth_value; const char *fopt; if ((fopt = f_no_arg(&truth_value, s)) != NULL) { if (f_yesno_arg("-fshort-wchar", s)) { set_wchar = true; short_wchar = truth_value; } else if (f_yesno_arg("-fsigned-char", s)) { unsigned_char = !truth_value; } else if (f_yesno_arg("-funsigned-char", s)) { unsigned_char = truth_value; } else if (f_yesno_arg("-ffreestanding", s)) { dialect.freestanding = truth_value; dialect.no_builtins = truth_value; } else if (f_yesno_arg("-fhosted", s)) { dialect.freestanding = !truth_value; dialect.no_builtins = !truth_value; } else if (f_yesno_arg("-fbuiltin", s)) { dialect.no_builtins = !truth_value; } else { return false; } } else { return false; } return true; }
bool options_parse_c_dialect(options_state_t *s) { const char *full_option = s->argv[s->i]; if (full_option[0] != '-') return false; bool truth_value; const char *fopt; if ((fopt = f_no_arg(&truth_value, s)) != NULL) { if (f_yesno_arg("-fshort-wchar", s)) { dialect.wchar_atomic_kind = truth_value ? ATOMIC_TYPE_USHORT : ATOMIC_TYPE_INT; } else if (f_yesno_arg("-fsigned-char", s)) { dialect.char_is_signed = truth_value; } else if (f_yesno_arg("-funsigned-char", s)) { dialect.char_is_signed = !truth_value; } else if (f_yesno_arg("-ffreestanding", s)) { dialect.freestanding = truth_value; dialect.no_builtins = truth_value; } else if (f_yesno_arg("-fhosted", s)) { dialect.freestanding = !truth_value; dialect.no_builtins = !truth_value; } else if (f_yesno_arg("-fbuiltin", s)) { dialect.no_builtins = !truth_value; } else { return false; } } else { return false; } return true; }
bool options_parse_diagnostics(options_state_t *s) { const char *full_option = s->argv[s->i]; if (full_option[0] != '-') return false; const char *option = &full_option[1]; if (simple_arg("w", s)) { driver_add_flag(&cppflags_obst, "-w"); disable_all_warnings(); } else if (simple_arg("pedantic", s)) { dialect.strict = true; set_warning_opt("pedantic"); set_warning_opt("error=return-type"); } else if (simple_arg("pedantic-errors", s)) { dialect.strict = true; set_warning_opt("error=pedantic"); set_warning_opt("error=return-type"); } else if (option[0] == 'W') { if (simple_arg("Winit-self", s)) { /* ignored (same as gcc does) */ } else if (simple_arg("Wformat-y2k", s) || simple_arg("Wformat-security", s) || simple_arg("Wold-style-declaration", s) || simple_arg("Wtype-limits", s)) { /* ignore (gcc compatibility) */ } else if (option[1] != '\0' && option[2] == ',') { /* this is not a warning option */ return false; } else { set_warning_opt(&option[1]); } } else if (option[0] == 'f') { const char *arg; if ((arg = equals_arg("fmessage-length", s)) != NULL) { (void)arg; /* not supported yet */ } else { bool truth_value; const char *fopt; if ((fopt = f_no_arg(&truth_value, s)) != NULL) { if (f_yesno_arg("-fdiagnostics-show-option", s)) { diagnostics_show_option = truth_value; } else if (f_yesno_arg("-fshow-column", s)) { show_column = truth_value; } else if (f_yesno_arg("-fcolor-diagnostics", s) || f_yesno_arg("-fdiagnostics-color", s)) { diagnostic_enable_color(truth_value ? (colorterm != 0 ? colorterm : 8) : 0); } else { return false; } } else { return false; } } } else { return false; } return true; }
bool options_parse_codegen(options_state_t *s) { const char *full_option = s->argv[s->i]; if (full_option[0] != '-') return false; const char *option = &full_option[1]; const char *arg; if ((arg = equals_arg("falign-loops", s)) != NULL || (arg = equals_arg("falign-jumps", s)) != NULL || (arg = equals_arg("falign-functions", s)) != NULL) { warningf(WARN_COMPAT_OPTION, NULL, "ignoring gcc option '%s'", full_option); } else if ((arg = equals_arg("fvisibility", s)) != NULL) { elf_visibility_t visibility = get_elf_visibility_from_string(arg); if (visibility == ELF_VISIBILITY_ERROR) { errorf(NULL, "invalid visibility '%s' specified", arg); s->argument_errors = true; } else { set_default_visibility(visibility); } } else if (simple_arg("-unroll-loops", s)) { /* ignore (gcc compatibility) */ } else if (simple_arg("fexcess-precision=standard", s)) { /* ignore (gcc compatibility) we always adhere to the C99 standard * anyway in this respect */ } else if (accept_prefix(s, "-g", false, &arg)) { if (streq(arg, "0")) { set_target_option("debug=none"); set_target_option("ia32-optcc=true"); } else { set_target_option("debug=frameinfo"); set_target_option("ia32-optcc=false"); } } else if (accept_prefix(s, "-m", false, &arg)) { arg = &option[1]; /* remember option for backend */ assert(obstack_object_size(&codegenflags_obst) == 0); obstack_blank(&codegenflags_obst, sizeof(codegen_option_t)); size_t len = strlen(arg); obstack_grow(&codegenflags_obst, arg, len); codegen_option_t *const cg_option = obstack_nul_finish(&codegenflags_obst); cg_option->next = NULL; *codegen_options_anchor = cg_option; codegen_options_anchor = &cg_option->next; } else { bool truth_value; const char *fopt; if ((fopt = f_no_arg(&truth_value, s)) != NULL) { if (f_yesno_arg("-ffast-math", s)) { ir_allow_imprecise_float_transforms(truth_value); } else if (f_yesno_arg("-fomit-frame-pointer", s)) { target.set_use_frame_pointer = true; target.use_frame_pointer = !truth_value; } else if (f_yesno_arg("-fstrength-reduce", s)) { /* does nothing, for gcc compatibility (even gcc does * nothing for this switch anymore) */ } else if (!truth_value && (f_yesno_arg("-fasynchronous-unwind-tables", s) || f_yesno_arg("-funwind-tables", s))) { /* do nothing: a gcc feature which we do not support * anyway was deactivated */ } else if (f_yesno_arg("-frounding-math", s)) { /* ignore for gcc compatibility: we don't have any unsafe * optimizations in that area */ } else if (f_yesno_arg("-fverbose-asm", s)) { set_target_option(truth_value ? "verboseasm" : "verboseasm=no"); } else if (f_yesno_arg("-fPIC", s)) { target.pic = truth_value; target.set_pic = true; } else if (f_yesno_arg("-fpic", s)) { target.pic = truth_value; target.set_pic = true; /* cparser has no concept of -fPIC vs. -fpic yet */ if (truth_value) warningf(WARN_COMPAT_OPTION, NULL, "-fpic unsupported, using -fPIC instead"); } else if (f_yesno_arg("-fplt", s)) { target.pic_noplt = !truth_value; target.set_noplt = true; } else if (f_yesno_arg("-fjump-tables", s) || f_yesno_arg("-fexpensive-optimizations", s) || f_yesno_arg("-fcommon", s) || f_yesno_arg("-foptimize-sibling-calls", s) || f_yesno_arg("-falign-loops", s) || f_yesno_arg("-falign-jumps", s) || f_yesno_arg("-falign-functions", s) || f_yesno_arg("-fstack-protector", s) || f_yesno_arg("-fstack-protector-all", s)) { /* better warn the user for these as he might have expected * that something happens */ warningf(WARN_COMPAT_OPTION, NULL, "ignoring gcc option '-f%s'", fopt); } else if (firm_option(&option[1])) { /* parsed a firm option */ } else { return false; } } else { return false; } } return true; }