From 12daee5c4431e7de3ff5bf0ed3f6e8b97ef57f24 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 20 Aug 2023 15:26:54 +0200 Subject: [PATCH] DGen - Lookup the value of `dgen:compiler` from the config and use that as the C compiler Configuration - Set default value of `dgen:compiler` to `"clang"` Commands - Added a command to specify the C compile to use - Transfer `-cccompiler`/`-cc` over to a config entry --- source/tlang/commandline/commands.d | 7 +++++++ source/tlang/compiler/codegen/emit/dgen.d | 3 ++- source/tlang/compiler/configuration.d | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/tlang/commandline/commands.d b/source/tlang/commandline/commands.d index 469692a..54363b5 100644 --- a/source/tlang/commandline/commands.d +++ b/source/tlang/commandline/commands.d @@ -66,6 +66,10 @@ mixin template EmitBase() @ArgNamed("prettygen|pg", "Generate pretty-printed code") @(ArgConfig.optional) bool prettyPrintCodeGen = true; + + @ArgNamed("ccompiler|cc", "The system C compiler to use for DGne (C emitter)") + @(ArgConfig.optional) + string systemCC = "clang"; @ArgNamed("output|o", "Filename of generated object file") @(ArgConfig.optional) @@ -99,6 +103,9 @@ mixin template EmitBase() // Set whether or not to enable pre-inlining of function call arguments in DGen compiler.getConfig().addConfig(ConfigEntry("dgen:preinline_args", preinlineArguments)); + // Set the C compiler to use for DGen + compiler.getConfig().addConfig(ConfigEntry("dgen:compiler", systemCC)); + // Set the paths to the object files to link in compiler.getConfig().addConfig(ConfigEntry("linker:link_files", bruh)); } diff --git a/source/tlang/compiler/codegen/emit/dgen.d b/source/tlang/compiler/codegen/emit/dgen.d index 449ea8b..5824772 100644 --- a/source/tlang/compiler/codegen/emit/dgen.d +++ b/source/tlang/compiler/codegen/emit/dgen.d @@ -1286,7 +1286,8 @@ int main() try { //NOTE: Change to system compiler (maybe, we need to choose a good C compiler) - string[] compileArgs = ["clang", "-o", "tlang.out", file.name()]; + string systemCompiler = config.getConfig("dgen:compiler").getText(); + string[] compileArgs = [systemCompiler, "-o", "tlang.out", file.name()]; // Check for object files to be linked in string[] objectFilesLink; diff --git a/source/tlang/compiler/configuration.d b/source/tlang/compiler/configuration.d index 28da661..f6f1757 100644 --- a/source/tlang/compiler/configuration.d +++ b/source/tlang/compiler/configuration.d @@ -212,6 +212,9 @@ public final class CompilerConfiguration /* Set the mapping to hashing of entity names for DGen (TODO: This should be changed before release) */ config.addConfig(ConfigEntry("dgen:mapper", "hashmapper")); + /* Set the system C compiler for DGen to clang */ + config.addConfig(ConfigEntry("dgen:compiler", "clang")); + /** * Configure, at compile time, the system type aliases */