Skip to content

Commit

Permalink
backend_init() gets const ref parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and dlang-bot committed Jun 3, 2024
1 parent be53a38 commit 05e70f4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
17 changes: 10 additions & 7 deletions compiler/src/dmd/dmsc.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/target.d
Original file line number Diff line number Diff line change
Expand Up @@ -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 = &params;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 05e70f4

Please sign in to comment.