Commit Graph

73 Commits

Author SHA1 Message Date
Andrew Kelley
3227aec848 fix not respecting sub-arch feature 2020-01-22 17:35:57 -05:00
Andrew Kelley
48c7e6c48b std.Target.CpuFeatures is now a struct with both CPU and feature set
Previously it was a tagged union which was one of:
 * baseline
 * a specific CPU
 * a set of features

Now, it's possible to have a CPU but also modify the CPU's feature set
on top of that. This is closer to what LLVM does.

This is more correct because Zig's notion of CPUs (and LLVM's) is not
exact CPU models. For example "skylake" is not one very specific model;
there are several different pieces of hardware that match "skylake" that
have different feature sets enabled.
2020-01-22 17:13:31 -05:00
Andrew Kelley
cbe9a51518 don't trust llvm's GetHostCPUName
comment from this commit reproduced here:

I have observed the CPU name reported by LLVM being incorrect. On
the SourceHut build services, LLVM 9.0 reports the CPU as "athlon-xp",
which is a 32-bit CPU, even though the system is 64-bit and the reported
CPU features include, among other things, +64bit.
So the strategy taken here is that we observe both reported CPU, and the
reported CPU features. The features are trusted more; but if the features
match exactly the features of the reported CPU, then we trust the reported CPU.
2020-01-21 22:02:13 -05:00
Andrew Kelley
830e0ba2d2 enable native CPU feature for windows; disable failing tests
See #508. These can be re-enabled when we upgrade to LLVM 10.
2020-01-21 21:46:06 -05:00
Andrew Kelley
6e6ec3d71d put hack back in to disable windows native cpu features
See #508. This can be removed when we upgrade to LLVM 10.
2020-01-21 21:01:36 -05:00
Andrew Kelley
68b6867e76 lazily compute the full cpu features dependencies 2020-01-21 20:11:36 -05:00
Andrew Kelley
92559cd02c hit a comptime limitation with computing dense sets 2020-01-21 19:40:44 -05:00
Andrew Kelley
91ecce3bc0 fix cache of cpu features 2020-01-21 12:14:43 -05:00
Andrew Kelley
1f7babbc80 properly forward baseline target cpu features to llvm 2020-01-21 03:01:20 -05:00
Andrew Kelley
39759b90fc make zig targets show native cpu name and features 2020-01-21 01:22:37 -05:00
Andrew Kelley
e640d01535 fixups to arch data, support any number of cpu features 2020-01-21 00:34:54 -05:00
Andrew Kelley
f3dd9bbdac improve zig targets 2020-01-20 13:40:25 -05:00
Andrew Kelley
bf82929557 fix std.Target.Arch.parseCpuFeatureSet 2020-01-20 12:41:18 -05:00
Andrew Kelley
8f29d14073 stage1 is building. zig targets now self-hosted 2020-01-20 01:42:31 -05:00
Andrew Kelley
20af858601 some fixes 2020-01-19 21:06:41 -05:00
Andrew Kelley
a313f15384 figure out zig0/stage1 and scanning for native CPU 2020-01-19 20:54:05 -05:00
Andrew Kelley
a867b43366 progress towards merging
see BRANCH_TODO file
2020-01-19 20:54:04 -05:00
Layne Gustafson
430077df1b Allow target details with no LLVM support 2020-01-19 20:53:20 -05:00
Layne Gustafson
35c681b7b1 Fix sentinel mismatch in llvm strings
Previously, buffers were used with toOwnedSlice() to create c strings
for LLVM cpu/feature strings. However, toOwnedSlice() shrinks the
string memory to the buffer's length, which cuts off the null terminator.
Now toSliceConst() is used instead, and the buffer is not deinited
so that the string memory is not freed.
2020-01-19 20:53:20 -05:00
Layne Gustafson
8902f3ca32 Enable 64bit feature for riscv64 2020-01-19 20:53:20 -05:00
Layne Gustafson
a5c9397539 No allocations for n.t. empty strings 2020-01-19 20:53:20 -05:00
Layne Gustafson
40ff359486 Only enable requested features 2020-01-19 20:53:20 -05:00
Layne Gustafson
ebb6f15bba Make sure llvm strings are null-terminated 2020-01-19 20:53:20 -05:00
Layne Gustafson
fd17a9962b Add defaut feature support 2020-01-19 20:53:20 -05:00
Layne Gustafson
03dd376b55 Add builtin.zig support 2020-01-19 20:53:19 -05:00
Layne Gustafson
c61856ebcf Add TargetDetails abstraction 2020-01-19 20:53:19 -05:00
Layne Gustafson
bd6ef21f85 Add cpu/feature specification to cmndline 2020-01-19 20:53:19 -05:00
Layne Gustafson
c131e50ea7 Switch CPU/features to simple format 2020-01-19 20:53:18 -05:00
Layne Gustafson
5bc4690d85 Make targets cmd able to list CPUs and features 2020-01-19 20:53:18 -05:00
Vexu
55348c9b93 translate-c-2 bug fixes
- fix use of undefined value
- fix parenexprclass result not being suppressed
- add an error and a TODO for access of an anonymous field
2019-12-29 19:23:36 +02:00
Vexu
a37caaa528 translate-c-2 parameter name aliasing 2019-12-16 10:39:31 +02:00
Vexu
69dee57d95 remove concept of translate mode 2019-12-12 14:26:24 +02:00
Andrew Kelley
7c1dbfab72 self-hosted: manually parse args 2019-12-11 02:08:33 -05:00
Robin Voetter
c519bb02df Fix usage of freed memory in zig fmt 2019-12-10 11:09:29 -05:00
Andrew Kelley
03396b3caa update docs to new fmt API 2019-12-08 23:46:50 -05:00
Andrew Kelley
8b2622cdd5 std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley
b36c07a95a Merge remote-tracking branch 'origin/master' into remove-array-type-coercion 2019-12-01 09:56:01 -05:00
Andrew Kelley
413f9a5cfc move std.fs.Dir.cwd to std.fs.cwd
update to non-deprecated std.fs APIs throughout the codebase

Related: #3811
2019-11-30 15:35:27 -05:00
Andrew Kelley
85e1e3b95f Merge pull request #3284 from Sahnvour/export_variables
Improved support for exporting variables
2019-11-30 00:25:52 -05:00
Andrew Kelley
bf3ac66150 remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
Jonathan S
4014a8e4b4 Avoid deprecated cwd-based functions for opening directories, preferring to open explicitly relative to Dir.cwd(). 2019-11-25 23:46:48 -05:00
Andrew Kelley
15d415e10b make std.mem.toSlice use null terminated pointers
and fix the fallout
2019-11-24 21:21:05 -05:00
Andrew Kelley
34b1ebefaa Merge remote-tracking branch 'origin/master' into null-terminated-pointers 2019-11-24 20:28:46 -05:00
Sahnvour
696567d9d7 export: check variable type
also fixed existing occurrences
2019-11-24 21:33:58 +01:00
Vexu
03cc81665b Merge branch 'master' into modernize-stage2 2019-11-23 19:13:48 +02:00
Andrew Kelley
47f06be369 string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
Andrew Kelley
0237e7a701 std.io.getStdOut and related fns no longer can error
Thanks to the Windows Process Environment Block, it is possible to
obtain handles to the standard input, output, and error streams without
possibility of failure.
2019-11-13 04:01:40 +00:00
Andrew Kelley
aa0daea541 update more of the std lib to use @as 2019-11-08 15:57:25 -05:00
Vexu
c6076a1360 self hosted compiler: use enum literals 2019-11-07 10:30:56 +02:00
Andrew Kelley
c3d816a98e std lib networking improvements, especially non-blocking I/O
* delete the std/event/net directory
 * `std.event.Loop.waitUntilFdReadable` and related functions
   no longer have possibility of failure. On Linux, they fall
   back to poll() and then fall back to sleep().
 * add some missing `noasync` decorations in `std.event.Loop`
 * redo the `std.net.Server` API. it's quite nice now, but
   shutdown does not work cleanly. There is a race condition with
   close() that I am actively working on.
 * move `std.io.OutStream` to its own file to match `std.io.InStream`.
   I started working on making `write` integrated with evented I/O,
   but it got tricky so I backed off and filed #3557. However
   I did integrate `std.os.writev` and `std.os.pwritev` with evented I/O.
 * add `std.Target.stack_align`
 * move networking tests to `lib/std/net/test.zig`
 * add `std.net.tcpConnectToHost` and `std.net.tcpConnectToAddress`.
 * rename `error.UnknownName` to `error.UnknownHostName` within the
   context of DNS resolution.
 * add `std.os.readv`, which is integrated with evented I/O.
 * `std.os.preadv`, is now integrated with evented I/O.
 * `std.os.accept4` now asserts that ENOTSOCK and EOPNOTSUPP never
    occur (misuse of API), instead of returning errors.
 * `std.os.connect` is now integrated with evented I/O.
   `std.os.connect_async` is gone. Just use `std.os.connect`.
 * fix false positive dependency loop regarding async function frames
 * add more compile notes to help when dependency loops occur
   in determining whether a function is async.
 * ir: change an assert to ir_assert to make it easier to find
   workarounds for when such an assert is triggered. In this case
   it was trying to parse an IPv4 address at comptime.
2019-10-29 22:59:30 -04:00