Configurable Linux crt/crtbegin paths.

This commit is contained in:
Christoffer Lerno
2023-05-31 18:33:06 +02:00
committed by Christoffer Lerno
parent 4cf98dab93
commit b30d130d92
6 changed files with 37 additions and 2 deletions

View File

@@ -159,7 +159,11 @@ static void usage(void)
OUTPUT(" --wincrt=<option> - Windows CRT linking: none, static, dynamic (default).");
OUTPUT("");
OUTPUT(" --macossdk <dir> - Set the directory for the MacOS SDK for cross compilation.");
OUTPUT(" --macos-min-version <ver> - Set the minimum MacOS version to compile for.");
OUTPUT(" --macos-sdk-version <ver> - Set the MacOS SDK compiled for.");
OUTPUT("");
OUTPUT(" --linux-crt <dir> - Set the directory to use for finding crt1.o and related files.");
OUTPUT(" --linux-crtbegin <dir> - Set the directory to use for finding crtbegin.o and related files.");
}
@@ -807,6 +811,18 @@ static void parse_option(BuildOptions *options)
options->path = check_dir(next_arg());
return;
}
if (match_longopt("linux-crt"))
{
if (at_end() || next_is_opt()) error_exit("error: --linux-crt needs a directory.");
options->linuxpaths.crt = check_dir(next_arg());
return;
}
if (match_longopt("linux-crtbegin"))
{
if (at_end() || next_is_opt()) error_exit("error: --linux-crtbegin needs a directory.");
options->linuxpaths.crtbegin = check_dir(next_arg());
return;
}
if (match_longopt("safe"))
{
options->safe_mode = 1;

View File

@@ -297,6 +297,10 @@ typedef struct BuildOptions_
const char *min_version;
const char *sdk_version;
} macos;
struct {
const char *crt;
const char *crtbegin;
} linuxpaths;
int build_threads;
const char** libraries_to_fetch;
const char** files;
@@ -456,6 +460,11 @@ typedef struct
WinCrtLinking crt_linking;
bool use_win_subsystem;
} win;
struct
{
const char *crt;
const char *crtbegin;
} linuxpaths;
} BuildTarget;

View File

@@ -243,6 +243,8 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
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->linuxpaths.crt) target->linuxpaths.crt = options->linuxpaths.crt;
if (options->linuxpaths.crtbegin) target->linuxpaths.crtbegin = options->linuxpaths.crtbegin;
if (options->x86_vector_capability != X86VECTOR_DEFAULT)
{
target->feature.x86_vector_capability = options->x86_vector_capability;

View File

@@ -374,6 +374,12 @@ static void load_into_build_target(JSONObject *json, const char *type, BuildTarg
// macos-sdk-version
target->macos.sdk_version = get_valid_string(json, "macos-sdk-version", type, false);
// Linux crt
target->linuxpaths.crt = get_valid_string(json, "linux-crt", type, false);
// Linux crtbegin
target->linuxpaths.crtbegin = get_valid_string(json, "linux-crtbegin", type, false);
// version
const char *version = get_valid_string(json, "version", type, false);
if (version) target->version = version;

View File

@@ -340,6 +340,7 @@ static const char *find_freebsd_crt(void)
static const char *find_linux_crt(void)
{
if (active_target.linuxpaths.crt) return active_target.linuxpaths.crt;
#if PLATFORM_POSIX
glob_t globbuf;
if (!glob("/usr/lib/*/crt1.o", 0, NULL, &globbuf) && globbuf.gl_pathc)
@@ -362,6 +363,7 @@ static const char *find_linux_crt(void)
static const char *find_linux_crt_begin(void)
{
if (active_target.linuxpaths.crtbegin) return active_target.linuxpaths.crtbegin;
#if PLATFORM_POSIX
glob_t globbuf;
if (!glob("/usr/lib/gcc/*/*/crtbegin.o", 0, NULL, &globbuf) && globbuf.gl_pathc)

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.518"
#define COMPILER_VERSION "0.4.519"