Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #13412 nim now recompiles for stdin input; SuccessX now configurable; can show whether it recompiled #13506

Merged
merged 4 commits into from
Mar 19, 2020

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 26, 2020

note

IMO we should simply not support reading from stdin via pipes, Nim is a compiler, it's not for throwaway code.

it's very useful and I use it a lot, lots of modern languages support it, eg python (python -c), D (rdmd --eval) and plenty others
this is very useful when you just want to quickly test a single command without having to open a file just for that;
having 1 liners that can be copy pasted in a shell without further work is quite useful too

Besides, there is already nim secret for that.

that's a different beast, VM code semantics is different from runtime code and there are other differences

@Araq
Copy link
Member

Araq commented Feb 26, 2020

The patch to extccomp is ok, the rest is noisy. How about we report 0 for LOC if it's a cached build? It makes sense, right, if it's cached, we looked at 0 lines of code.

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Feb 26, 2020

I stumbled across this today..

image

I meant to highlight above that echo 'hello' | .. would have failed the nim compilation (because it should have been echo 'echo "hello"' | ..). But it still printed the output of the last successfully compiled stdinfile binary.

Even with corrected echo 'echo "hello"' | .., it still printed the old output. i.e. the stdinfile doesn't get recompiled.

@timotheecour timotheecour force-pushed the pr_fix_13412_nim_stdin_rebuild branch from acb8a61 to 0f91dea Compare February 27, 2020 06:18
@timotheecour
Copy link
Member Author

timotheecour commented Feb 27, 2020

How about we report 0 for LOC if it's a cached build? It makes sense, right, if it's cached, we looked at 0 lines of code.

nah, it's not 0 because of various config files etc; that would be a lie and also not what user wants

The patch to extccomp is ok, the rest is noisy.

found a much better future proof solution, now I can add this to my ~/.config/nim/config.nims (or just use cmd line but that's not practical for that):

--msgs.hintSuccessX:customMsg
eg:
--msgs.hintSuccessX:"$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output recompiled: $projectRecompiled"

and it works exactly the way user wants, without affecting others, and can be later augmented with other fields a specific user may care about
I'm leaving it undocumented for now.

note:

using --msgs.hintSuccessX instead of --msgs.successX since it makes it easier to search in compiler sources

@timotheecour timotheecour force-pushed the pr_fix_13412_nim_stdin_rebuild branch from 0f91dea to b0da397 Compare February 28, 2020 01:38
@timotheecour timotheecour changed the title fix #13412 nim now recompiles for stdin input; SuccessX now indicates whether it recompiled fix #13412 nim now recompiles for stdin input; SuccessX now configurable; can show whether it recompiled Feb 28, 2020
@timotheecour timotheecour force-pushed the pr_fix_13412_nim_stdin_rebuild branch from b0da397 to cb7ffaa Compare March 11, 2020 07:39
@timotheecour timotheecour force-pushed the pr_fix_13412_nim_stdin_rebuild branch from cb7ffaa to dc5811e Compare March 18, 2020 11:51
@timotheecour
Copy link
Member Author

timotheecour commented Mar 18, 2020

ping @Araq (just rebased, no changes, was green already before rebase)

@Clyybber
Copy link
Contributor

Clyybber commented Mar 18, 2020

@timotheecour

The patch to extccomp is ok, the rest is noisy.

Can you restrict this PR to the extccomp patch?

@timotheecour timotheecour force-pushed the pr_fix_13412_nim_stdin_rebuild branch from dc5811e to 8268aa2 Compare March 19, 2020 03:24
@timotheecour
Copy link
Member Author

Can you restrict this PR to the extccomp patch?

done, PTAL (I will revisit the other changes I was making here in another PR as it is useful, there are still existing bugs related to nim not rebuilding when it should, which forces the suboptimal -f in some situations)

@Araq Araq merged commit 1f20424 into nim-lang:devel Mar 19, 2020
@timotheecour timotheecour deleted the pr_fix_13412_nim_stdin_rebuild branch March 19, 2020 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

echo 'echo 1' | nim c -r - silently gives wrong results (nimBetterRun not updated for stdin)
4 participants