From bf5683b41c42955fc439f54514e4a10d4b805c8c Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 17 Feb 2022 20:49:57 +0100 Subject: [PATCH] General cleanup, more native platform detection. --- CMakeLists.txt | 5 +- src/build/build_options.c | 8 ++- src/build/build_options.h | 24 +++------ src/build/builder.c | 67 +++++++++++++++++++++---- src/build/project.c | 1 - src/compiler/ast.c | 2 +- src/compiler/bigint.c | 24 ++++----- src/compiler/c_abi_internal.h | 8 +-- src/compiler/compiler.c | 31 ++---------- src/compiler/compiler_internal.h | 56 ++++----------------- src/compiler/enums.h | 1 - src/compiler/float.c | 6 +-- src/compiler/linker.c | 22 +++----- src/compiler/llvm_codegen_c_abi_win64.c | 53 +++++++++---------- src/compiler/llvm_codegen_c_abi_x86.c | 1 - src/compiler/llvm_codegen_expr.c | 2 +- src/compiler/llvm_codegen_function.c | 2 +- src/compiler/llvm_codegen_internal.h | 2 +- src/compiler/number.c | 15 ------ src/compiler/parse_global.c | 52 +------------------ src/compiler/parse_stmt.c | 3 -- src/compiler/sema_casts.c | 25 +-------- src/compiler/target.c | 32 ++++++++---- src/compiler/tokens.c | 18 ------- src/compiler/types.c | 6 --- src/utils/errors.h | 4 +- src/utils/file_utils.c | 1 - 27 files changed, 167 insertions(+), 304 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8afb2ee..1dab620d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,9 @@ set(LLVM_LINK_COMPONENTS WindowsManifest ) +if (${LLVM_PACKAGE_VERSION} VERSION_GREATER 14) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} WindowsDriver) +endif() llvm_map_components_to_libnames(llvm_libs ${LLVM_LINK_COMPONENTS}) @@ -91,7 +94,7 @@ if(UNIX) find_library(LLD_MINGW NAMES lldMinGW.a liblldMinGW.a PATHS ${LLVM_LIBRARY_DIRS}) find_library(LLD_WASM NAMES lldWasm.a liblldWasm.a PATHS ${LLVM_LIBRARY_DIRS}) - if(${LLVM_PACKAGE_VERSION} VERSION_LESS 14) + if (${LLVM_PACKAGE_VERSION} VERSION_LESS 14) find_library(LLD_CORE NAMES lldCore.a liblldCore.a PATHS ${LLVM_LIBRARY_DIRS}) find_library(LLD_DRIVER NAMES lldDriver.a liblldDriver.a PATHS ${LLVM_LIBRARY_DIRS}) find_library(LLD_READER_WRITER NAMES lldReaderWriter.a liblldReaderWriter.a PATHS ${LLVM_LIBRARY_DIRS}) diff --git a/src/build/build_options.c b/src/build/build_options.c index 101225bf1..73edbcc44 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -25,6 +25,7 @@ extern const char* llvm_target; char *arch_os_target[ARCH_OS_TARGET_LAST + 1] = { [X86_FREEBSD] = "x86-freebsd", [X86_OPENBSD] = "x86-openbsd", + [X86_NETBSD] = "x86-netbsd", [X86_MCU] = "x86-mcu", [X86_ELF] = "x86-elf", [X86_WINDOWS] = "x86-windows", @@ -33,12 +34,17 @@ char *arch_os_target[ARCH_OS_TARGET_LAST + 1] = { [X64_LINUX] = "x64-linux", [X64_WINDOWS] = "x64-windows", [X64_WINDOWS_GNU] = "x64-mingw", + [X64_FREEBSD] = "x64-freebsd", + [X64_OPENBSD] = "x64-openbsd", [X64_NETBSD] = "x64-netbsd", [X64_ELF] = "x64-elf", [AARCH64_LINUX] = "aarch64-linux", [AARCH64_DARWIN] = "aarch64-darwin", + [AARCH64_ELF] = "aarch64-elf", [RISCV32_LINUX] = "riscv32-linux", + [RISCV32_ELF] = "riscv32-elf", [RISCV64_LINUX] = "riscv64-linux", + [RISCV64_ELF] = "riscv64-elf", [WASM32] = "wasm32", [WASM64] = "wasm64", }; @@ -70,7 +76,7 @@ static void usage(void) OUTPUT(" --stdlib - Use this directory as the C3 standard library path."); OUTPUT(" --lib - Use this directory as the C3 library path."); OUTPUT(" --path - Use this as the base directory for the current command."); - OUTPUT(" --template