Add macos sdk / min version to pass to the linker.

This commit is contained in:
Christoffer Lerno
2022-12-29 01:06:35 +01:00
parent 90f5c24d4c
commit f122d290f1
9 changed files with 45 additions and 3 deletions

View File

@@ -689,6 +689,18 @@ static void parse_option(BuildOptions *options)
options->win.crt_linking = (WinCrtLinking)parse_multi_option(argopt, 3, wincrt_linking); options->win.crt_linking = (WinCrtLinking)parse_multi_option(argopt, 3, wincrt_linking);
return; return;
} }
if (match_longopt("macos-sdk-version"))
{
if (at_end() || next_is_opt()) error_exit("error: --macos-sdk-version needs a version.");
options->macos.sdk_version = next_arg();
return;
}
if (match_longopt("macos-min-version"))
{
if (at_end() || next_is_opt()) error_exit("error: --macos-min-version needs a version.");
options->macos.min_version = next_arg();
return;
}
if (match_longopt("build-dir")) if (match_longopt("build-dir"))
{ {
if (at_end() || next_is_opt()) error_exit("error: --build-dir needs a directory."); if (at_end() || next_is_opt()) error_exit("error: --build-dir needs a directory.");

View File

@@ -242,6 +242,8 @@ typedef struct BuildOptions_
} win; } win;
struct { struct {
const char *sdk; const char *sdk;
const char *min_version;
const char *sdk_version;
} macos; } macos;
int build_threads; int build_threads;
const char** files; const char** files;
@@ -379,6 +381,8 @@ typedef struct
struct struct
{ {
const char *sdk; const char *sdk;
const char *min_version;
const char *sdk_version;
} macos; } macos;
struct struct
{ {

View File

@@ -228,6 +228,8 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
target->testing = options->testing; target->testing = options->testing;
if (options->macos.sdk) target->macos.sdk = options->macos.sdk; if (options->macos.sdk) target->macos.sdk = options->macos.sdk;
if (options->win.sdk) target->win.sdk = options->win.sdk; if (options->win.sdk) target->win.sdk = options->win.sdk;
if (options->macos.min_version) target->macos.min_version = options->macos.min_version;
if (options->macos.sdk_version) target->macos.sdk_version = options->macos.sdk_version;
if (options->win.crt_linking != WIN_CRT_DEFAULT) target->win.crt_linking = options->win.crt_linking; if (options->win.crt_linking != WIN_CRT_DEFAULT) target->win.crt_linking = options->win.crt_linking;
if (options->x86_vector_capability != X86VECTOR_DEFAULT) if (options->x86_vector_capability != X86VECTOR_DEFAULT)
{ {

View File

@@ -327,6 +327,12 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg
// macossdk // macossdk
target->macos.sdk = get_valid_string(json, "macossdk", type, false); target->macos.sdk = get_valid_string(json, "macossdk", type, false);
// macos-min-version
target->macos.min_version = get_valid_string(json, "macos-min-version", type, false);
// macos-sdk-version
target->macos.sdk_version = get_valid_string(json, "macos-sdk-version", type, false);
// version // version
const char *version = get_valid_string(json, "version", type, false); const char *version = get_valid_string(json, "version", type, false);
if (version) target->version = version; if (version) target->version = version;

View File

@@ -585,6 +585,7 @@ typedef enum
TOKEN_CT_FOR, // $for TOKEN_CT_FOR, // $for
TOKEN_CT_FOREACH, // $foreach TOKEN_CT_FOREACH, // $foreach
TOKEN_CT_IF, // $if TOKEN_CT_IF, // $if
TOKEN_CT_INCLUDE, // $include
TOKEN_CT_NAMEOF, // $nameof TOKEN_CT_NAMEOF, // $nameof
TOKEN_CT_OFFSETOF, // $offsetof TOKEN_CT_OFFSETOF, // $offsetof
TOKEN_CT_QNAMEOF, // $qnameof TOKEN_CT_QNAMEOF, // $qnameof

View File

@@ -301,8 +301,22 @@ static void linker_setup_macos(const char ***args_ref, LinkerType linker_type)
if (is_pie(platform_target.reloc_model)) add_arg("-pie"); if (is_pie(platform_target.reloc_model)) add_arg("-pie");
add_arg("-platform_version"); add_arg("-platform_version");
add_arg("macos"); add_arg("macos");
add_arg(str_printf("%d.%d.0", mac_sdk->macos_min_deploy_target.major, mac_sdk->macos_min_deploy_target.minor)); if (active_target.macos.min_version)
add_arg(str_printf("%d.%d", mac_sdk->macos_deploy_target.major, mac_sdk->macos_deploy_target.minor)); {
add_arg(active_target.macos.min_version);
}
else
{
add_arg(str_printf("%d.%d.0", mac_sdk->macos_min_deploy_target.major, mac_sdk->macos_min_deploy_target.minor));
}
if (active_target.macos.sdk_version)
{
add_arg(active_target.macos.sdk_version);
}
else
{
add_arg(str_printf("%d.%d", mac_sdk->macos_deploy_target.major, mac_sdk->macos_deploy_target.minor));
}
} }

View File

@@ -1315,6 +1315,7 @@ Ast *parse_stmt(ParseContext *c)
case TOKEN_CT_ENDFOREACH: case TOKEN_CT_ENDFOREACH:
case TOKEN_CT_VASPLAT: case TOKEN_CT_VASPLAT:
case TOKEN_IMPLIES: case TOKEN_IMPLIES:
case TOKEN_CT_INCLUDE:
SEMA_ERROR_HERE("Unexpected '%s' found when expecting a statement.", SEMA_ERROR_HERE("Unexpected '%s' found when expecting a statement.",
token_type_to_string(c->tok)); token_type_to_string(c->tok));
advance(c); advance(c);

View File

@@ -360,6 +360,8 @@ const char *token_type_to_string(TokenType type)
return "$extnameof"; return "$extnameof";
case TOKEN_CT_IF: case TOKEN_CT_IF:
return "$if"; return "$if";
case TOKEN_CT_INCLUDE:
return "$include";
case TOKEN_CT_VACOUNT: case TOKEN_CT_VACOUNT:
return "$vacount"; return "$vacount";
case TOKEN_CT_VATYPE: case TOKEN_CT_VATYPE:

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.3.126" #define COMPILER_VERSION "0.3.127"