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

use zig as a c compiler #490

Closed
andrewrk opened this issue Sep 17, 2017 · 3 comments · Fixed by #2003
Closed

use zig as a c compiler #490

andrewrk opened this issue Sep 17, 2017 · 3 comments · Fixed by #2003
Labels
accepted This proposal is planned. enhancement Solving this issue will likely involve adding new logic or components to the codebase. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Sep 17, 2017

zig cc foo.c

All args after cc are args exactly as you would pass to clang. We depend on libclang, might as well expose it.

In the std build API, the default way to compile C code would be with this, instead of with an external compiler. Using an external compiler is still useful and supported, however.

Being a C++ compiler is a little tricker, since we would need to know the location of libstdc++ in addition to libc, and all the weird versioning stuff that goes along with it.

@andrewrk andrewrk added accepted This proposal is planned. enhancement Solving this issue will likely involve adding new logic or components to the codebase. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. labels Sep 17, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Sep 17, 2017
@PavelVozenilek
Copy link

There should be some macro identifying that it is "zig compiler" and its version.

@andrewrk
Copy link
Member Author

Sure, we can do:

#define __zig__ 1
#define __zig_version__ "0.0.0"
#define __zig_major__ 0
#define __zig_minor__ 0
#define __zig_patchlevel__ 0

to match clang. The corresponding clang defines will still exist.

@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Dec 8, 2017
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
tiehuis added a commit that referenced this issue Apr 12, 2018
Commands are now separated more precisely from one another. Arguments
are parsed mostly using a custom argument parser instead of manually.
This should be on parity feature-wise with the previous main.zig but
adds a few extra code-paths as well that were not yet implemented.

Subcommands are much more prominent and consistent. The first argument
is always a sub-command and then all following arguments refer to that
command. Different commands display there own usage messages and options
based on what they can do instead of a one-for-all usage message that
was only applicable for the build commands previously.

The `cc` command is added and is intended for driving a c compiler. See #490.
This is currently a wrapper over the system cc and assumes that it
exists, but it should suffice as a starting point.
andrewrk added a commit that referenced this issue Feb 24, 2019
@hostilefork
Copy link

@andrewrk said:

Sure, we can do:

 #define __zig__ 1

This doesn't seem to be the case when using zig cc in version 0.11.0-dev.3883+7166407d8.

Is there another approved way to detect compilation under zig?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. enhancement Solving this issue will likely involve adding new logic or components to the codebase. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants