@@ -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