Skip to content

Commit 5fc7fea

Browse files
committed
progress
1 parent ce4d75c commit 5fc7fea

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

compiler/ast2nif.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ proc nifLineInfo(w: var LineInfoWriter; info: TLineInfo): PackedLineInfo =
5252
result = NoLineInfo
5353
else:
5454
let fid = get(w, info.fileIndex)
55-
result = pack(w.man, fid, info.line.int32, info.col)
55+
# Must use pool.man since toString uses pool.man to unpack
56+
result = pack(pool.man, fid, info.line.int32, info.col)
5657

5758
proc oldLineInfo(w: var LineInfoWriter; info: PackedLineInfo): TLineInfo =
5859
if info == NoLineInfo:
5960
result = unknownLineInfo
6061
else:
61-
var x = unpack(w.man, info)
62+
var x = unpack(pool.man, info)
6263
var fileIdx: FileIndex
6364
if w.fileV == x.file:
6465
fileIdx = w.fileK

compiler/main.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ proc mainCommand*(graph: ModuleGraph) =
420420
of cmdCheck:
421421
commandCheck(graph)
422422
of cmdM:
423-
graph.config.symbolFiles = v2Sf
424-
setUseIc(graph.config.symbolFiles != disabledSf)
423+
# cmdM uses NIF files, not ROD files
424+
graph.config.symbolFiles = disabledSf
425+
setUseIc(false)
425426
commandCheck(graph)
426427
of cmdParse:
427428
wantMainModule(conf)

compiler/nim.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
118118
if conf.selectedGC == gcUnselected:
119119
if conf.backend in {backendC, backendCpp, backendObjc} or
120120
(conf.cmd in cmdDocLike and conf.backend != backendJs) or
121-
conf.cmd == cmdGendepend:
121+
conf.cmd == cmdGendepend or
122+
conf.cmd == cmdM:
122123
initOrcDefines(conf)
123124

124125
mainCommand(graph)

compiler/pipelines.nim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ proc processPipeline(graph: ModuleGraph; semNode: PNode; bModule: PPassContext):
3838
of GenDependPass:
3939
result = addDotDependency(bModule, semNode)
4040
of SemPass:
41-
result = graph.emptyNode
41+
# Return the semantic node for cmdM (NIF generation needs it)
42+
# For regular check, we don't need the result
43+
if graph.config.cmd == cmdM:
44+
result = semNode
45+
else:
46+
result = graph.emptyNode
4247
of Docgen2Pass, Docgen2TexPass:
4348
when not defined(leanCompiler):
4449
result = processNode(bModule, semNode)
@@ -275,6 +280,7 @@ proc compilePipelineModule*(graph: ModuleGraph; fileIdx: FileIndex; flags: TSymF
275280
localError(graph.config, unknownLineInfo,
276281
"nim m requires precompiled NIF for import: " & toFullPath(graph.config, fileIdx) &
277282
" (expected: " & nifPath & ")")
283+
return nil # Don't fall through to compile from source
278284
if result == nil and graph.config.cmd != cmdM:
279285
# Fall back to ROD file loading (not used for cmdM which uses NIF only)
280286
result = moduleFromRodFile(graph, fileIdx, cachedModules)
@@ -358,6 +364,10 @@ proc compilePipelineProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIdx
358364
graph.withinSystem = true
359365
discard graph.compilePipelineModule(projectFile, {sfMainModule, sfSystemModule})
360366
graph.withinSystem = false
367+
elif graph.config.cmd == cmdM:
368+
# For cmdM: load system.nim from NIF, don't recompile it
369+
# The import mechanism will load it via moduleFromNifFile
370+
discard graph.compilePipelineModule(projectFile, {sfMainModule})
361371
else:
362372
graph.compilePipelineSystemModule()
363373
discard graph.compilePipelineModule(projectFile, {sfMainModule})

0 commit comments

Comments
 (0)