mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
add --linux-libc=host option and set default to host (#2636)
* added `--linux-libc=host` and set default to `default_linux` from `src/build/builder.c` * updated `resources/project_schema.json` for `linux-libc` host build option * Update how libc is set. --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
committed by
GitHub
parent
15662bd32f
commit
0685260454
@@ -204,9 +204,10 @@
|
|||||||
"description": "Set the libc to use for Linux.",
|
"description": "Set the libc to use for Linux.",
|
||||||
"enum": [
|
"enum": [
|
||||||
"gnu",
|
"gnu",
|
||||||
"musl"
|
"musl",
|
||||||
|
"host"
|
||||||
],
|
],
|
||||||
"default": "gnu"
|
"default": "host"
|
||||||
},
|
},
|
||||||
"x86cpu": {
|
"x86cpu": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ typedef enum
|
|||||||
LINUX_LIBC_NOT_SET = -1,
|
LINUX_LIBC_NOT_SET = -1,
|
||||||
LINUX_LIBC_GNU = 0,
|
LINUX_LIBC_GNU = 0,
|
||||||
LINUX_LIBC_MUSL = 1,
|
LINUX_LIBC_MUSL = 1,
|
||||||
|
LINUX_LIBC_HOST = 2,
|
||||||
} LinuxLibc;
|
} LinuxLibc;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@@ -897,7 +898,7 @@ static BuildTarget default_build_target = {
|
|||||||
.feature.panic_level = PANIC_NOT_SET,
|
.feature.panic_level = PANIC_NOT_SET,
|
||||||
.win.crt_linking = WIN_CRT_DEFAULT,
|
.win.crt_linking = WIN_CRT_DEFAULT,
|
||||||
.win.def = NULL,
|
.win.def = NULL,
|
||||||
.linuxpaths.libc = LINUX_LIBC_GNU,
|
.linuxpaths.libc = LINUX_LIBC_NOT_SET,
|
||||||
.switchrange_max_size = DEFAULT_SWITCHRANGE_MAX_SIZE,
|
.switchrange_max_size = DEFAULT_SWITCHRANGE_MAX_SIZE,
|
||||||
.switchjump_max_size = DEFAULT_SWITCH_JUMP_MAX_SIZE,
|
.switchjump_max_size = DEFAULT_SWITCH_JUMP_MAX_SIZE,
|
||||||
.quiet = false,
|
.quiet = false,
|
||||||
@@ -913,6 +914,7 @@ extern const int manifest_default_keys_count;
|
|||||||
extern const char *manifest_target_keys[][2];
|
extern const char *manifest_target_keys[][2];
|
||||||
extern const int manifest_target_keys_count;
|
extern const int manifest_target_keys_count;
|
||||||
extern const char *arch_os_target[ARCH_OS_TARGET_LAST + 1];
|
extern const char *arch_os_target[ARCH_OS_TARGET_LAST + 1];
|
||||||
|
extern LinuxLibc default_libc;
|
||||||
|
|
||||||
BuildOptions parse_arguments(int argc, const char *argv[]);
|
BuildOptions parse_arguments(int argc, const char *argv[]);
|
||||||
ArchOsTarget arch_os_target_from_string(const char *target);
|
ArchOsTarget arch_os_target_from_string(const char *target);
|
||||||
|
|||||||
@@ -50,9 +50,10 @@ static const char *optsizes[3] = {
|
|||||||
[SIZE_OPTIMIZATION_TINY] = "tiny",
|
[SIZE_OPTIMIZATION_TINY] = "tiny",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *linuxlibc[2] = {
|
static const char *linuxlibc[3] = {
|
||||||
[LINUX_LIBC_GNU] = "gnu",
|
[LINUX_LIBC_GNU] = "gnu",
|
||||||
[LINUX_LIBC_MUSL] = "musl",
|
[LINUX_LIBC_MUSL] = "musl",
|
||||||
|
[LINUX_LIBC_HOST] = "host",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *linker_kind[3] = {
|
static const char *linker_kind[3] = {
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ static void usage(bool full)
|
|||||||
print_opt("--macos-min-version <ver>", "Set the minimum MacOS version to compile for.");
|
print_opt("--macos-min-version <ver>", "Set the minimum MacOS version to compile for.");
|
||||||
print_opt("--macos-sdk-version <ver>", "Set the MacOS SDK compiled for.");
|
print_opt("--macos-sdk-version <ver>", "Set the MacOS SDK compiled for.");
|
||||||
PRINTF("");
|
PRINTF("");
|
||||||
print_opt("--linux-libc=<gnu|musl>", "Set the libc to use on Linux, defaults to gnu.");
|
print_opt("--linux-libc=<host|gnu|musl>", "Set the libc to use on Linux, defaults to host.");
|
||||||
print_opt("--linux-crt <dir>", "Set the directory to use for finding crt1.o and related files.");
|
print_opt("--linux-crt <dir>", "Set the directory to use for finding crt1.o and related files.");
|
||||||
print_opt("--linux-crtbegin <dir>", "Set the directory to use for finding crtbegin.o and related files.");
|
print_opt("--linux-crtbegin <dir>", "Set the directory to use for finding crtbegin.o and related files.");
|
||||||
PRINTF("");
|
PRINTF("");
|
||||||
|
|||||||
@@ -540,6 +540,7 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
|
|||||||
target->emit_asm = options->emit_asm;
|
target->emit_asm = options->emit_asm;
|
||||||
target->print_stats = options->verbosity_level >= 2;
|
target->print_stats = options->verbosity_level >= 2;
|
||||||
|
|
||||||
|
if (target->linuxpaths.libc == LINUX_LIBC_NOT_SET) target->linuxpaths.libc = default_libc;
|
||||||
target->benchmarking = options->benchmarking;
|
target->benchmarking = options->benchmarking;
|
||||||
target->testing = options->testing;
|
target->testing = options->testing;
|
||||||
target->silent = options->verbosity_level < 0;
|
target->silent = options->verbosity_level < 0;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const char *project_default_keys[][2] = {
|
|||||||
{"linker-search-paths", "Linker search paths."},
|
{"linker-search-paths", "Linker search paths."},
|
||||||
{"linux-crt", "Set the directory to use for finding crt1.o and related files."},
|
{"linux-crt", "Set the directory to use for finding crt1.o and related files."},
|
||||||
{"linux-crtbegin", "Set the directory to use for finding crtbegin.o and related files."},
|
{"linux-crtbegin", "Set the directory to use for finding crtbegin.o and related files."},
|
||||||
{"linux-libc", "Set the libc to use for Linux. Valid options are 'gnu' and 'musl', default is 'gnu'"},
|
{"linux-libc", "Set the libc to use for Linux. Valid options are 'host', 'gnu' and 'musl', default is 'host'"},
|
||||||
{"loop-vectorize", "Force enable/disable loop auto-vectorization."},
|
{"loop-vectorize", "Force enable/disable loop auto-vectorization."},
|
||||||
{"macos-min-version", "Set the minimum MacOS version to compile for."},
|
{"macos-min-version", "Set the minimum MacOS version to compile for."},
|
||||||
{"macos-sdk-version", "Set the MacOS SDK compiled for." },
|
{"macos-sdk-version", "Set the MacOS SDK compiled for." },
|
||||||
@@ -118,7 +118,7 @@ const char* project_target_keys[][2] = {
|
|||||||
{"linker-search-paths-override", "Linker search paths for this target, overriding global settings."},
|
{"linker-search-paths-override", "Linker search paths for this target, overriding global settings."},
|
||||||
{"linux-crt", "Set the directory to use for finding crt1.o and related files."},
|
{"linux-crt", "Set the directory to use for finding crt1.o and related files."},
|
||||||
{"linux-crtbegin", "Set the directory to use for finding crtbegin.o and related files."},
|
{"linux-crtbegin", "Set the directory to use for finding crtbegin.o and related files."},
|
||||||
{"linux-libc", "Set the libc to use for Linux. Valid options are 'gnu' and 'musl', default is 'gnu'"},
|
{"linux-libc", "Set the libc to use for Linux. Valid options are 'host', 'gnu' and 'musl', default is 'host'"},
|
||||||
{"loop-vectorize", "Force enable/disable loop auto-vectorization."},
|
{"loop-vectorize", "Force enable/disable loop auto-vectorization."},
|
||||||
{"macos-min-version", "Set the minimum MacOS version to compile for."},
|
{"macos-min-version", "Set the minimum MacOS version to compile for."},
|
||||||
{"macos-sdk-version", "Set the MacOS SDK compiled for." },
|
{"macos-sdk-version", "Set the MacOS SDK compiled for." },
|
||||||
@@ -488,7 +488,7 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json,
|
|||||||
target->linuxpaths.crtbegin = get_string(context, json, "linux-crtbegin", target->linuxpaths.crtbegin);
|
target->linuxpaths.crtbegin = get_string(context, json, "linux-crtbegin", target->linuxpaths.crtbegin);
|
||||||
|
|
||||||
// linux-libc
|
// linux-libc
|
||||||
LinuxLibc linux_libc = GET_SETTING(LinuxLibc, "linux-libc", linuxlibc, "`gnu` or `musl`.");
|
LinuxLibc linux_libc = GET_SETTING(LinuxLibc, "linux-libc", linuxlibc, "`gnu`, `musl` or `host`.");
|
||||||
if (linux_libc > -1) target->linuxpaths.libc = linux_libc;
|
if (linux_libc > -1) target->linuxpaths.libc = linux_libc;
|
||||||
|
|
||||||
// version
|
// version
|
||||||
@@ -503,7 +503,7 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json,
|
|||||||
// testfn
|
// testfn
|
||||||
target->testfn = get_string(context, json, "testfn", target->testfn);
|
target->testfn = get_string(context, json, "testfn", target->testfn);
|
||||||
|
|
||||||
// testfn
|
// benchfn
|
||||||
target->benchfn = get_string(context, json, "benchfn", target->benchfn);
|
target->benchfn = get_string(context, json, "benchfn", target->benchfn);
|
||||||
|
|
||||||
// link-libc
|
// link-libc
|
||||||
|
|||||||
@@ -402,12 +402,10 @@ static const char *find_linux_crt_begin(void)
|
|||||||
|
|
||||||
static const char *find_linux_ld(void)
|
static const char *find_linux_ld(void)
|
||||||
{
|
{
|
||||||
INFO_LOG("Environment Type ID: %d", compiler.platform.environment_type);
|
if (compiler.platform.environment_type == ENV_TYPE_ANDROID) return "--dynamic-linker=/system/ld-android.so";
|
||||||
switch (compiler.platform.environment_type)
|
switch (compiler.build.linuxpaths.libc)
|
||||||
{
|
{
|
||||||
case ENV_TYPE_MUSL:
|
case LINUX_LIBC_MUSL:
|
||||||
case ENV_TYPE_MUSLEABI:
|
|
||||||
case ENV_TYPE_MUSLEABIHF:
|
|
||||||
switch (compiler.platform.arch)
|
switch (compiler.platform.arch)
|
||||||
{
|
{
|
||||||
case ARCH_TYPE_ARM: return "--dynamic-linker=/lib/ld-musl-arm.so.1";
|
case ARCH_TYPE_ARM: return "--dynamic-linker=/lib/ld-musl-arm.so.1";
|
||||||
@@ -428,10 +426,9 @@ static const char *find_linux_ld(void)
|
|||||||
}
|
}
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
break;
|
break;
|
||||||
case ENV_TYPE_ANDROID:
|
case LINUX_LIBC_GNU:
|
||||||
return "--dynamic-linker=/system/ld-android.so";
|
switch (compiler.platform.arch)
|
||||||
default:
|
{
|
||||||
switch (compiler.platform.arch) {
|
|
||||||
case ARCH_TYPE_ARM: return "--dynamic-linker=/lib/ld-linux.so.3";
|
case ARCH_TYPE_ARM: return "--dynamic-linker=/lib/ld-linux.so.3";
|
||||||
case ARCH_TYPE_AARCH64: return "--dynamic-linker=/lib/ld-linux-aarch64.so.1";
|
case ARCH_TYPE_AARCH64: return "--dynamic-linker=/lib/ld-linux-aarch64.so.1";
|
||||||
case ARCH_TYPE_MIPS: return "--dynamic-linker=/lib/ld-linux-mipsn8.so.1";
|
case ARCH_TYPE_MIPS: return "--dynamic-linker=/lib/ld-linux-mipsn8.so.1";
|
||||||
@@ -443,11 +440,12 @@ static const char *find_linux_ld(void)
|
|||||||
case ARCH_TYPE_SPARCV9: return "--dynamic-linker=/lib/ld-linux.so.2";
|
case ARCH_TYPE_SPARCV9: return "--dynamic-linker=/lib/ld-linux.so.2";
|
||||||
case ARCH_TYPE_X86: return "--dynamic-linker=/lib64/ld-linux.so.2";
|
case ARCH_TYPE_X86: return "--dynamic-linker=/lib64/ld-linux.so.2";
|
||||||
case ARCH_TYPE_X86_64: return "--dynamic-linker=/lib64/ld-linux-x86-64.so.2";
|
case ARCH_TYPE_X86_64: return "--dynamic-linker=/lib64/ld-linux-x86-64.so.2";
|
||||||
default: return "--dynamic-linkrt=/lib/ld-linux-unknown.so.2"; // another placeholder until we have all of them
|
default: return "--dynamic-linker=/lib/ld-linux-unknown.so.2"; // another placeholder until we have all of them
|
||||||
}
|
}
|
||||||
|
FALLTHROUGH;
|
||||||
|
default:
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
}
|
}
|
||||||
UNREACHABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void linker_setup_linux(const char ***args_ref, Linker linker_type, bool is_dylib)
|
static void linker_setup_linux(const char ***args_ref, Linker linker_type, bool is_dylib)
|
||||||
|
|||||||
Reference in New Issue
Block a user