156 Commits

Author SHA1 Message Date
Andrew Kelley
e1bf74fca3
translate-c: put -x c back in there, it's necessary 2019-04-25 00:06:58 -04:00
Andrew Kelley
712274997e
translate-c: unify API for self-hosted and C++ translate-c
See #1964
2019-04-25 00:06:57 -04:00
Andrew Kelley
976080462c
translate-c: a little closer to self-hosted implementation 2019-04-25 00:06:54 -04:00
LemonBoy
70c2e86da3 Add translation from pointer to boolean 2019-04-22 22:23:41 +02:00
LemonBoy
8d05330cf7 More precise translation of char literals 2019-04-22 22:23:41 +02:00
LemonBoy
69bc5fd04d translate-c: Pointer to/from integral conversion 2019-04-22 22:16:30 +02:00
LemonBoy
d3dd49c403 translate-c: Support for integer to boolean conversions 2019-04-22 22:16:29 +02:00
LemonBoy
19b8278f91 translate-c: Convert char literals 2019-04-19 11:50:30 +02:00
LemonBoy
6d95c5d15c translate-c: Parse float/double literals 2019-04-19 11:50:30 +02:00
LemonBoy
1fda44cbc8 translate-c: support conversion to/from fp types 2019-04-19 11:50:30 +02:00
Andrew Kelley
4e2f6ebf39
freestanding target adds -ffrestanding to cc parameters
closes #2287
2019-04-16 12:06:14 -04:00
Andrew Kelley
3226b5315e
translate-c: move some code to the C API
See #1964
2019-04-16 04:32:48 -04:00
Andrew Kelley
5cb18e9c6f
translate-c: move some code to the C API
See #1964
2019-04-15 00:32:27 -04:00
Andrew Kelley
9d229791c6
translate-c: move some code to the C API
See #1964
2019-04-12 14:39:12 -04:00
Andrew Kelley
6284a4c534
translate-c: move some code to the C API
See #1964
2019-04-12 03:56:38 -04:00
Andrew Kelley
f860493f23
translate-c: move some code to the C API
See #1964
2019-04-12 03:12:22 -04:00
Andrew Kelley
6f34d08aed
translate-c: move some code to the C API
See #1964
2019-04-11 23:38:41 -04:00
Andrew Kelley
b960f1d922
translate-c: move some code to the C API
See #1964
2019-04-11 15:33:26 -04:00
Andrew Kelley
dff201540f
translate-c: move some code to the C API
See #1964
2019-04-11 03:59:12 -04:00
Andrew Kelley
85256521ba
fix translate-c regression 2019-03-18 20:09:27 -04:00
Andrew Kelley
a581f4f0e2
Merge remote-tracking branch 'origin/master' into llvm8 2019-03-18 20:03:23 -04:00
Andrew Kelley
a17bf219c6
Merge pull request #2069 from ziglang/glibc-assert-translation
Implemented enough of translate-c to translate assert
2019-03-18 14:43:17 -04:00
Jimmi Holst Christensen
9171e7a7c1 More work on ignoring values correctly 2019-03-18 14:55:57 +01:00
Jimmi HC
5ae400fb39 fixed void cast and added the last tests 2019-03-15 19:11:46 +01:00
Jimmi Holst Christensen
a77b2a0810 Implemented enough of translate-c to translate assert
This required the following
* __extention__
* ({})
* Fixing if (0) ; else ;
2019-03-15 16:12:41 +01:00
Jimmi Holst Christensen
3ef9b899e4 workaround for #2043 2019-03-15 11:17:21 +01:00
Andrew Kelley
3cdd2c0bdd Merge remote-tracking branch 'origin/master' into llvm8 2019-03-10 13:48:06 -04:00
Andrew Kelley
91955dee58
breaking changes to zig build API and improved caching
* in Zig build scripts, getOutputPath() is no longer a valid function
   to call, unless setOutputDir() was used, or within a custom make()
   function. Instead there is more convenient API to use which takes
   advantage of the caching system. Search this commit diff for
   `exe.run()` for an example.
 * Zig build by default enables caching. All build artifacts will go
   into zig-cache. If you want to access build artifacts in a convenient
   location, it is recommended to add an `install` step. Otherwise
   you can use the `run()` API mentioned above to execute programs
   directly from their location in the cache. Closes #330.
   `addSystemCommand` is available for programs not built with Zig
   build.
 * Please note that Zig does no cache evicting yet. You may have to
   manually delete zig-cache directories periodically to keep disk
   usage down. It's planned for this to be a simple Least Recently
   Used eviction system eventually.
 * `--output`, `--output-lib`, and `--output-h` are removed. Instead,
   use `--output-dir` which defaults to the current working directory.
   Or take advantage of `--cache on`, which will print the main output
   path to stdout, and the other artifacts will be in the same directory
   with predictable file names. `--disable-gen-h` is available when
   one wants to prevent .h file generation.
 * `@cImport` is always independently cached now. Closes #2015.
   It always writes the generated Zig code to disk which makes debug
   info and compile errors better. No more "TODO: remember C source
   location to display here"
 * Fix .d file parsing. (Fixes the MacOS CI failure)
 * Zig no longer creates "temporary files" other than inside a
   zig-cache directory.

This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-08 23:23:11 -05:00
Andrew Kelley
2caf39c961 fix .d file processing and use -MV to quote spaces 2019-03-07 14:30:50 -05:00
Andrew Kelley
ce76de35f1
multi-arch glibc headers 2019-03-07 12:16:10 -05:00
Andrew Kelley
e06da10838
fix translate-c 2019-03-05 16:12:19 -05:00
Andrew Kelley
aeb16010f3
initial glibc support 2019-03-04 22:15:53 -05:00
Andrew Kelley
0714e19598
Merge remote-tracking branch 'origin/master' into llvm8 2019-03-04 08:24:56 -05:00
Andrew Kelley
5424b4320d
remove namespace type; files are empty structs
closes #1047
2019-02-28 10:11:32 -05:00
Andrew Kelley
6bc19b437c
updates to build with llvm 8.0.0rc3 2019-02-28 09:55:27 -05:00
Andrew Kelley
2dcf1a2392
Merge remote-tracking branch 'origin/master' into llvm8 2019-02-28 09:19:18 -05:00
Andrew Kelley
6365f5a9f3 introduce sys_include_dir for when sys/* files are not with stdlib.h 2019-02-26 17:26:34 -05:00
Andrew Kelley
33174f11ef fix regressions on Windows 2019-02-26 16:24:32 -05:00
Andrew Kelley
1ec1097bd3
use -nostdinc and sometimes -nolibc when compiling C code 2019-02-26 14:59:36 -05:00
Andrew Kelley
6fd2816431
use -nostdinc++ when compiling C code 2019-02-26 10:15:48 -05:00
Andrew Kelley
3932b6474e
use -nobuiltininc when compiling c code 2019-02-26 08:16:03 -05:00
Andrew Kelley
0d4db8828a
@cImport works with --cache on
We pass -MD -MF args to clang when doing `@cImport`, which
gives us a complete list of files that the C code read from.
Then we add these to the cache. So even when using `@cImport`
Zig's caching system remains perfect. This is a proof of concept
for the mechanism that the self-hosted compiler will use to
watch and rebuild files.
2019-02-25 14:03:36 -05:00
Andrew Kelley
6fd8d455bc
better libc detection (#1996)
* better libc detection

This introduces a new command `zig libc` which prints
the various paths of libc files. It outputs them to stdout
in a simple text file format that it is capable of parsing.
You can use `zig libc libc.txt` to validate a file.

These arguments are gone:
--libc-lib-dir [path]        directory where libc crt1.o resides
--libc-static-lib-dir [path] directory where libc crtbegin.o resides
--msvc-lib-dir [path]        (windows) directory where vcruntime.lib resides
--kernel32-lib-dir [path]    (windows) directory where kernel32.lib resides

Instead we have this argument:
--libc [file]                Provide a file which specifies libc paths

This is used to pass a libc text file (which can be generated with
`zig libc`). So it is easier to manage multiple cross compilation
environments.

`--cache on` now works when linking against libc.

`ZigTarget` now has a bool field `is_native`

Better error messaging when you try to link against libc or use
`@cImport` but the various paths cannot be found. It should also be
faster.

* save native_libc.txt in zig-cache

This avoids having to detect libc at runtime on every invocation.
2019-02-23 09:35:56 -05:00
LemonBoy
e280dce30f Translate parameterless C functions (#1978)
Both FunctionNoProto and FunctionProto are subclasses of FunctionType,
the only difference is that the former is parameterless.
2019-02-18 10:26:45 -05:00
LemonBoy
6cf38369d2 Silence gcc8 class-memaccess warnings
Use an explicit cast to tell gcc we know what we're doing.
2019-02-17 14:40:01 -05:00
Andrew Kelley
c3c92ca8b1
translate-c: 4 more functions using C decls
See #1964
2019-02-16 19:48:39 -05:00
Andrew Kelley
2dfa76a1a7 fix regressions from previous commit when building with clang 2019-02-16 16:17:30 -05:00
Andrew Kelley
356cfa08f4
translate-c: proof of concept for transitioning to userland
See #1964
2019-02-16 15:26:44 -05:00
Andrew Kelley
f4c5bcfea5
refactor translate-c - no more using namespace clang
this is in preparation for #1964
2019-02-16 14:09:00 -05:00
Andrew Kelley
f57182456d
Merge pull request #1898 from Sahnvour/translate-c-arrays
Translate c arrays
2019-02-16 14:07:41 -05:00