From 05e70f4b0904604353af176a7e46a1efa06f6152 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sun, 2 Jun 2024 22:49:15 -0700 Subject: [PATCH] backend_init() gets const ref parameters --- compiler/src/dmd/dmsc.d | 17 ++++++++++------- compiler/src/dmd/main.d | 2 +- compiler/src/dmd/mars.d | 8 ++++---- compiler/src/dmd/target.d | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/compiler/src/dmd/dmsc.d b/compiler/src/dmd/dmsc.d index af037bb19a23..d7abe8f84810 100644 --- a/compiler/src/dmd/dmsc.d +++ b/compiler/src/dmd/dmsc.d @@ -32,19 +32,22 @@ import dmd.backend.type; import dmd.backend.backconfig; /************************************** - * Initialize config variables. + * Initialize backend config variables. + * Params: + * params = command line parameters + * driverParams = more command line parameters + * target = target machine info */ -void backend_init() +void backend_init(const ref Param params, const ref DMDparams driverParams, const ref Target target) { - //printf("out_config_init()\n"); - Param *params = &global.params; + //printf("backend_init()\n"); exefmt_t exfmt; switch (target.os) { - case Target.OS.Windows: exfmt = target.isX86_64 ? EX_WIN64 : EX_WIN32; break; - case Target.OS.linux: exfmt = target.isX86_64 ? EX_LINUX64 : EX_LINUX; break; - case Target.OS.OSX: exfmt = target.isX86_64 ? EX_OSX64 : EX_OSX; break; + case Target.OS.Windows: exfmt = target.isX86_64 ? EX_WIN64 : EX_WIN32; break; + case Target.OS.linux: exfmt = target.isX86_64 ? EX_LINUX64 : EX_LINUX; break; + case Target.OS.OSX: exfmt = target.isX86_64 ? EX_OSX64 : EX_OSX; break; case Target.OS.FreeBSD: exfmt = target.isX86_64 ? EX_FREEBSD64 : EX_FREEBSD; break; case Target.OS.OpenBSD: exfmt = target.isX86_64 ? EX_OPENBSD64 : EX_OPENBSD; break; case Target.OS.Solaris: exfmt = target.isX86_64 ? EX_SOLARIS64 : EX_SOLARIS; break; diff --git a/compiler/src/dmd/main.d b/compiler/src/dmd/main.d index 224b2c380908..a5e53ee18bd6 100644 --- a/compiler/src/dmd/main.d +++ b/compiler/src/dmd/main.d @@ -522,7 +522,7 @@ private int tryMain(size_t argc, const(char)** argv, ref Param params) if (global.errors) removeHdrFilesAndFail(params, modules); - backend_init(); + backend_init(params, driverParams, target); // Do semantic analysis foreach (m; modules) diff --git a/compiler/src/dmd/mars.d b/compiler/src/dmd/mars.d index 891169472e3d..6a6ede5f97f4 100644 --- a/compiler/src/dmd/mars.d +++ b/compiler/src/dmd/mars.d @@ -344,9 +344,9 @@ const(char)[] parse_conf_arg(Strings* args) * Note that if `-defaultlib=` or `-debuglib=` was used, * we don't override that either. * Params: - * target = parameters set by user - * defaultlibname = set based on `target` - * debuglibname = set based on `target` + * target = parameters set by user + * defaultlibname = set based on `target` + * debuglibname = set based on `target` */ pure @safe void setDefaultLibraries(const ref Target target, ref const(char)[] defaultlibname, ref const(char)[] debuglibname) @@ -456,7 +456,7 @@ extern(C) void flushMixins() * params = set to result of parsing `arguments` * files = set to files pulled from `arguments` * target = more things set to result of parsing `arguments` - * driverParams = even more things to set + * driverParams = even more things to set * Returns: * true if errors in command line */ diff --git a/compiler/src/dmd/target.d b/compiler/src/dmd/target.d index e53291f8ec9f..c471b7a09eb0 100644 --- a/compiler/src/dmd/target.d +++ b/compiler/src/dmd/target.d @@ -406,7 +406,7 @@ extern (C++) struct Target extern (C++) void _init(ref const Param params) { // isX86_64 and cpu are initialized in parseCommandLine - isX86 = !isX86_64; + isX86 = !isX86_64; this.params = ¶ms; @@ -499,7 +499,7 @@ extern (C++) struct Target /** Determine the object format to be used */ - extern(D) Target.ObjectFormat objectFormat() @safe + extern(D) Target.ObjectFormat objectFormat() const @safe { if (os == Target.OS.OSX) return Target.ObjectFormat.macho;