modular / modular/rules_mojo

Different source orders can affect output

Open
#103 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Starlark
Stars
22
Forks
10
PR merge metrics
No merged PRs in 30d

Description

The following targets give different output (aside from file name):

load("//mojo:mojo_library.bzl", "mojo_library")

mojo_library(
    name = "lib1",
    srcs = [
        "__init__.mojo",
        "foo/__init__.mojo",
    ],
)

mojo_library(
    name = "lib2",
    srcs = [
        # do not sort
        "foo/__init__.mojo",
        "__init__.mojo",
    ],
)

We seem to be relying on the fact that srcs[0] is in the root directory, so if the first source is not in the root directory then we only compile a subset of the files.

We could look for the root-most __init__.mojo but I would need to be certain that we can rely on that assumption.

In any case, generally we don't run into this since __init__.mojo always gets sorted to the first item by glob and by buildifier (if specified manually).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mojo_library rule loaded from //mojo:mojo_library.bzl and reproduce the issue using the two source orders shown. Trace how srcs[0] determines compilation, then verify that both orders produce the same output and compile all listed files.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.