1 /** 2 * Configures and initializes the backend. 3 * 4 * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved 5 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) 6 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dmsc.d, _dmsc.d) 8 * Documentation: https://dlang.org/phobos/dmd_dmsc.html 9 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/dmsc.d 10 */ 11 12 module dmd.dmsc; 13 14 import core.stdc.stdio; 15 import core.stdc.string; 16 import core.stdc.stddef; 17 18 extern (C++): 19 20 import dmd.globals; 21 import dmd.dclass; 22 import dmd.dmdparams; 23 import dmd.dmodule; 24 import dmd.mtype; 25 import dmd.target; 26 27 import dmd.root.filename; 28 29 import dmd.backend.cc; 30 import dmd.backend.cdef; 31 import dmd.backend.global; 32 import dmd.backend.ty; 33 import dmd.backend.type; 34 import dmd.backend.backconfig; 35 36 /************************************** 37 * Initialize config variables. 38 */ 39 40 void backend_init() 41 { 42 //printf("out_config_init()\n"); 43 Param *params = &global.params; 44 exefmt_t exfmt; 45 switch (target.os) 46 { 47 case Target.OS.Windows: exfmt = target.isX86_64 ? EX_WIN64 : EX_WIN32; break; 48 case Target.OS.linux: exfmt = target.isX86_64 ? EX_LINUX64 : EX_LINUX; break; 49 case Target.OS.OSX: exfmt = target.isX86_64 ? EX_OSX64 : EX_OSX; break; 50 case Target.OS.FreeBSD: exfmt = target.isX86_64 ? EX_FREEBSD64 : EX_FREEBSD; break; 51 case Target.OS.OpenBSD: exfmt = target.isX86_64 ? EX_OPENBSD64 : EX_OPENBSD; break; 52 case Target.OS.Solaris: exfmt = target.isX86_64 ? EX_SOLARIS64 : EX_SOLARIS; break; 53 case Target.OS.DragonFlyBSD: exfmt = EX_DRAGONFLYBSD64; break; 54 default: assert(0); 55 } 56 57 bool exe; 58 if (driverParams.dll || driverParams.pic != PIC.fixed) 59 { 60 } 61 else if (params.run) 62 exe = true; // EXE file only optimizations 63 else if (driverParams.link && !params.deffile) 64 exe = true; // EXE file only optimizations 65 else if (params.exefile.length && 66 params.exefile.length >= 4 && 67 FileName.equals(FileName.ext(params.exefile), "exe")) 68 exe = true; // if writing out EXE file 69 70 out_config_init( 71 (target.isX86_64 ? 64 : 32) | (target.objectFormat() == Target.ObjectFormat.coff ? 1 : 0), 72 exe, 73 false, //params.trace, 74 driverParams.nofloat, 75 driverParams.vasm, 76 params.v.verbose, 77 driverParams.optimize, 78 driverParams.symdebug, 79 driverParams.alwaysframe, 80 driverParams.stackstomp, 81 driverParams.ibt, 82 target.cpu >= CPU.avx2 ? 2 : target.cpu >= CPU.avx ? 1 : 0, 83 driverParams.pic, 84 params.useModuleInfo && Module.moduleinfo, 85 params.useTypeInfo && Type.dtypeinfo, 86 params.useExceptions && ClassDeclaration.throwable, 87 driverParams.dwarf, 88 global.versionString(), 89 exfmt, 90 params.addMain 91 ); 92 93 out_config_debug( 94 driverParams.debugb, 95 driverParams.debugc, 96 driverParams.debugf, 97 driverParams.debugr, 98 false, 99 driverParams.debugx, 100 driverParams.debugy 101 ); 102 } 103 104 /************************************** 105 */ 106 107 void backend_term() @safe 108 { 109 }