mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Support C3C_LIB and C3C_CC environment variables. Enable compiling against 20 to see if it works.
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -216,7 +216,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Release, Debug]
|
||||
llvm_version: [17, 18, 19]
|
||||
llvm_version: [17, 18, 19, 20]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
- Support `int[*] { 1, 2, 3 }` expressions.
|
||||
- Support inline struct designated init as if inline was anonymous.
|
||||
- Introduce the `.paramsof` property.
|
||||
- Support environment variable 'C3C_LIB' to find the standard library.
|
||||
- Support environment variable 'C3C_CC' to find the default C compiler.
|
||||
|
||||
### Fixes
|
||||
- Issue where a lambda wasn't correctly registered as external. #1408
|
||||
|
||||
@@ -270,6 +270,7 @@ static void free_arenas(void)
|
||||
static int compile_cfiles(const char *cc, const char **files, const char *flags, const char **include_dirs,
|
||||
const char **out_files, const char *output_subdir)
|
||||
{
|
||||
if (!cc) cc = default_c_compiler();
|
||||
int total = 0;
|
||||
FOREACH(const char *, file, files)
|
||||
{
|
||||
@@ -1453,3 +1454,20 @@ File *compile_and_invoke(const char *file, const char *args, const char *stdin_d
|
||||
return source_file_text_load(file, out);
|
||||
}
|
||||
|
||||
const char *default_c_compiler(void)
|
||||
{
|
||||
static const char *cc = NULL;
|
||||
if (cc) return cc;
|
||||
const char *cc_env = getenv("C3C_CC");
|
||||
if (cc_env && strlen(cc_env) > 0)
|
||||
{
|
||||
INFO_LOG("Setting CC to %s from environment variable 'C3C_CC'.", cc_env);
|
||||
cc = strdup(cc);
|
||||
return cc;
|
||||
}
|
||||
#if PLATFORM_WINDOWS
|
||||
return cc = "cl.exe";
|
||||
#else
|
||||
return cc = "cc";
|
||||
#endif
|
||||
}
|
||||
@@ -3747,4 +3747,4 @@ INLINE bool check_module_name(Path *path)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const char *default_c_compiler(void);
|
||||
@@ -853,7 +853,7 @@ void platform_linker(const char *output_file, const char **files, unsigned file_
|
||||
else
|
||||
{
|
||||
INFO_LOG("Using cc linker.");
|
||||
vec_add(parts, compiler.build.cc ? compiler.build.cc : "cc");
|
||||
vec_add(parts, compiler.build.cc ? compiler.build.cc : default_c_compiler());
|
||||
append_fpie_pic_options(compiler.platform.reloc_model, &parts);
|
||||
}
|
||||
|
||||
|
||||
@@ -1931,10 +1931,6 @@ void target_setup(BuildTarget *target)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!target->cc)
|
||||
{
|
||||
target->cc = compiler.platform.os == OS_TYPE_WIN32 ? "cl.exe" : "cc";
|
||||
}
|
||||
|
||||
compiler.platform.int128 = os_target_supports_int128(compiler.platform.os, compiler.platform.arch);
|
||||
compiler.platform.vec128f = os_target_supports_vec(compiler.platform.os, compiler.platform.arch, 128, false);
|
||||
|
||||
@@ -184,8 +184,6 @@ bool file_namesplit(const char *path, char** filename_ptr, char** directory_ptr)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *file_expand_path(const char *path)
|
||||
{
|
||||
if (path[0] == '~' && path[1] == '/')
|
||||
@@ -377,6 +375,16 @@ const char *find_rel_exe_dir(const char *dir)
|
||||
|
||||
const char *find_lib_dir(void)
|
||||
{
|
||||
char *lib_dir_env = getenv("C3C_LIB");
|
||||
if (lib_dir_env && strlen(lib_dir_env) > 0)
|
||||
{
|
||||
INFO_LOG("Using stdlib library from env 'C3C_LIB': %s.", lib_dir_env);
|
||||
if (!file_exists(lib_dir_env))
|
||||
{
|
||||
error_exit("Library path from 'C3C_LIB' environment variable: '%s', could not be resolved.", lib_dir_env);
|
||||
}
|
||||
return strdup(lib_dir_env);
|
||||
}
|
||||
char *path = find_executable_path();
|
||||
|
||||
INFO_LOG("Detected executable path at %s", path);
|
||||
|
||||
Reference in New Issue
Block a user