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

add a "check only" compiler flag to get compiler errors without emitting build artifacts #3036

Closed
kevinw opened this issue Aug 9, 2019 · 5 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@kevinw
Copy link

kevinw commented Aug 9, 2019

Having the compiler check your code for errors without emitting code would be very useful for IDEs and text editors with IDE-like plugins.

Something like:

zig check src/main.zig

Another possibility could be that you have to add a "check" task to your build.zig, but you set some kind of "null" target.

@andrewrk andrewrk added this to the 0.6.0 milestone Aug 9, 2019
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Aug 9, 2019
@andrewrk
Copy link
Member

andrewrk commented Aug 9, 2019

Thanks for filing the issue for this.

It needs to be a flag to one of the other build commands, and there does have to be a target. Consider this code:

if (builtin.os == .windows and otherCondition()) {
    @compileError("something went wrong");
}

Zig also needs to know whether e.g. pub fn main() is an entry point or not based on build
exe, build-obj, build-lib. So those still need to be the command names.

So this will look like an additional flag, for example --check-only. (If anyone knows the names of the equivalent flags from, e.g. clang or java please let me know so we can match that standard name)

Related issue: #3028

@andrewrk andrewrk changed the title zig check to get compiler errors without emitting code add a "check only" compiler flag to get compiler errors without emitting build artifacts Aug 9, 2019
@iguessthislldo
Copy link

(If anyone knows the names of the equivalent flags from, e.g. clang or java please let me know so we can match that standard name)

The clang and GCC option for this is -fsyntax-only. I copied this term in a work project project as --syntax-only.

@zimmi
Copy link
Contributor

zimmi commented Aug 9, 2019

The Java compiler (javac) doesn't support this feature. Running the JVM via java supports --dry-run.

@daurnimator
Copy link
Collaborator

--dry-run is a common flag for this across various tools

@andrewrk
Copy link
Member

This is now supported with -fno-emit-bin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

5 participants