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

Compiler does not detect source files overwritten by --emit #13427

Open
HertzDevil opened this issue May 3, 2023 · 1 comment
Open

Compiler does not detect source files overwritten by --emit #13427

HertzDevil opened this issue May 3, 2023 · 1 comment

Comments

@HertzDevil
Copy link
Contributor

The compiler detects whether a Crystal source file will be overwritten by the executable if an output filename is not explicitly given; #13370 makes this work on Windows and extends it to the object file after cross-compilation. But it doesn't cover the extra files generated by the --emit options (which are produced even when running a file, not just building):

$ echo 1 > test.ll
$ crystal build --cross-compile --target=x86_64-linux-gnu --emit=llvm-ir test.ll

This overwrites test.ll. The compiler should be able to take care of this too.

Speaking of which, is --cross-compile --emit=obj entirely redundant?

@straight-shoota
Copy link
Member

I guess. But this seems like a very weird and unlikely use case. It only matters if a source file has the file extension .ll which violates the convention to name Crystal source files .cr.

This is different with binary outputs because a) you can select the output path and .cr extension is not that unlikely due to many shards having that in their name and b) source files sometimes omit the file extension to make them easily callable as an ad-hoc compiled program (via she-bang).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants