Commit Graph

663 Commits (107b5196f65c4e77c6c61ff830d6eb7de8b8842b)

Author SHA1 Message Date
Andrew Kelley 107b5196f6
Merge pull request #4827 from ziglang/zig-cpp
support compiling and linking c++ code
2020-03-27 22:35:13 -04:00
Andrew Kelley a258741084
initial support of response files
See #4833

It doesn't support comments or quotes yet.
2020-03-27 22:24:40 -04:00
Michael Dusan 33819ecfbc windows: don't hard-code forward-slash paths
`zig targets` -> unable to list targets: BadPathName
2020-03-27 21:28:52 -04:00
Andrew Kelley f407109070
zig c++: get it working with musl and mingw-w64 2020-03-27 12:38:52 -04:00
Andrew Kelley db17c0d88c
ability to compile c++ hello world with `zig c++`
closes #4786
2020-03-26 22:48:37 -04:00
Andrew Kelley fae6cf0961
improved handling of native system directories
* `-isystem` instead of `-I` for system include directories
   fixes a problem with native system directories interfering with zig's
   bundled libc.
 * separate Stage2Target.is_native into Stage2Target.is_native_os and
   Stage2Target.is_native_cpu.
2020-03-25 20:34:15 -04:00
Michael Dusan dd66fbb96a
Merge pull request #4811 from mikdusan/fix4634
self-hosted: use fs.selfExePathAlloc
2020-03-25 19:49:52 -04:00
Andrew Kelley e3fec6cce9
zig cc: add detection for `-###`
it turns on --verbose-cc and --verbose-link
2020-03-25 19:32:12 -04:00
Michael Dusan d554070de1
self-hosted: use fs.selfExePathAlloc
- add fs.selfExePathAlloc
- use fs.selfExePathAlloc instead of fs.selfExeDirPathAlloc
- remove redundant code from fs.selfExeDirPath

closes #4634
2020-03-25 18:40:28 -04:00
Andrew Kelley 6cbe589b51
zig cc: support -T linker script option 2020-03-25 12:05:48 -04:00
Andrew Kelley 93c7fa105f
Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
Andrew Kelley 13d04f9963
Merge pull request #4741 from momumi/master
allow `_` separators in number literals (stage 1)
2020-03-23 00:54:54 -04:00
Andrew Kelley 94f7c56001
riscv: add -mrelax arg for C to work around upstream issue
See #4485
2020-03-22 21:47:19 -04:00
Andrew Kelley e5e5196d8e
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 20:48:21 -04:00
momumi 2d18178c27 minor fixes and more tests for _ separators
* Make the tokenizer spit out an Invalid token on the first invalid
  character found in the number literal.
* More parsing and tokenizer tests for number literals
* fix invalid switch statement in ir.zig
2020-03-23 09:21:34 +10:00
Andrew Kelley 23c263776c
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 15:09:29 -04:00
momumi 8de45e5143 update parsing of int literals in self-hosted
* update std.math.big.Int.setString() to ignore underscores and make it
  case insensitive
* fix issue in ir.zig with leading zeroes in integer literals
2020-03-22 13:59:14 +10:00
Andrew Kelley 2b65dc1032
zig cc: detect optimization and debug flags 2020-03-21 22:30:46 -04:00
Andrew Kelley 4b0ddb817b
zig cc: better support for the preprocessor option (-E) 2020-03-21 20:32:48 -04:00
Michael Dusan 28ad78cb7f
rename "passthrough" → "driver_punt"
- punt when `-E` is supplied
- punt when `-S` is supplied
2020-03-21 16:53:59 -04:00
Andrew Kelley 0eee98edc1
zig cc improvements
* The generated options data file is sorted now in a way that
   makes sure longer prefixes are first. This prevents collisions
   with some parameters.
 * Add support for `-fPIC`, `-fno-PIC`, `-nostdlib`, `-shared`,
   `-rdynamic`, `-Wl,-soname`, `-Wl,-rpath`
 * Better support for `-o`.
 * Disable generating h files
 * Shared library support.
 * Better positional argument support.
2020-03-21 15:40:49 -04:00
Andrew Kelley a4eaeee720
ability to use `zig cc` as a drop-in C compiler
The basics are working
2020-03-21 15:39:39 -04:00
Andrew Kelley 7438d0fc31
glibc: include ld symbols and proper soname for ld 2020-03-20 14:39:05 -04:00
Andrew Kelley 53b5aa812b
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -04:00
Andrew Kelley 8ea0a00f40
improve std lib code for the new semantics 2020-03-19 09:53:54 -04:00
Andrew Kelley 0707be8de8
fixes in semantic analysis needed to support this feature 2020-03-19 09:53:54 -04:00
Andrew Kelley 46ffc798b6
fix swapped logic for Windows
Remove `std.fs.deleteTree`. Callers instead should use
`std.fs.cwd().deleteTree`.

Add `std.fs.deleteTreeAbsolute` for when the caller has an absolute
path.
2020-03-18 16:42:47 -04:00
Andrew Kelley 27affde592
(breaking) clarify openDir API
* remove deprecated `std.fs.Dir` APIs
 * `std.fs.Dir.openDir` now takes a options struct with bool fields for
   `access_sub_paths` and `iterate`. It's now much more clear how
   opening directories works.
 * fixed the std lib and various zig code calling the wrong openDir
   function.
 * the runtime safety check for dir flags is removed in favor of the
   cheaper option of putting a comment on the same line as handling
   EBADF / ACCESS_DENIED, since that will show up in stack traces.
2020-03-18 16:10:57 -04:00
Andrew Kelley dbde5df568
clean up some self-hosted bitrot + don't assume libstdc++
closes #4682

The self-hosted compiler is still bit rotted and still not compiling
successfully yet. I have a more serious rework of the code in a
different branch.
2020-03-17 23:03:45 -04:00
Andrew Kelley 656ba530d8
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Andrew Kelley 4905102901
fix all the TODOs from the pull request
* `std.Buffer.print` is removed; use `buffer.outStream().print`
 * `std.fmt.count` returns a `u64`
 * `std.Fifo.print` is removed; use `fifo.outStream().print`
 * `std.fmt.bufPrint` error is renamed from `BufferTooSmall`
   to `NoSpaceLeft` to match `std.os.write`.
 * `std.io.FixedBufferStream.getWritten` returns mutable buffer
   if the buffer is mutable.
2020-03-13 12:02:58 -04:00
Andrew Kelley 2dd920ee39
Merge branch 'format-stream' of https://github.com/fengb/zig into fengb-format-stream 2020-03-13 11:31:11 -04:00
Andrew Kelley aa49f972d6
Merge pull request #4720 from Vexu/translate-c
Translate-c treat C bools as ints
2020-03-12 14:00:07 -04:00
daurnimator 8a22c50c08 Remove unused static_crt_dir field from libc config 2020-03-12 12:27:45 -04:00
Benjamin Feng 4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng ed7f30e1cd Migrate last vestiges of fmt 2020-03-12 10:41:09 -05:00
Benjamin Feng 0059d9ee3e Convert fmt.bufPrint / fmt.allocPrint 2020-03-12 10:41:09 -05:00
Benjamin Feng 4023ed56d4 Convert translate-c to fmtstream 2020-03-12 10:41:09 -05:00
Vexu 02c491e42a
translate-c fix order of tokens 2020-03-12 17:14:01 +02:00
Vexu dda711ba0d
translate-c treat c bools as ints 2020-03-12 14:40:47 +02:00
Andrew Kelley f58705b4a6
fix `zig targets` not reporting native info 2020-03-12 00:33:06 -04:00
Michael Dusan bfebc11d06
fix zig-cache to treat cpu-features as raw-bytes
- add Stage2Target.cache_hash_len
- add cache_mem(ch, ptr, len)
- update call sites to use { ptr, len }
2020-03-11 19:33:12 -04:00
Michael Dusan e0fe0f7f1e
parse CPU features when --target is null
- fixes case where features are not parsed when `-target` is null
- `zig builtin -mcpu native+bogus` should return error/list of valid features
2020-03-11 19:33:10 -04:00
Andrew Kelley d882a30587
fix stage2 lib on windows 2020-03-10 20:51:30 -04:00
Andrew Kelley b6fbd524f1
(breaking) improve and simplify fixed buffer streams API 2020-03-10 16:31:04 -04:00
Andrew Kelley ba0e3be5cf
(breaking) rework stream abstractions
The main goal here is to make the function pointers comptime, so that we
don't have to do the crazy stuff with async function frames.

Since InStream, OutStream, and SeekableStream are already generic
across error sets, it's not really worse to make them generic across the
vtable as well.

See #764 for the open issue acknowledging that using generics for these
abstractions is a design flaw.

See #130 for the efforts to make these abstractions non-generic.

This commit also changes the OutStream API so that `write` returns
number of bytes written, and `writeAll` is the one that loops until the
whole buffer is written.
2020-03-10 15:32:32 -04:00
Vexu cb4c488cbd
translate-c support struct field alignment 2020-03-10 15:57:57 +02:00
Vexu 4cace8f7c3
properly mangle shadowed primitive types 2020-03-10 15:52:54 +02:00
Vexu baec74645d
translate-c add daurnimator's pointer check to macro cast 2020-03-10 15:52:03 +02:00
Vexu 692a974c3e
translate-c reject structs with VLAs 2020-03-08 12:11:37 +02:00