Commit Graph

2198 Commits (d45ea4d89d7232fc4bcf56a5e088d7d6b5004ebb)

Author SHA1 Message Date
Andrew Kelley 3c3316d4ba
update tests to new Target API 2020-02-28 14:51:55 -05:00
Andrew Kelley 0912484c4f
improve the "external executor" detection logic 2020-02-28 14:51:54 -05:00
Andrew Kelley dbe4d72bcf
separate std.Target and std.zig.CrossTarget
Zig now supports a more fine-grained sense of what is native and what is
not. Some examples:

This is now allowed:
-target native

Different OS but native CPU, default Windows C ABI:
-target native-windows
This could be useful for example when running in Wine.

Different CPU but native OS, native C ABI.
-target x86_64-native -mcpu=skylake

Different C ABI but otherwise native target:
-target native-native-musl
-target native-native-gnu

Lots of breaking changes to related std lib APIs.
Calls to getOs() will need to be changed to getOsTag().
Calls to getArch() will need to be changed to getCpuArch().

Usage of Target.Cross and Target.Native need to be updated to use
CrossTarget API.

`std.build.Builder.standardTargetOptions` is changed to accept its
parameters as a struct with default values. It now has the ability to
specify a whitelist of targets allowed, as well as the default target.
Rather than two different ways of collecting the target, it's now always
a string that is validated, and prints helpful diagnostics for invalid
targets. This feature should now be actually useful, and contributions
welcome to further improve the user experience.

`std.build.LibExeObjStep.setTheTarget` is removed.
`std.build.LibExeObjStep.setTarget` is updated to take a CrossTarget
parameter.

`std.build.LibExeObjStep.setTargetGLibC` is removed. glibc versions are
handled in the CrossTarget API and can be specified with the `-target`
triple.

`std.builtin.Version` gains a `format` method.
2020-02-28 14:51:54 -05:00
Andrew Kelley 87b9e744dd
update std lib to new Target API 2020-02-28 14:51:54 -05:00
Andrew Kelley 4616af0ca4
introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Andrew Kelley fba39ff331
restructuring std.Target for OS version ranges, pass 1 2020-02-28 14:51:50 -05:00
Andrew Kelley c39d7a6326
fix exported variable not respecting linkage 2020-02-27 11:51:43 -05:00
LemonBoy 2696c8b42d ir: Robust checking for init expr type
Closes #3979
2020-02-27 10:40:22 -05:00
LemonBoy fd1eade4ca ir: Allow empty inferred error sets
Closes #4564
2020-02-26 21:02:22 -05:00
Vexu 22432b15e3
add test for `@intToEnum` 2020-02-26 11:19:40 -05:00
Vexu d505ea6caf
fix `@tagName` on extern and non-exhaustive enums 2020-02-26 11:19:39 -05:00
Andrew Kelley c4a2734aa0
Merge pull request #4561 from LemonBoy/fix-4536-1
Resend of #4552
2020-02-26 11:11:28 -05:00
Andrew Kelley aa2aad229c
Merge pull request #4497 from LemonBoy/do-do-do
The great stack-trace race (Part 1 of N)
2020-02-26 11:10:38 -05:00
LemonBoy d2535c003c ir: Fix regression with self-referencing containers 2020-02-26 10:05:04 +01:00
Andrew Kelley a55e536391
fix typo in previous commit
oops, forgot to actually run the test
2020-02-25 21:32:03 -05:00
Andrew Kelley e75598af3d
add test case to catch regression from previous commit
Once this test case is passing, previous commit can be re-added.

Closes #4560
2020-02-25 21:24:27 -05:00
Andrew Kelley dad62a7e27
Revert "ir: Fix sizeOf comparison with ptr to zst"
This reverts commit 89812217b4.

This caused #4560
2020-02-25 21:23:35 -05:00
LemonBoy e9bac8be6b ir: Fix array to slice conversion for zero-sized arrays
Closes #3848
2020-02-25 17:40:01 -05:00
LemonBoy 55ea855e2c ir: Various fixes for comptime ptr handling
* Correctly fold ptrToInt on optional types
* Generate null as ConstPtrSpecialNull in intToPtr
* Correctly stop ptrToInt on ?*T where T is zero-sized

Closes #4535
2020-02-25 17:38:56 -05:00
LemonBoy 89812217b4 ir: Fix sizeOf comparison with ptr to zst
Closes #4536
2020-02-25 17:36:54 -05:00
LemonBoy b46efcde82 ir: Fix sizeOf comparison with ptr to zst
Closes #4536
2020-02-25 12:48:08 +01:00
Vexu d56115ef41
remove `@IntType` and `@ArgType` (mostly) from the compiler 2020-02-25 01:27:34 +02:00
Vexu 538d9a5dd8
remove uses of `@ArgType` and `@IntType` 2020-02-24 23:39:03 +02:00
Vexu 45da72c5b6
remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType` 2020-02-24 23:09:01 +02:00
Andrew Kelley 1d06c82c3b
Merge pull request #4516 from xackus/remove-bytes-to-slice
remove @bytesToSlice, @sliceToBytes from the language
2020-02-24 13:51:47 -05:00
LemonBoy 08047cd6d7 correct test expectations 2020-02-23 22:47:48 +01:00
xackus 7664c3bc11 remove @bytesToSlice, @sliceToBytes from tests, docs 2020-02-23 18:03:50 +01:00
Andrew Kelley 570973761a
add regression test for already fixed bug
closes #3586
2020-02-21 15:31:00 -05:00
Andrew Kelley 2de7d0b10c
fix zig build, ABI ABI, and update tests to new Target layout 2020-02-20 18:50:20 -05:00
Andrew Kelley 903127f36c
Merge remote-tracking branch 'origin/master' into sub-architecture-annihilation 2020-02-20 18:36:04 -05:00
Andrew Kelley 0f016b368d
support -mcpu=baseline, both in stage1 and stage2
See e381a42de9 for more details.
This is set up so that if we wish to make "baseline" depend on the
OS in the future, it is possible to do that.
2020-02-20 18:31:17 -05:00
Andrew Kelley b0d2ebe529 remove std.io.readLine
This was deceptive. It was always meant to be sort of a "GNU readline"
sort of thing where it provides a Command Line Interface to input text.
However that functionality did not exist and it was basically a red
herring for people trying to read line-delimited input from a stream.

In this commit the API is deleted, so that people can find the proper
API more easily.

A CLI text input abstraction would be useful but may not even need to be
in the standard library. As you can see in this commit, the guess_number
CLI game gets by just fine by using `std.fs.File.read`.
2020-02-20 15:30:00 -05:00
LemonBoy a385547786 ir: Compile error on result_loc type mismatch w/ slicing
Closes #4508
2020-02-20 13:14:19 +01:00
Andrew Kelley 84f1893c18
remove the concept of "sub-architecture"
in favor of CPU features. Also rearrange the `std.Target`
data structure.

 * note: `@import("builtin")` was already deprecated in favor of
   `@import("std").builtin`.
 * `std.builtin.arch` is now deprecated in favor of
   `std.builtin.cpu.arch`.
 * `std.Target.CpuFeatures.Cpu` is now `std.Target.Cpu.Model`.
 * `std.Target.CpuFeatures` is now `std.Target.Cpu`.
 * `std.Target` no longer has an `arch` field. Instead it has a
   `cpu` field, which has `arch`, `model`, and `features`.
 * `std.Target` no longer has a `cpu_features` field.
 * `std.Target.Arch` is moved to `std.Target.Cpu.Arch` and
   it is an enum instead of a tagged union.
 * `std.Target.parseOs` is moved to `std.Target.Os.parse`.
 * `std.Target.parseAbi` is moved to `std.Target.Abi.parse`.
 * `std.Target.parseArchSub` is only for arch now and moved
    to `std.Target.Cpu.Arch.parse`.
 * `std.Target.parse` is improved to accept CPU name and features.
 * `std.Target.Arch.getBaselineCpuFeatures` is moved to
   `std.Target.Cpu.baseline`.
 * `std.Target.allCpus` is renamed to `std.Target.allCpuModels`.
 * `std.Target.defaultAbi` is moved to `std.Target.Abi.default`.
 * Significant cleanup of aarch64 and arm CPU features, resulting in
   the needed bit count for cpu feature set going from 174 to 138.
 * Add `std.Target.Cpu.Feature.Set.addFeatureSet` for merging
   feature sets together.

`-target-feature` and `-target-cpu` are removed in favor of
`-mcpu`, to conform to established conventions, and it gains
additional power to support cpu features. The syntax is:
-mcpu=name+on1+on2-off1-off2

closes #4261
2020-02-19 21:30:36 -05:00
Andrew Kelley 63383a8af8
consistent capitalization of error message 2020-02-19 01:24:19 -05:00
Andrew Kelley 30194f27fb
update new test case to take into account lazy `@typeInfo` 2020-02-18 18:27:18 -05:00
LemonBoy a6b74cdd38
stage1: Make the parser reject extern fn with body 2020-02-18 18:18:29 -05:00
Andrew Kelley ccca4b5a5e
Merge pull request #4474 from LemonBoy/saukerkraut
Patches
2020-02-18 18:15:11 -05:00
Andrew Kelley dd58278dbe
add behavior test for previous commit 2020-02-18 15:28:14 -05:00
Timon Kruiper 7560fc716d
Makes the declaration slice resolve lazely when using `@typeInfo`
This way all the declarations in a container won't be resolved untill
the user actually uses the decls slice in the builtin TypeInfo union.
2020-02-18 15:26:37 -05:00
LemonBoy 6b74fd2e12 ir: Avoid invalidating the decl_table iterator
Collect the declarations to resolve first and run resolve_top_level_decl
on them later.

Closes #4310
2020-02-16 21:14:30 +01:00
LemonBoy 096f79260b ir: Prevent crash when indexing undefined ptr to array
Closes #4471
2020-02-16 19:53:53 +01:00
Andrew Kelley 7f7d1fbe5a
Implement noasync awaits
Note that there is not yet runtime safety for this.

See #3157
2020-02-16 01:44:52 -05:00
Andrew Kelley cb3a818699
zig fmt: support `noasync await` 2020-02-16 01:44:52 -05:00
Andrew Kelley 72805fd66e
fix taking address of temporary async frame 2020-02-16 01:44:49 -05:00
Vexu b15958c557 fix c tokenizer bug 2020-02-14 18:57:57 -05:00
Andrew Kelley 9e1afdc234
Merge pull request #4454 from LemonBoy/capture-reform
Payload captures no longer alias the original value
2020-02-14 14:39:00 -05:00
LemonBoy 1c8ac2a0c1 test: Add test cases for the new capture behavior 2020-02-14 15:59:28 +01:00
Vexu 9206f8a8cd translate-c improve macro cast translation 2020-02-14 09:36:44 -05:00
Andrew Kelley e8dfc5e7f6
Merge pull request #4442 from fengb/testing-allocator-calls
Migrate tests from FixedBufferAllocator to testing.allocator
2020-02-13 16:17:21 -05:00