diff --git a/compiler/ast2nif.nim b/compiler/ast2nif.nim index 34eabd81cf..b91dc4956e 100644 --- a/compiler/ast2nif.nim +++ b/compiler/ast2nif.nim @@ -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 diff --git a/compiler/main.nim b/compiler/main.nim index 377c85b6e1..da6ae82ce7 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -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) diff --git a/compiler/nim.nim b/compiler/nim.nim index 005f11a580..319844c62d 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -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) diff --git a/compiler/pipelines.nim b/compiler/pipelines.nim index ac17160aa3..2ef0c60e22 100644 --- a/compiler/pipelines.nim +++ b/compiler/pipelines.nim @@ -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})