fix: multiple definition of triple elements

This commit is contained in:
Sven Vogel 2024-09-19 22:54:12 +02:00
parent 6b5f80799e
commit caeda1224c
2 changed files with 63 additions and 27 deletions

View File

@ -15,16 +15,47 @@ static GHashTable* args = NULL;
static Dependency *new_dependency(); static Dependency *new_dependency();
const char* ARCH_X86_64 = "x86_64";
const char* ARCH_I386 = "i386";
const char* ARCH_ARM = "arm";
const char* ARCH_THUMB = "thumb";
const char* ARCH_MIPS = "mips";
const char* SUB_V5 = "v5";
const char* SUB_V6M = "v6m";
const char* SUB_V7A = "v7a";
const char* SUB_V7M = "v7m";
const char* VENDOR_PC = "pc";
const char* VENDOR_APPLE = "apple";
const char* VENDOR_NVIDIA = "nvidia";
const char* VENDOR_IBM = "ibm";
const char* SYS_NONE = "none";
const char* SYS_LINUX = "linux";
const char* SYS_WIN32 = "win32";
const char* SYS_DARWIN = "darwin";
const char* SYS_CUDA = "cuda";
const char* ENV_EABI = "eabi";
const char* ENV_GNU = "gnu";
const char* ENV_ANDROID = "android";
const char* ENV_MACHO = "macho";
const char* ENV_ELF = "elf";
const char* find_string(const char* haystack, const char** options, size_t size) const char* find_string(const char* haystack, const char** options, size_t size)
{ {
const static char* found = NULL; const static char* found = NULL;
for (size_t i = 0; i < size/sizeof(const char*); i++) if (haystack != NULL)
{ {
if (strstr(haystack, options[i])) for (size_t i = 0; i < size/sizeof(const char*); i++)
{ {
found = options[i]; if (strstr(haystack, options[i]))
break; {
found = options[i];
break;
}
} }
} }
@ -191,6 +222,7 @@ TargetConfig* default_target_config() {
config->lld_fatal_warnings = FALSE; config->lld_fatal_warnings = FALSE;
config->gsc_fatal_warnings = FALSE; config->gsc_fatal_warnings = FALSE;
config->import_paths = mem_new_g_array(MemoryNamespaceOpt, sizeof(char*)); config->import_paths = mem_new_g_array(MemoryNamespaceOpt, sizeof(char*));
config->triple = NULL;
return config; return config;
} }

View File

@ -78,6 +78,10 @@ typedef struct TargetConfig_t {
char *archive_directory; char *archive_directory;
// binary driver for executable generation // binary driver for executable generation
char *driver; char *driver;
// system to compile code for
// LLVM triple, see: https://clang.llvm.org/docs/CrossCompilation.html#target-triple
// in case this is empty this will be the native platform
char* triple;
// mode of compilation // mode of compilation
TargetCompilationMode mode; TargetCompilationMode mode;
// number between 1 and 3 // number between 1 and 3
@ -126,33 +130,33 @@ typedef struct Option_t {
bool is_opt; bool is_opt;
} Option; } Option;
const char* ARCH_X86_64 = "x86_64"; extern const char* ARCH_X86_64;
const char* ARCH_I386 = "i386"; extern const char* ARCH_I386;
const char* ARCH_ARM = "arm"; extern const char* ARCH_ARM;
const char* ARCH_THUMB = "thumb"; extern const char* ARCH_THUMB;
const char* ARCH_MIPS = "mips"; extern const char* ARCH_MIPS;
const char* SUB_V5 = "v5"; extern const char* SUB_V5;
const char* SUB_V6M = "v6m"; extern const char* SUB_V6M;
const char* SUB_V7A = "v7a"; extern const char* SUB_V7A;
const char* SUB_V7M = "v7m"; extern const char* SUB_V7M;
const char* VENDOR_PC = "pc"; extern const char* VENDOR_PC;
const char* VENDOR_APPLE = "apple"; extern const char* VENDOR_APPLE;
const char* VENDOR_NVIDIA = "nvidia"; extern const char* VENDOR_NVIDIA;
const char* VENDOR_IBM = "ibm"; extern const char* VENDOR_IBM;
const char* SYS_NONE = "none"; extern const char* SYS_NONE;
const char* SYS_LINUX = "linux"; extern const char* SYS_LINUX;
const char* SYS_WIN32 = "win32"; extern const char* SYS_WIN32;
const char* SYS_DARWIN = "darwin"; extern const char* SYS_DARWIN;
const char* SYS_CUDA = "cuda"; extern const char* SYS_CUDA;
const char* ENV_EABI = "eabi"; extern const char* ENV_EABI;
const char* ENV_GNU = "gnu"; extern const char* ENV_GNU;
const char* ENV_ANDROID = "android"; extern const char* ENV_ANDROID;
const char* ENV_MACHO = "macho"; extern const char* ENV_MACHO;
const char* ENV_ELF = "elf"; extern const char* ENV_ELF;
const char* extract_arch_from_triple(const char* triple); const char* extract_arch_from_triple(const char* triple);