This commit is contained in:
araq
2025-12-02 10:16:11 +01:00
parent ce4d75cbc2
commit 5fc7feacd1
4 changed files with 19 additions and 6 deletions

View File

@@ -52,13 +52,14 @@ proc nifLineInfo(w: var LineInfoWriter; info: TLineInfo): PackedLineInfo =
result = NoLineInfo
else:
let fid = get(w, info.fileIndex)
result = pack(w.man, fid, info.line.int32, info.col)
# Must use pool.man since toString uses pool.man to unpack
result = pack(pool.man, fid, info.line.int32, info.col)
proc oldLineInfo(w: var LineInfoWriter; info: PackedLineInfo): TLineInfo =
if info == NoLineInfo:
result = unknownLineInfo
else:
var x = unpack(w.man, info)
var x = unpack(pool.man, info)
var fileIdx: FileIndex
if w.fileV == x.file:
fileIdx = w.fileK

View File

@@ -420,8 +420,9 @@ proc mainCommand*(graph: ModuleGraph) =
of cmdCheck:
commandCheck(graph)
of cmdM:
graph.config.symbolFiles = v2Sf
setUseIc(graph.config.symbolFiles != disabledSf)
# cmdM uses NIF files, not ROD files
graph.config.symbolFiles = disabledSf
setUseIc(false)
commandCheck(graph)
of cmdParse:
wantMainModule(conf)

View File

@@ -118,7 +118,8 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
if conf.selectedGC == gcUnselected:
if conf.backend in {backendC, backendCpp, backendObjc} or
(conf.cmd in cmdDocLike and conf.backend != backendJs) or
conf.cmd == cmdGendepend:
conf.cmd == cmdGendepend or
conf.cmd == cmdM:
initOrcDefines(conf)
mainCommand(graph)

View File

@@ -38,7 +38,12 @@ proc processPipeline(graph: ModuleGraph; semNode: PNode; bModule: PPassContext):
of GenDependPass:
result = addDotDependency(bModule, semNode)
of SemPass:
result = graph.emptyNode
# Return the semantic node for cmdM (NIF generation needs it)
# For regular check, we don't need the result
if graph.config.cmd == cmdM:
result = semNode
else:
result = graph.emptyNode
of Docgen2Pass, Docgen2TexPass:
when not defined(leanCompiler):
result = processNode(bModule, semNode)
@@ -275,6 +280,7 @@ proc compilePipelineModule*(graph: ModuleGraph; fileIdx: FileIndex; flags: TSymF
localError(graph.config, unknownLineInfo,
"nim m requires precompiled NIF for import: " & toFullPath(graph.config, fileIdx) &
" (expected: " & nifPath & ")")
return nil # Don't fall through to compile from source
if result == nil and graph.config.cmd != cmdM:
# Fall back to ROD file loading (not used for cmdM which uses NIF only)
result = moduleFromRodFile(graph, fileIdx, cachedModules)
@@ -358,6 +364,10 @@ proc compilePipelineProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIdx
graph.withinSystem = true
discard graph.compilePipelineModule(projectFile, {sfMainModule, sfSystemModule})
graph.withinSystem = false
elif graph.config.cmd == cmdM:
# For cmdM: load system.nim from NIF, don't recompile it
# The import mechanism will load it via moduleFromNifFile
discard graph.compilePipelineModule(projectFile, {sfMainModule})
else:
graph.compilePipelineSystemModule()
discard graph.compilePipelineModule(projectFile, {sfMainModule})