Commit Graph

3882 Commits

Author SHA1 Message Date
Andrew Kelley
93c7fa105f Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
Andrew Kelley
dc44fe053c zig cc: detect dynamic linker argument 2020-03-23 12:39:18 -04:00
Andrew Kelley
e643b414e4 zig cc: recognize .S and .C as source file extensions 2020-03-23 11:34:16 -04:00
LemonBoy
0cd953d40e ir: Prevent crash when slicing hardcoded pointer
Closes #4780
2020-03-23 09:13:52 -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
Andrew Kelley
7ffdf59c44 Merge pull request #4774 from ziglang/zig-cc
ability to use `zig cc` as a drop-in C compiler
2020-03-22 19:20:02 -04:00
LemonBoy
6a89751025 ir: Implement cast from anon struct to union 2020-03-22 19:06:22 -04:00
Andrew Kelley
23c263776c Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 15:09:29 -04:00
Andrew Kelley
2b65dc1032 zig cc: detect optimization and debug flags 2020-03-21 22:30:46 -04:00
LemonBoy
dc79f181a5 ir: Disallow comparison between enum literal and untagged enum
Closes #4770
2020-03-21 20:54:05 -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
4d9b458f8f zig cc: support .cc and .cxx extensions 2020-03-21 16:51:43 -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
LemonBoy
128e70ff3a ir: Allow errdefer with payload
Closes #1265
2020-03-21 09:54:49 +01:00
Andrew Kelley
3a2c490889 "generate .h files" feature is no longer supported in stage1 2020-03-20 18:33:36 -04:00
Andrew Kelley
7438d0fc31 glibc: include ld symbols and proper soname for ld 2020-03-20 14:39:05 -04:00
LemonBoy
541e763010 ir: Peer type resolution between ?[]T and *[N]T
Closes #4767
2020-03-20 12:23:05 -04:00
Andrew Kelley
53b5aa812b Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -04:00
Andrew Kelley
160367e0dd fix compile error for reading past end of pointer casted array 2020-03-19 17:23:53 -04:00
Andrew Kelley
1d7861a36e fix incorrect sentinel check 2020-03-19 13:18:14 -04:00
Andrew Kelley
f824658e13 slicing sentinel-terminated slice without end
now results in a sentinel-terminated slice.
2020-03-19 10:54:20 -04:00
Andrew Kelley
7fa88cc0a6 std lib fixups for new semantics
std lib tests are passing now
2020-03-19 09:53:55 -04:00
Andrew Kelley
2164b511cc partial revert of an improvement this branch made
because it uncovered a result location bug, and I need to get this
branch merged before going into a result location rabbit hole.

also fix the result type of slicing when the indexes are runtime known
and the result should be sentinel terminated.
2020-03-19 09:53:55 -04:00
Andrew Kelley
8688c43745 when result loc is a slice, avoid evaluating lazy start..end
This prevents lazy values from being unnecessarily evaluated.
2020-03-19 09:53:55 -04:00
Andrew Kelley
e947f0c740 0-bit array type does not resolve child type 2020-03-19 09:53:55 -04:00
Andrew Kelley
72a261b4d3 fix runtime slice of pointer not setting length 2020-03-19 09:53:55 -04:00
Andrew Kelley
4435b05b6b fix regression when slicing 0-bit pointers 2020-03-19 09:53:55 -04:00
Andrew Kelley
2b4134459d fix alignment when slicing with comptime start and end index 2020-03-19 09:53:54 -04:00
Andrew Kelley
8d0ac6dc4d @ptrCast supports casting a slice to pointer 2020-03-19 09:53:54 -04:00
Andrew Kelley
c896c5001f fix slice of string literal having the wrong type 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
2182d28cb0 slicing with comptime start and end results in array
implements #863
2020-03-19 09:53:51 -04:00
LemonBoy
e3c92d0532 ir: More changes to sentinel-terminated const arrays
* Don't add an extra slot for the sentinel. Most of the code keeps using
  the constant value from the type descriptor, let's harmonize all the
  code dealing with sentinels.

* Properly write out sentinel values when reinterpreting pointers at
  comptime.

* Allow the reading of the 0th element in a `[0:S]T` type.
2020-03-19 09:53:30 -04:00
Andrew Kelley
63a4dbc30d array sentinel does not count towards type_has_one_possible_value 2020-03-18 11:11:41 -04:00
LemonBoy
1479c28b49 ir: Correct ABI size calculation for arrays
Zero-length array with a sentinel may not have zero size.

Closes #4749
2020-03-18 11:10:45 -04:00
momumi
925f710852 make parsing 0.0_e1 an error 2020-03-15 13:05:24 +10:00
momumi
7aac21c6f5 allow _ separators in number literals (stage 1)
* Underscores `_` may be placed between two digits in a int/float literal
* Consecutive underscores are not allowed
* Fixed parsing bug in exponents of hexadecimal float literals.
  Exponents should always be base 10, but hex characters would be parsed
  inside the exponent and everything after them would be ignored. eg:
  `0x1.0p1ab1` would be parsed as `0x1.0p1`.
2020-03-15 12:38:35 +10:00
Andrew Kelley
a77386eb98 for build-obj with only 1 C file, name .o file after root_out_name 2020-03-14 17:11:51 -04:00
Andrew Kelley
4a8e766ef5 fix mismatch between expected and actual output name 2020-03-14 01:26:49 -04:00
Andrew Kelley
66d7370fac special case when doing build-obj with just one source file
When building an object file from only one source file, instead of
having a two-stage cache system, we special case it and use the cache
directory that the .o file is output to as the final cache directory for
all the build artifacts.

When there are more than 1 source file, the linker has to merge objects
into one, and so the two stage approach makes sens. But in the case of
only one source file, this prevents needlessly copying the object file.

This commit fixes an issue with the previous one, where zig with cache
enabled would print a directory that actually did not have any build
artifacts in it.
2020-03-13 23:59:36 -04:00
Andrew Kelley
66e76a0209 zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
Noam Preil
eb4d313dbc Fix compilation with --no-emit-bin 2020-03-13 15:40:29 -04:00
Andrew Kelley
656ba530d8 Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Andrew Kelley
2f06971a7e Merge pull request #4725 from ziglang/update-musl
Upgrade musl libc to 1.2.0
2020-03-12 19:56:38 -04:00
Andrew Kelley
f51bec321b Merge pull request #4707 from Vexu/small-atomics
Support atomic operations with bools and non power of two integers
2020-03-12 18:55:16 -04:00
Andrew Kelley
6e25ac2a2b stage1: update musl libc building code for v1.2.0 2020-03-12 17:45:55 -04:00