mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Add compiler options to simplify external tool usage.
This commit is contained in:
@@ -6,8 +6,6 @@ set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
|
||||
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
|
||||
set(C3_LLVM_VERSION "auto" CACHE STRING "Use LLVM version [default: auto]")
|
||||
|
||||
#set(CMAKE_BUILD_TYPE Release)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
|
||||
if(NOT C3_LLVM_VERSION STREQUAL "auto")
|
||||
if(${C3_LLVM_VERSION} VERSION_LESS 12 OR ${C3_LLVM_VERSION} VERSION_GREATER 14)
|
||||
@@ -28,6 +26,9 @@ add_definitions(${LLVM_DEFINITIONS})
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
AllTargetsAsmParsers
|
||||
AllTargetsCodeGens
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "utils/lib.h"
|
||||
#include "utils/toml.h"
|
||||
#include "build_options.h"
|
||||
#define DEFAULT_SYMTAB_SIZE (64 * 1024)
|
||||
#define DEFAULT_SYMTAB_SIZE (256 * 1024)
|
||||
#define DEFAULT_SWITCHRANGE_MAX_SIZE (256)
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -79,6 +79,7 @@ static void usage(void)
|
||||
OUTPUT(" -V --version - Print version information.");
|
||||
OUTPUT(" -E - Lex only.");
|
||||
OUTPUT(" -P - Only parse and output the AST as S-expressions.");
|
||||
OUTPUT(" -C - Only lex, parse and check.");
|
||||
OUTPUT(" -o - Set the output binary file name.");
|
||||
OUTPUT(" -O0 - Optimizations off.");
|
||||
OUTPUT(" -O1 - Simple optimizations only.");
|
||||
@@ -278,10 +279,10 @@ static void print_all_targets(void)
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
OUTPUT("C3 Compiler Version: Pre-alpha %s", COMPILER_VERSION);
|
||||
OUTPUT("Installed directory: %s", find_executable_path());
|
||||
OUTPUT("LLVM version: %s", llvm_version);
|
||||
OUTPUT("LLVM default target: %s", llvm_target);
|
||||
OUTPUT("C3 Compiler Version (pre-alpha): %s", COMPILER_VERSION);
|
||||
OUTPUT("Installed directory: %s", find_executable_path());
|
||||
OUTPUT("LLVM version: %s", llvm_version);
|
||||
OUTPUT("LLVM default target: %s", llvm_target);
|
||||
}
|
||||
|
||||
static void parse_option(BuildOptions *options)
|
||||
@@ -402,6 +403,13 @@ static void parse_option(BuildOptions *options)
|
||||
}
|
||||
options->compile_option = COMPILE_LEX_PARSE_ONLY;
|
||||
return;
|
||||
case 'C':
|
||||
if (options->compile_option != COMPILE_NORMAL)
|
||||
{
|
||||
FAIL_WITH_ERR("Illegal combination of compile options.");
|
||||
}
|
||||
options->compile_option = COMPILE_LEX_PARSE_CHECK_ONLY;
|
||||
return;
|
||||
case '-':
|
||||
if (match_longopt("tinybackend"))
|
||||
{
|
||||
|
||||
@@ -78,6 +78,7 @@ typedef enum
|
||||
COMPILE_NORMAL,
|
||||
COMPILE_LEX_ONLY,
|
||||
COMPILE_LEX_PARSE_ONLY,
|
||||
COMPILE_LEX_PARSE_CHECK_ONLY,
|
||||
COMPILE_OUTPUT_HEADERS,
|
||||
COMPILE_OUTPUT_AST,
|
||||
} CompileOption;
|
||||
@@ -231,6 +232,7 @@ typedef struct
|
||||
bool output_ast : 1;
|
||||
bool lex_only : 1;
|
||||
bool parse_only : 1;
|
||||
bool check_only : 1;
|
||||
bool emit_llvm : 1;
|
||||
bool emit_object_files : 1;
|
||||
bool no_link : 1;
|
||||
|
||||
@@ -127,6 +127,9 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
|
||||
case COMPILE_LEX_PARSE_ONLY:
|
||||
target->parse_only = true;
|
||||
break;
|
||||
case COMPILE_LEX_PARSE_CHECK_ONLY:
|
||||
target->check_only = true;
|
||||
break;
|
||||
case COMPILE_OUTPUT_HEADERS:
|
||||
target->output_headers = true;
|
||||
target->run_after_compile = false;
|
||||
|
||||
@@ -370,6 +370,8 @@ void compiler_compile(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (active_target.check_only) return;
|
||||
|
||||
void **gen_contexts = NULL;
|
||||
void (*task)(void *);
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ int main_real(int argc, const char *argv[])
|
||||
UNREACHABLE
|
||||
}
|
||||
|
||||
print_arena_status();
|
||||
memory_release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "PRE.5"
|
||||
#define COMPILER_VERSION "PRE.6"
|
||||
Reference in New Issue
Block a user