macOS: if used, -arch option must match target

This commit is contained in:
Christian Jullien 2021-08-02 14:21:28 +02:00
parent a951dc026f
commit e449db5f1d

View File

@ -1558,9 +1558,9 @@ static const TCCOption tcc_options[] = {
#ifdef TCC_TARGET_PE #ifdef TCC_TARGET_PE
{ "impdef", TCC_OPTION_impdef, 0}, { "impdef", TCC_OPTION_impdef, 0},
#endif #endif
//#ifdef TCC_TARGET_MACHO #ifdef TCC_TARGET_MACHO
{ "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG }, { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },
//#endif #endif
{ "C", TCC_OPTION_C, 0}, { "C", TCC_OPTION_C, 0},
{ NULL, 0, 0 }, { NULL, 0, 0 },
}; };
@ -1991,12 +1991,25 @@ reparse:
tcc_error("cannot parse %s here", r); tcc_error("cannot parse %s here", r);
tool = x; tool = x;
break; break;
#if defined(TCC_TARGET_MACHO)
case TCC_OPTION_arch:
#if defined(TCC_TARGET_X86_64)
if (strcmp(optarg, "x86_64") == 0)
break; /* Ok, arch matches target */
#endif
#if defined(TCC_TARGET_ARM64)
if (strcmp(optarg, "arm64") == 0)
break; /* Ok, arch matches target */
#endif
tcc_error("this compiler does not support %s", optarg);
/* ignored */
break;
#endif
case TCC_OPTION_traditional: case TCC_OPTION_traditional:
case TCC_OPTION_pedantic: case TCC_OPTION_pedantic:
case TCC_OPTION_pipe: case TCC_OPTION_pipe:
case TCC_OPTION_s: case TCC_OPTION_s:
case TCC_OPTION_C: case TCC_OPTION_C:
case TCC_OPTION_arch:
/* ignored */ /* ignored */
break; break;
default: default: