Added fasm (external assembler) support.
This commit is contained in:
parent
626226efa4
commit
df0e1a515b
3 changed files with 49 additions and 2 deletions
|
|
@ -612,6 +612,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
|
||||||
of "experimental":
|
of "experimental":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
gExperimentalMode = true
|
gExperimentalMode = true
|
||||||
|
of "assembler":
|
||||||
|
cAssembler = nameToCC(arg)
|
||||||
|
if cAssembler notin cValidAssemblers:
|
||||||
|
localError(info, errGenerated, "'$1' is not a valid assembler." % [arg])
|
||||||
else:
|
else:
|
||||||
if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg)
|
if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg)
|
||||||
else: invalidCmdLineOption(pass, switch, info)
|
else: invalidCmdLineOption(pass, switch, info)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import
|
||||||
type
|
type
|
||||||
TSystemCC* = enum
|
TSystemCC* = enum
|
||||||
ccNone, ccGcc, ccLLVM_Gcc, ccCLang, ccLcc, ccBcc, ccDmc, ccWcc, ccVcc,
|
ccNone, ccGcc, ccLLVM_Gcc, ccCLang, ccLcc, ccBcc, ccDmc, ccWcc, ccVcc,
|
||||||
ccTcc, ccPcc, ccUcc, ccIcl
|
ccTcc, ccPcc, ccUcc, ccIcl, asmFasm
|
||||||
TInfoCCProp* = enum # properties of the C compiler:
|
TInfoCCProp* = enum # properties of the C compiler:
|
||||||
hasSwitchRange, # CC allows ranges in switch statements (GNU C)
|
hasSwitchRange, # CC allows ranges in switch statements (GNU C)
|
||||||
hasComputedGoto, # CC has computed goto (GNU C extension)
|
hasComputedGoto, # CC has computed goto (GNU C extension)
|
||||||
|
|
@ -318,6 +318,31 @@ compiler ucc:
|
||||||
packedPragma: "", # XXX: not supported yet
|
packedPragma: "", # XXX: not supported yet
|
||||||
props: {})
|
props: {})
|
||||||
|
|
||||||
|
# fasm assembler
|
||||||
|
compiler fasm:
|
||||||
|
result = (
|
||||||
|
name: "fasm",
|
||||||
|
objExt: "o",
|
||||||
|
optSpeed: "",
|
||||||
|
optSize: "",
|
||||||
|
compilerExe: "fasm",
|
||||||
|
cppCompiler: "fasm",
|
||||||
|
compileTmpl: "$file $objfile",
|
||||||
|
buildGui: "",
|
||||||
|
buildDll: "",
|
||||||
|
buildLib: "",
|
||||||
|
linkerExe: "",
|
||||||
|
linkTmpl: "",
|
||||||
|
includeCmd: "",
|
||||||
|
linkDirCmd: "",
|
||||||
|
linkLibCmd: "",
|
||||||
|
debug: "",
|
||||||
|
pic: "",
|
||||||
|
asmStmtFrmt: "",
|
||||||
|
structStmtFmt: "",
|
||||||
|
packedPragma: "",
|
||||||
|
props: {})
|
||||||
|
|
||||||
const
|
const
|
||||||
CC*: array[succ(low(TSystemCC))..high(TSystemCC), TInfoCC] = [
|
CC*: array[succ(low(TSystemCC))..high(TSystemCC), TInfoCC] = [
|
||||||
gcc(),
|
gcc(),
|
||||||
|
|
@ -331,16 +356,19 @@ const
|
||||||
tcc(),
|
tcc(),
|
||||||
pcc(),
|
pcc(),
|
||||||
ucc(),
|
ucc(),
|
||||||
icl()]
|
icl(),
|
||||||
|
fasm()]
|
||||||
|
|
||||||
hExt* = ".h"
|
hExt* = ".h"
|
||||||
|
|
||||||
var
|
var
|
||||||
cCompiler* = ccGcc # the used compiler
|
cCompiler* = ccGcc # the used compiler
|
||||||
|
cAssembler* = ccNone
|
||||||
gMixedMode*: bool # true if some module triggered C++ codegen
|
gMixedMode*: bool # true if some module triggered C++ codegen
|
||||||
cIncludes*: seq[string] = @[] # directories to search for included files
|
cIncludes*: seq[string] = @[] # directories to search for included files
|
||||||
cLibs*: seq[string] = @[] # directories to search for lib files
|
cLibs*: seq[string] = @[] # directories to search for lib files
|
||||||
cLinkedLibs*: seq[string] = @[] # libraries to link
|
cLinkedLibs*: seq[string] = @[] # libraries to link
|
||||||
|
cValidAssemblers* = @[asmFasm]
|
||||||
|
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
|
|
@ -527,6 +555,19 @@ proc getLinkerExe(compiler: TSystemCC): string =
|
||||||
|
|
||||||
proc getCompileCFileCmd*(cfilename: string, isExternal = false): string =
|
proc getCompileCFileCmd*(cfilename: string, isExternal = false): string =
|
||||||
var c = cCompiler
|
var c = cCompiler
|
||||||
|
if cfilename.endswith(".asm"):
|
||||||
|
var customAssembler = getConfigVar("assembler")
|
||||||
|
if customAssembler.len > 0:
|
||||||
|
c = nameToCC(customAssembler)
|
||||||
|
else:
|
||||||
|
if targetCPU == cpuI386 or targetCPU == cpuAmd64:
|
||||||
|
c = asmFasm
|
||||||
|
else:
|
||||||
|
c = ccNone
|
||||||
|
|
||||||
|
if c == ccNone:
|
||||||
|
rawMessage(errExternalAssemblerNotFound, "")
|
||||||
|
|
||||||
var options = cFileSpecificOptions(cfilename)
|
var options = cFileSpecificOptions(cfilename)
|
||||||
var exe = getConfigVar(c, ".exe")
|
var exe = getConfigVar(c, ".exe")
|
||||||
if exe.len == 0: exe = c.getCompilerExe
|
if exe.len == 0: exe = c.getCompilerExe
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ type
|
||||||
errCannotInferReturnType,
|
errCannotInferReturnType,
|
||||||
errGenericLambdaNotAllowed,
|
errGenericLambdaNotAllowed,
|
||||||
errCompilerDoesntSupportTarget,
|
errCompilerDoesntSupportTarget,
|
||||||
|
errExternalAssemblerNotFound,
|
||||||
errUser,
|
errUser,
|
||||||
warnCannotOpenFile,
|
warnCannotOpenFile,
|
||||||
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
|
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
|
||||||
|
|
@ -370,6 +371,7 @@ const
|
||||||
"it is used as an operand to another routine and the types " &
|
"it is used as an operand to another routine and the types " &
|
||||||
"of the generic paramers can be inferred from the expected signature.",
|
"of the generic paramers can be inferred from the expected signature.",
|
||||||
errCompilerDoesntSupportTarget: "The current compiler \'$1\' doesn't support the requested compilation target",
|
errCompilerDoesntSupportTarget: "The current compiler \'$1\' doesn't support the requested compilation target",
|
||||||
|
errExternalAssemblerNotFound: "External assembler not found",
|
||||||
errUser: "$1",
|
errUser: "$1",
|
||||||
warnCannotOpenFile: "cannot open \'$1\'",
|
warnCannotOpenFile: "cannot open \'$1\'",
|
||||||
warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored",
|
warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue