mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
CI: Major refactor, expanded coverage, and ~80% speedup (#2736)
* netbsd fail on error
- Group each BSD test in its own subshell. Without this, if an error
occurs, it exits, but we don't know "where" it failed
- added *usesh: true* to BSD for faster copying into the virtualbox VM
- Some test_suite_runners wheren't correctly printing. added
--no-terminal
- For testing I've changed *build-msvc* from Debug to RelWithDebInfo
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* separate runs
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* fix typo
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* Split msvc-debug into separate workflow
Run msvc-debug only on maintainer pushes, keep CI fast and still catches
errors.
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* Fix build and test errors on NetBSD
* Set proper sizes for various types used for threads
* Add num_cpu function
* Add sysctl constants
* Allow testproject to build on NetBSD
* Tweaks to the linker code so that it adds correct flags and finds dynamic linker on NetBSD
* bsd: force system linker test
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* system linker on openbsd
remove lld from netbsd
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* use cc linker in openbsd, and re-add lld for netbsd
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* openbsd: fixes
- implement num_cpu() for OPENBSD
- testproject: add openbsd
- linker.c: fix for openbsd
- bsd refactor main.yml and more fixes
* openbsd: fix for unit tests and test_suite_runner
openbsd now passes all tests except the 'dynlib-test' which yields
'relocation error' when running `cc test.c -L. -ladd -Wl,-rpath=.`
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* openbsd: guard/disable unit test test_ct_intlog2()
* build-msys2-clang: add all tests that build-msvc has
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* Fix Windows import library generation by adding /IMPLIB support and properly declaring static_lib_name()
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* build-msys2-mingw: add all tests that build-msvc has and enable it
configure CMake to link LLVM and LLD statically
* Revert "Revert windows"
This reverts commit 197f82d829.
* win-llvm 21.1.8
uses the RelWithDebInfo+Assertions
* refactor(CI): Centralize test logic and fix Docker execution
This commit refactors the GitHub Actions workflow to improve
maintainability and correct a flaw in the Docker build.
- Ensures Docker based tests run *inside* the generated container, not
on the host. This also fixes environment isolation and user permission
errors.
- Centralizes all common test steps (examples, libs, unit tests, etc)
into a single, auto-detecting Bash script: `scripts/tools/ci_tests.sh`.
- Centralize all release artifact packaging into a single
`scripts/tools/package_build.sh`
- fixes using correct paths for test_suite_runner when running on
windows under bash.
- This significantly reduces YAML duplication, making `main.yml` more
readable and easier to maintain.
This one supersedes pull/2677, and includes the fixes for:
- fix openbsd and netbsd
- added win-llvm 21.1.8 and fixed CMakeLists.txt
- added full unit-tests and suite for build-msys2-mingw and
build-msys2-clang
* macos: add/fix build for llvm (19,20,21)
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* ci: run tests in temp dir to avoid workspace pollution
Executes ci_tests.sh in a disposable temporary directory by copying
resources/ and test/ folders, preventing build artifacts from cluttering
the source tree.
This makes it easy to run `scripts/tools/ci_tests.sh` locally on any
platform.
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* add ilammy/msvc-dev-cmd@ and Ninja
we can simplify the windows runner and run everything in bash
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* windows: drain subprocess stderr before join to avoid test_suite_runner hang
* move last test to `ci_tests.sh`
thus completing the centralization of tests in `ci_tests.sh`
* Fix Windows CI cache
Updates the cache key to include hashes of CMakeLists.txt and the
workflow file.
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* `package_build.sh` runs in temp dir to avoid workspace pollution
- add cleanup
* nix: use `ci_tests.sh`
* remove annoying build-mac warnings
This now checks if package already installed trying to prevent
annoying warnings in the github ci:
Fixes:
```
build-mac (Release, 19)curl 8.17.0 is already installed and up-to-date.
To reinstall 8.17.0, run: brew reinstall curl
```
* refactor test_suite_runner
- less allocations, cleaner code, more maintainable.
- now can be killed and the temp dirs are correctly cleaned up, and the
output is correct.
* main.yml: bsd: change to using rsync, is twice as fast.
* default to `--wincrt=dynamic` when `--sanitize=address` on windows
Default to dynamic, as static ASan is removed in LLVM 21+ for Windows
https://github.com/llvm/llvm-project/pull/107899
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
* Formatting (indent with tab, align with space). Fix K&R braces. Style: keep all cases multiline if one is.
---------
Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
Co-authored-by: Alex Garrett <limit.ordinal17@gmail.com>
This commit is contained in:
@@ -184,6 +184,7 @@ static void linker_setup_windows(const char ***args_ref, Linker linker_type, con
|
||||
{
|
||||
if (crt_linking == WIN_CRT_STATIC)
|
||||
{
|
||||
// This path is now unreachable due to the check in compiler.c
|
||||
add_concat_file_arg(compiler_path, "c3c_rt/clang_rt.asan-x86_64.lib");
|
||||
}
|
||||
else
|
||||
@@ -589,63 +590,72 @@ static void linker_setup_bsd(const char ***args_ref, Linker linker_type, bool is
|
||||
{
|
||||
if (compiler.linking.link_math) linking_add_link(&compiler.linking, "m");
|
||||
linking_add_link(&compiler.linking, "pthread");
|
||||
linking_add_link(&compiler.linking, "execinfo"); // for backtrace
|
||||
if (compiler.build.debug_info == DEBUG_INFO_FULL)
|
||||
{
|
||||
add_plain_arg("-rdynamic");
|
||||
}
|
||||
linking_add_link(&compiler.linking, "execinfo");
|
||||
if (compiler.build.debug_info == DEBUG_INFO_FULL) add_plain_arg("-rdynamic");
|
||||
return;
|
||||
}
|
||||
if (is_no_pie(compiler.platform.reloc_model)) add_plain_arg("-no-pie");
|
||||
if (is_pie(compiler.platform.reloc_model)) add_plain_arg("-pie");
|
||||
add_plain_arg("--eh-frame-hdr");
|
||||
|
||||
if (!link_libc()) return;
|
||||
|
||||
const char *crt_dir = find_bsd_crt();
|
||||
if (!crt_dir)
|
||||
if (!crt_dir) error_exit("Failed to find the C runtime at link time.");
|
||||
if (strip_unused() && compiler.build.type == TARGET_TYPE_EXECUTABLE) add_plain_arg("--gc-sections");
|
||||
bool is_openbsd = compiler.platform.os == OS_TYPE_OPENBSD;
|
||||
bool is_netbsd = compiler.platform.os == OS_TYPE_NETBSD;
|
||||
bool is_pie_pic_mode = is_pie_pic(compiler.platform.reloc_model);
|
||||
if (is_openbsd)
|
||||
{
|
||||
error_exit("Failed to find the C runtime at link time.");
|
||||
}
|
||||
if (strip_unused() && compiler.build.type == TARGET_TYPE_EXECUTABLE)
|
||||
{
|
||||
add_plain_arg("--gc-sections");
|
||||
}
|
||||
if (is_pie_pic(compiler.platform.reloc_model))
|
||||
{
|
||||
if (!is_dylib) add_plain_arg("-pie");
|
||||
add_concat_file_arg(crt_dir, "crti.o");
|
||||
if (!is_dylib && compiler.platform.os != OS_TYPE_NETBSD)
|
||||
{
|
||||
add_concat_file_arg(crt_dir, "Scrt1.o");
|
||||
}
|
||||
add_concat_file_arg(crt_dir, "crtbeginS.o");
|
||||
add_concat_file_arg(crt_dir, "crtendS.o");
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *crt_o = compiler.platform.os == OS_TYPE_NETBSD ? "crt0.o" : "crt1.o";
|
||||
add_concat_file_arg(crt_dir, "crti.o");
|
||||
if (!is_dylib) add_concat_file_arg(crt_dir, crt_o);
|
||||
if (!is_dylib) add_concat_file_arg(crt_dir, "crt0.o");
|
||||
add_concat_file_arg(crt_dir, "crtbegin.o");
|
||||
add_concat_file_arg(crt_dir, "crtend.o");
|
||||
}
|
||||
add_concat_file_arg(crt_dir, "crtn.o");
|
||||
add_concat_quote_arg("-L", crt_dir);
|
||||
add_plain_arg("--dynamic-linker=/libexec/ld-elf.so.1");
|
||||
if (compiler.platform.os == OS_TYPE_NETBSD)
|
||||
else
|
||||
{
|
||||
/* The following two flags are needed to work around ld-elf.so not being able
|
||||
* to handle more than two PT_LOAD segments. */
|
||||
add_plain_arg("--no-rosegment");
|
||||
add_plain_arg("-znorelro");
|
||||
if (!is_openbsd) add_concat_file_arg(crt_dir, "crti.o");
|
||||
if (is_dylib || is_pie_pic_mode)
|
||||
{
|
||||
if (!is_dylib && is_pie(compiler.platform.reloc_model)) add_plain_arg("-pie");
|
||||
if (!is_dylib) add_concat_file_arg(crt_dir, is_netbsd ? "crt0.o" : "Scrt1.o");
|
||||
add_concat_file_arg(crt_dir, "crtbeginS.o");
|
||||
add_concat_file_arg(crt_dir, "crtendS.o");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!is_dylib) add_concat_file_arg(crt_dir, is_netbsd ? "crt0.o" : "crt1.o");
|
||||
add_concat_file_arg(crt_dir, "crtbegin.o");
|
||||
add_concat_file_arg(crt_dir, "crtend.o");
|
||||
}
|
||||
if (!is_openbsd) add_concat_file_arg(crt_dir, "crtn.o");
|
||||
}
|
||||
add_concat_quote_arg("-L", crt_dir);
|
||||
add_plain_arg("-L/usr/lib/");
|
||||
switch (compiler.platform.os)
|
||||
{
|
||||
case OS_TYPE_NETBSD:
|
||||
add_plain_arg("--dynamic-linker=/usr/libexec/ld.elf_so");
|
||||
if (is_dylib)
|
||||
{
|
||||
add_plain_arg("--no-rosegment");
|
||||
add_plain_arg("-znorelro");
|
||||
}
|
||||
break;
|
||||
case OS_TYPE_OPENBSD:
|
||||
add_plain_arg("--dynamic-linker=/usr/libexec/ld.so");
|
||||
break;
|
||||
default:
|
||||
add_plain_arg("--dynamic-linker=/libexec/ld-elf.so.1");
|
||||
}
|
||||
linking_add_link(&compiler.linking, "c");
|
||||
if (is_openbsd)
|
||||
{
|
||||
linking_add_link(&compiler.linking, "execinfo");
|
||||
}
|
||||
else
|
||||
{
|
||||
linking_add_link(&compiler.linking, "gcc");
|
||||
linking_add_link(&compiler.linking, "gcc_s");
|
||||
}
|
||||
if (compiler.linking.link_math) linking_add_link(&compiler.linking, "m");
|
||||
linking_add_link(&compiler.linking, "gcc");
|
||||
linking_add_link(&compiler.linking, "gcc_s");
|
||||
|
||||
add_plain_arg("-L/usr/lib/");
|
||||
add_plain_arg("-m");
|
||||
add_plain_arg(ld_target(compiler.platform.arch));
|
||||
}
|
||||
@@ -716,6 +726,7 @@ static bool linker_setup(const char ***args_ref, const char **files_to_link, uns
|
||||
if (is_dylib)
|
||||
{
|
||||
add_plain_arg("/DLL");
|
||||
add_concat_quote_arg("/IMPLIB:", static_lib_name());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -932,8 +943,8 @@ static bool link_exe(const char *output_file, const char **files_to_link, unsign
|
||||
UNREACHABLE
|
||||
}
|
||||
#else
|
||||
success = false;
|
||||
error = "linking (.exe) is not implemented for C3C compiled without LLVM";
|
||||
success = false;
|
||||
error = "linking (.exe) is not implemented for C3C compiled without LLVM";
|
||||
#endif
|
||||
if (!success)
|
||||
{
|
||||
@@ -1163,9 +1174,9 @@ bool dynamic_lib_linker(const char *output_file, const char **files, unsigned fi
|
||||
return true;
|
||||
}
|
||||
bool success;
|
||||
const char *error = NULL;
|
||||
const char *error = NULL;
|
||||
#if LLVM_AVAILABLE
|
||||
int count = assemble_link_arguments(args, vec_size(args));
|
||||
int count = assemble_link_arguments(args, vec_size(args));
|
||||
switch (compiler.platform.object_format)
|
||||
{
|
||||
case OBJ_FORMAT_COFF:
|
||||
@@ -1184,8 +1195,8 @@ bool dynamic_lib_linker(const char *output_file, const char **files, unsigned fi
|
||||
UNREACHABLE
|
||||
}
|
||||
#else
|
||||
success = false;
|
||||
error = "linking not implemented for c3c compiled without llvm";
|
||||
success = false;
|
||||
error = "linking not implemented for c3c compiled without llvm";
|
||||
#endif
|
||||
if (!success)
|
||||
{
|
||||
@@ -1219,7 +1230,7 @@ bool static_lib_linker(const char *output_file, const char **files, unsigned fil
|
||||
}
|
||||
return llvm_ar(output_file, files, file_count, format);
|
||||
#else
|
||||
return false;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user