wasm32 / wasm64 targets are use-libc=no by default.

This commit is contained in:
Christoffer Lerno
2024-09-25 21:01:00 +02:00
parent 413877b59d
commit a8932910d9
3 changed files with 44 additions and 2 deletions

View File

@@ -324,7 +324,7 @@ jobs:
- name: Test WASM - name: Test WASM
run: | run: |
cd resources/testfragments cd resources/testfragments
../../build/c3c compile --reloc=none --target wasm32 -g0 --link-libc=no --no-entry -Os wasm4.c3 ../../build/c3c compile --target wasm32 -g0 --no-entry -Os wasm4.c3
- name: Install QEMU and Risc-V toolchain - name: Install QEMU and Risc-V toolchain
run: | run: |
@@ -558,7 +558,7 @@ jobs:
- name: Test WASM - name: Test WASM
run: | run: |
cd resources/testfragments cd resources/testfragments
../../build/c3c compile --reloc=none --target wasm32 -g0 --link-libc=no --no-entry -Os wasm4.c3 ../../build/c3c compile --reloc=none --target wasm32 -g0 --no-entry -Os wasm4.c3
- name: Build testproject direct linker - name: Build testproject direct linker
run: | run: |

View File

@@ -26,6 +26,7 @@
- Deprecated inline generic types outside of struct definitions and macros unless marked `@adhoc`. - Deprecated inline generic types outside of struct definitions and macros unless marked `@adhoc`.
- Improved method detection in earlier stages of checking. - Improved method detection in earlier stages of checking.
- Allow `^` suffix for non-recursive imports #1480. - Allow `^` suffix for non-recursive imports #1480.
- wasm32 / wasm64 targets are use-libc=no by default.
### Fixes ### Fixes
- Issue where a lambda wasn't correctly registered as external. #1408 - Issue where a lambda wasn't correctly registered as external. #1408

View File

@@ -229,6 +229,43 @@ void update_build_target_with_opt_level(BuildTarget *target, OptimizationSetting
COPY_IF_DEFAULT(target->single_module, single_module); COPY_IF_DEFAULT(target->single_module, single_module);
} }
static LinkLibc libc_from_arch_os(ArchOsTarget target)
{
switch (target)
{
case ANDROID_AARCH64:
case FREEBSD_X86:
case FREEBSD_X64:
case IOS_AARCH64:
case LINUX_AARCH64:
case LINUX_RISCV32:
case LINUX_RISCV64:
case LINUX_X86:
case LINUX_X64:
case MACOS_AARCH64:
case MACOS_X64:
case MINGW_X64:
case NETBSD_X86:
case NETBSD_X64:
case OPENBSD_X86:
case OPENBSD_X64:
case WINDOWS_AARCH64:
case WINDOWS_X64:
return LINK_LIBC_ON;
case WASM32:
case WASM64:
case MCU_X86:
case ARCH_OS_TARGET_DEFAULT:
case ELF_AARCH64:
case ELF_RISCV32:
case ELF_RISCV64:
case ELF_X86:
case ELF_X64:
case ELF_XTENSA:
return LINK_LIBC_OFF;
}
UNREACHABLE
}
static void update_build_target_from_options(BuildTarget *target, BuildOptions *options) static void update_build_target_from_options(BuildTarget *target, BuildOptions *options)
{ {
@@ -470,6 +507,10 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
} }
if (target->optsetting == OPT_SETTING_NOT_SET) target->optsetting = OPT_SETTING_O0; if (target->optsetting == OPT_SETTING_NOT_SET) target->optsetting = OPT_SETTING_O0;
update_build_target_with_opt_level(target, target->optsetting); update_build_target_with_opt_level(target, target->optsetting);
if (target->link_libc == LINK_LIBC_NOT_SET)
{
target->link_libc = libc_from_arch_os(target->arch_os_target);
}
} }
void init_default_build_target(BuildTarget *target, BuildOptions *options) void init_default_build_target(BuildTarget *target, BuildOptions *options)