80 Commits

Author SHA1 Message Date
LemonBoy
9b7d9c72b0 stage1: Initial implementation of @extern 2020-11-20 22:32:43 +01:00
Tadeo Kondrak
25ec2dbc1e Add builtin.Signedness, use it instead of is_signed 2020-11-19 18:59:21 +02:00
Veikka Tuominen
ee1d21bbef
Merge pull request #6649 from Rocknest/verparse
make Version.parse less strict
2020-11-18 16:06:52 +02:00
LemonBoy
0d6a7088dc stage1: Implement Add/Mul reduction operators 2020-11-01 14:30:31 -07:00
Rocknest
39841d5e2c remove workaround 2020-10-12 15:18:50 +03:00
Rocknest
47d7bf1a0e add a test for Version.parse 2020-10-11 16:30:51 +03:00
Rocknest
cd4200ccef make Version.parse less strict 2020-10-11 16:29:19 +03:00
Andrew Kelley
95a37373e9
Merge pull request #6421 from tadeokondrak/opaque-syntax
Add opaque syntax that allows declarations
2020-10-07 16:58:50 -04:00
Tadeo Kondrak
0a6863a267 Remove .Cold calling convention.
This isn't a stable, defined calling convention, so it shouldn't be
grouped in with the others.

Closes https://github.com/ziglang/zig/issues/6556
2020-10-07 04:31:20 -04:00
Tadeo Kondrak
069fbb3c01
Add opaque type syntax 2020-10-06 22:08:24 -06:00
LemonBoy
22b5e47839 stage1: Implement @reduce builtin for vector types
The builtin folds a Vector(N,T) into a scalar T using a specified
operator.

Closes #2698
2020-10-05 04:51:45 -04:00
Tadeo Kondrak
183d1d4ba1
Switch TypeInfo.Fn.alignment to comptime_int from u29
All integers in TypeInfo are intentionally comptime_int:
https://github.com/ziglang/zig/issues/1683
2020-10-01 18:01:41 -06:00
Tadeo Kondrak
97ab720d84
stage1: Add alignment to TypeInfo.Fn 2020-10-01 17:59:42 -06:00
Tadeo Kondrak
a12203d2be
Switch TypeInfo alignment fields from u29 to comptime_int 2020-10-01 15:01:28 -06:00
Tadeo Kondrak
d81648ce8c
Add alignment field to TypeInfo.UnionField and TypeInfo.StructField
Closes https://github.com/ziglang/zig/issues/6122
2020-10-01 15:01:25 -06:00
Tadeo Kondrak
77df5dae7f
Make builtin.TypeInfo.Pointer.alignment u29 instead of comptime_int 2020-10-01 15:01:24 -06:00
Tadeo Kondrak
ff2ed966bb
Implement @Type for Union
This removes TypeInfo.UnionField.enum_field, which is redundant with
TypeInfo.Union.tag_type.
2020-09-07 06:23:24 -06:00
Tadeo Kondrak
1b2154dfe2 builtin: Add TypeInfo.StructField.is_comptime 2020-09-02 00:17:59 -04:00
Tadeo Kondrak
a049c31f21 Remove TypeInfo.Error.value 2020-08-22 03:20:12 -04:00
Andrew Kelley
776bfb0ee6
Merge pull request #6099 from tadeokondrak/@Type(.Struct)
Implement @Type for structs
2020-08-20 16:57:10 -04:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Tadeo Kondrak
0f677810ea
Remove offset field from TypeInfo.StructField
This isn't needed with @bitOffsetOf/@byteoffsetOf and complicates
@Type handling.
2020-08-19 14:55:40 -06:00
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04:00
Andrew Kelley
20510d209b GeneralPurposeAllocator: use std.log instead of std.debug.print
`std.builtin.StackTrace` gains a `format` function.

GeneralPurposeAllocator uses `std.log.err` instead of directly printing
to stderr. Some errors are recoverable.

The test runner is modified to fail the test run if any log messages of
"err" or worse severity are encountered.

self-hosted is modified to always print log messages of "err" severity
or worse even if they have not been explicitly enabled.

This makes GeneralPurposeAllocator available on the freestanding target.
2020-08-11 02:01:32 -04:00
Vexu
a1e78d0b06
add is_tuple field to struct typeinfo
part of #4335
2020-07-17 00:15:34 +03:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Andrew Kelley
c70633eacd
Merge pull request #5203 from tadeokondrak/@type-for-even-more-types
implement @typeInfo for Frame and implement @Type for Frame, EnumLiteral, and ErrorSet
2020-06-18 21:25:03 -04:00
Andrew Kelley
4a38799631 make file and fn_name fields of SourceLocation also null-terminated
One of the main motivating use cases for this language feature is
tracing/profiling tools, which expect null-terminated strings for these
values. Since the data is statically allocated, making them
additionally null-terminated comes at no cost.

This prevents the requirement of compile-time code to convert to
null-termination, which could increase the compilation time of
code with tracing enabled.

See #2029
2020-06-18 17:09:10 -04:00
Vexu
a5379aa3ee
implement @src 2020-06-18 21:11:09 +03:00
Tadeo Kondrak
a62e9bc8e5
Implement @Type for ErrorSet 2020-05-02 14:39:32 -06:00
Tadeo Kondrak
647901b4a8
Constify TypeInfo 2020-05-02 14:39:31 -06:00
Tadeo Kondrak
ca6db2d008
Implement @Type() for EnumLiteral and FnFrame 2020-05-02 14:39:28 -06:00
xackus
cd20e0cc67 rename mem.separate to mem.split 2020-04-04 17:37:51 -04:00
Andrew Kelley
656ba530d8
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Benjamin Feng
4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng
0fbccec000 Convert builtin to fmtstream 2020-03-12 10:41:04 -05:00
Andrew Kelley
96c07674fc
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-07 12:18:41 -05:00
Andrew Kelley
fa46bcb368
stage1: make get_optional_type more robust
Now it will emit a compile error rather than crashing when the child
type has not been resolved properly.

Introduces `get_optional_type2` which should be used generally inside
ir.cpp.

Fix some std lib compile errors noticed by the provided test case.

Thanks @LemonBoy for the test case. Closes #4377.

Fixes #4374.
2020-03-06 18:30:30 -05:00
Andrew Kelley
d1cb16aace
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -05:00
Andrew Kelley
5b26128bac
add new functions to std.mem and deprecate others
add std.mem.Span
add std.mem.span
add std.mem.length
add std.mem.indexOfSentinel

deprecate std.mem.len
deprecate std.mem.toSlice
deprecate std.mem.toSliceConst
2020-03-01 13:07:55 -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
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
f33bf48af7
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05: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
cdc5070f21
Merge remote-tracking branch 'origin/master' into llvm10 2020-02-10 00:26:33 -05:00
Andrew Kelley
0b5bcd2f56
more std lib async I/O integration
* `zig test` gainst `--test-evented-io` parameter and gains the ability
   to seamlessly run async tests.
 * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when
   using evented I/O
 * `std.io.getStdErr()` gives a File that is blocking even in evented
   I/O mode.
 * Delete `std.event.fs`. The functionality is now merged into `std.fs`
   and async file system access (using a dedicated thread) is
   automatically handled.
 * `std.fs.File` can be configured to specify whether its handle is
   expected to block, and whether that is OK to block even when in
   async I/O mode. This makes async I/O work correctly for e.g. the
   file system as well as network.
 * `std.fs.File` has some deprecated functions removed.
 * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
   to `std.os` and `std.fs.File`. They are all integrated with async
   I/O.
 * `std.fs.Watch` is still bit rotted and needs to be audited in light
   of the new async/await syntax.
 * `std.io.OutStream` integrates with async I/O
 * linked list nodes in the std lib have default `null` values for
   `prev` and `next`.
 * Windows async I/O integration is enabled for reading/writing file
   handles.
 * Added `std.os.mode_t`. Integer sizes need to be audited.
 * Fixed #4403 which was causing compiler to crash.

This is working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.
2020-02-06 18:05:50 -05:00
Andrew Kelley
17c8f108a4
drop @newStackCall
this was causing unrelated behavior tests to fail.

if this commit is reverted, the docs are good, but `@newStackCall` is
already deprecated in favor of `@call`, supplying the `stack` property.
2020-01-30 17:51:55 -05:00
Valentin Anger
d448c3d38a Add support for code model selection 2020-01-29 16:09:07 -05:00
Andrew Kelley
34706dad3f
fix typo in doc comment 2020-01-29 12:25:25 -05:00