Skip to content

Conversation

@miry
Copy link
Contributor

@miry miry commented Oct 25, 2025

When using --progress, the final step displays [14/13] Codegen (linking),
which incorrectly suggests there are only 13 steps.

$ crystal build --progress

[1/13] Parse                    
[2/13] Semantic (top level)              
[3/13] Semantic (new)                    
[4/13] Semantic (type declarations)      
[5/13] Semantic (abstract def check)     
[6/13] Semantic (restrictions augmenter) 
[7/13] Semantic (ivars initializers)     
[8/13] Semantic (cvars initializers)     
[9/13] Semantic (main)                   
[10/13] Semantic (cleanup)                
[11/13] Semantic (recursive struct check) 
[12/13] Codegen (crystal)                 
[13/13] Codegen (bc+obj)          
[14/13] Codegen (linking)                  

Propose to update the maximum step count to 14 to align with the actual number of stages.

🎩 Tophat

I have tested localy the progress produces:

[1/14] Parse
...
[14/14] Codegen (linking)

@miry miry changed the title fix: correct progress step count to 14 chore: correct progress step count to 14 Oct 25, 2025
When using --progress, the final step displays `[14/13] Codegen (linking)`,
which incorrectly suggests there are only 13 steps.

```shell
$ crystal build --progress

[1/13] Parse
[2/13] Semantic (top level)
[3/13] Semantic (new)
[4/13] Semantic (type declarations)
[5/13] Semantic (abstract def check)
[6/13] Semantic (restrictions augmenter)
[7/13] Semantic (ivars initializers)
[8/13] Semantic (cvars initializers)
[9/13] Semantic (main)
[10/13] Semantic (cleanup)
[11/13] Semantic (recursive struct check)
[12/13] Codegen (crystal)
[13/13] Codegen (bc+obj)
[14/13] Codegen (linking)
```

This commit updates the maximum step count to 14 to align with the actual number of stages.
@miry miry force-pushed the progress-stages-bump branch from 2e55dae to 90b7e2d Compare October 25, 2025 17:08
class ProgressTracker
# FIXME: This assumption is not always true
STAGES = 13
STAGES = 14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: As the comment above points out, the number of steps is not fixed. It depends on the specific compiler settings.
So I'm not sure if it makes much sense to change from one value that can be wrong sometimes to a different one that can also be wrong sometimes.
I guess 14 is right more often than 13 so it's probably an improvement.

Copy link
Contributor

@ysbaddaden ysbaddaden Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be dynamically calculated depending on which command line argument (or refactor the whole thing to use a stages array). There are:

  • 14 stages by default —maybe a stage got added but STAGES wasn't updated?
  • 13 stages when --cross-compile;
  • 11 stages when --no-codegen (regardless of --cross-compile);
  • are there other args that affect progress?
  • crystal tool hierarchy has 7 stages;
  • ...

Using 14 is better as a default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added stage was the restrictions augmenter.

Also on macOS running dsymutil counts as its own extra stage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than maybe it should be the following?

Suggested change
STAGES = 14
STAGES = {{flag?(:darwin) ? 15 : 14}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more like program.has_flag?("darwin") because whether dsymutil is run or not depends on the target, not the host.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, apparently not:

{% if flag?(:darwin) %}
run_dsymutil(output_filename) unless debug.none?
{% end %}

It depends on the dsymutil being available, which probably isn't the case when cross-compiling?

So the entire condition for this stage would be something like {{ flag?(:darwin) }} && !debug.none? && Process.find_executable("dsymutil"). 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could factor this all out and duplicate all the conditions in order to get a final count.

Or we just change it to 14, which is correct most of the time and be fine with that.

Or we simply remove the target value. Let steps just count upwards without saying how many are to be expected. This doesn't tell much anyway because the individual steps are very diverse.

@straight-shoota straight-shoota added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Oct 27, 2025
@straight-shoota straight-shoota added this to the 1.19.0 milestone Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants