Commit Graph

550 Commits

Author SHA1 Message Date
Andrew Kelley
c3f637a54c cmake: debug builds of zig enable logging by default
when logging is enabled, the --debug-log flag is available.
2021-06-23 10:44:46 -07:00
Andrew Kelley
193c529b8c CLI: rename --override-lib-dir to --zig-lib-dir
This breaking change disambiguates between overriding the lib dir when
performing an installation with the Zig Build System, and overriding the
lib dir that the Zig installation itself uses.
2021-06-14 11:33:27 -07:00
protty
2ba68f9f4c
std.Thread.Futex addition (#9070)
* std.Thread.Futex: implementation + tests

* std.Thread.Futex: fix darwin compile errors

* std.Thread.Futex: fix wait() documentation typo

* std.Thread.Futex: fix darwin version check

* std.Thread.Futex: remove unnecessary comptime keyword
2021-06-12 08:51:37 -05:00
Andrew Kelley
b755c46d70 start the 0.9.0 release cycle 2021-06-04 11:29:01 -07:00
Andrew Kelley
87dae0ce98
Merge pull request #8932 from ziglang/llvm-needs-zlib
cmake: LLVM needs to link against zlib
2021-06-03 02:13:37 -04:00
protty
eb6975f088
std.sync.atomic: extended atomic helper functions (#8866)
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint`
- added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int
- in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer
- added fence() and compilerFence() to std.atomic
2021-05-31 11:11:30 -05:00
Andrew Kelley
f8bc5294f2 cmake: LLVM needs to link against zlib
For more details on why this dependency is needed, see
https://github.com/ziglang/zig-bootstrap/issues/57
2021-05-29 17:22:27 -07:00
Andrew Kelley
0afb5b2ec6 stage2: add zig ar subcommand
The same entrypoint supports the following commands:

 * ar
 * ranlib
 * dlltool
 * lib

For now, our strategy is to bundle the (renamed) `main()` function of
llvm-ar, same as our strategy for `zig clang`. However, as Zig matures,
a goal will be to replace the dependency on LLVM  with our own
implementation of this tool, so that it is available in builds of zig
that do not have LLVM extensions enabled.

This commit also categorizes the subcommands into categories in the
--help menu.
2021-05-28 20:54:11 -07:00
Andrew Kelley
2a990d6966 stage1: rework tokenizer to match stage2
* Extracts AstGen logic from ir.cpp into astgen.cpp. Reduces the
   largest file of stage1 from 33,551 lines to 25,510.
 * tokenizer: rework it completely to match the stage2 tokenizer logic.
   They can now be maintained together; when one is changed, the other
   can be changed in the same way.
   - Each token now takes up 13 bytes instead of 64 bytes. The tokenizer
     does not parse char literals, string literals, integer literals,
     etc into meaningful data. Instead, that happens during parsing or
     astgen.
   - no longer store line offsets. Error messages scan source
     files to find the line/column as needed (same as stage2).
   - main loop: instead of checking the loop, handle a null byte
     explicitly in the switch statements. This is a nice improvement
     that we may want to backport to stage2.
   - delete some dead tokens, artifacts of past syntax that no longer
     exists.
 * Parser: fix a TODO by parsing builtin functions as tokens rather than
   `@` as a separate token. This is how stage2 does it.
 * Remove some debugging infrastructure. These will need to be redone,
   if at all, as the code migrates to match stage2.
   - remove the ast_render code.
   - remove the IR debugging stuff
   - remove teh token printing code
2021-05-28 12:58:40 -07:00
Andrew Kelley
79dee75b1c stage2: rename ir.zig to air.zig
We've settled on the nomenclature for the artifacts the compiler
pipeline produces:

1. Tokens
2. AST (Abstract Syntax Tree)
3. ZIR (Zig Intermediate Representation)
4. AIR (Analyzed Intermediate Representation)
5. Machine Code

Renaming `ir` identifiers to `air` will come with the inevitable
air-memory-layout branch that I plan to start after the 0.8.0 release.
2021-05-22 14:29:16 -07:00
Jakub Konka
7b74de7d71 wasi,cc: fix naming and add stubs for building
Rename include dir to match the convention:
  from `wasm32-wasi` to `wasm-wasi-musl`

Add building stubs which will be used to build and cache WASI
libc sysroot.
2021-05-20 16:54:00 +02:00
Andrew Kelley
a9cd9b021b Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
I want the updated Drone CI stuff to get the CI green.
2021-05-18 12:37:03 -07:00
Jakub Konka
138cecc028 zld: add prelim way of linking dylibs
The support is minimalistic in the sense that we only support actual
dylib files and not stubs/tbds yet, and we also don't support re-exports
just yet.
2021-05-18 09:28:00 +02:00
Andrew Kelley
9a95478c62 cmake: remove deleted file
This should have been part of 07606d12da
2021-05-15 21:46:36 -07:00
Andrew Kelley
f37451a63a stage2: fix zir.zig => Zir.zig in CMakeLists.txt 2021-04-15 19:12:05 -07:00
Jakub Konka
1119970d22 zld: add x86_64 relocs 2021-04-13 10:56:03 +02:00
Jakub Konka
6a866f1a96 zld: preprocess relocs on arm64 2021-04-13 10:56:03 +02:00
Jakub Konka
988b184d03 zld: redo symbol resolution in objects
Store only globals and undefs at the linker level, while all locals
stay scoped to the actual object file they were defined in. This is
fine since the relocations referencing locals will always be resolved
first using the local symbol table before checking for the reference
within the linker's global symbol table.

This also paves the way for proper symbol resolution from within static
and dynamic libraries.
2021-04-13 10:56:03 +02:00
Andrew Kelley
281a7baaea Merge remote-tracking branch 'origin/master' into zir-memory-layout
Wanted to make sure those new test cases still pass.

Also grab that CI fix so we can get those green check marks.
2021-03-28 19:42:43 -07:00
Isaac Freund
402f87a213
stage2: rename WipZirCode => AstGen, astgen.zig => AstGen.zig 2021-03-28 19:10:10 +02:00
Jakub Konka
ba8ac46e1f stage1: add cmake flag for enabling logging
Now that we ship our own linker for MachO by default in both stage1
and stage2, we need a way to enable logs for verbose debugging.
This commit adds `ZIG_ENABLE_LOGGING` cmake option which is equivalent
to stage2's `-Dlog` flag.

To enable it when building stage1 with cmake, add:

```
cmake .. -DZIG_ENABLE_LOGGING=on
```
2021-03-21 18:03:55 -07:00
Michael Dusan
e35f325dd1 azure: produce macos arm64 binaries
new pipeline `BuildMacOS_arm64`
  - `vmImage: 'macOS-10.15' `

new `macos_arm64_script`
  - switch from using `make` to `ninja`
  - select xcode 12.4
  - set zig-cache env variables
  - build host-zig binary with xcode, link against llvm for x86_64 (target macos 10.15)
  - build arm64-zig binary with xcode and host-zig, link against llvm for arm64 (target macos 11.0)
  - ad-hoc codesign arm64 binary with linker
  - use host-zig for docgen
  - use host-zig for experimental std lib docs
  - sync final `release/` hierarchy with `linux_script`
  - use gnu-tar for good-practices (set owner, set sort)

enhance `CMakeLists.txt`
  - do not build `zig0` when cross-compiling
  - disable `BYPRODUCTS` directive `zig1.o` to avoid `ninja` error

see #8265
2021-03-20 22:50:51 +01:00
Andrew Kelley
f5aca4a6a1 Merge remote-tracking branch 'origin/master' into zir-memory-layout
I need the enum arrays that were just merged into master.
2021-03-18 15:52:12 -07:00
Jakub Konka
7516dfff83 zld: use zld when linking aarch64 by default and cross-comp 2021-03-18 00:37:13 +01:00
Andrew Kelley
099af0e008 stage2: rename zir_sema.zig to Sema.zig 2021-03-16 00:04:17 -07:00
Andrew Kelley
4e9894cfc4 cmake build: allow overriding whether to use llvm-config
Previously, there was an option ZIG_PREFER_LLVM_CONFIG which would
override the default of not using llvm-config when cross compiling.

That option is now removed in favor of the more powerful
ZIG_USE_LLVM_CONFIG which defaults to OFF for cross compiling and ON for
native compilation. The option overrides the default.

This will be used in zig-bootstrap to improve support for native builds.
2021-03-13 14:30:56 -07:00
daurnimator
1f861ecc95 Bring back ZIG_SKIP_INSTALL_LIB_FILES 2021-03-01 16:23:10 -08:00
Andrew Kelley
38441b5eab MultiArrayList: use @memcpy as a workaround
Reverts bf642204b3 and uses a different
workaround, suggested by @LemonBoy.

There is either a compiler bug or a design flaw somewhere around here.
It does not have to block this branch, but I need to understand exactly
what's going on here and make it so that nobody ever has to run into
this problem again.
2021-02-24 12:49:12 -07:00
Andrew Kelley
f041425e48 translate-c: fix using wrong slice and AST tag 2021-02-23 13:55:12 -07:00
Veikka Tuominen
d672c20b8a
Merge pull request #7479 from ziglang/translate-c-ast
Make translate-c use intermediate AST
2021-02-19 13:03:29 +02:00
Isaac Freund
070e548acf
std: remove io.AutoIndentingStream
This type is not widely applicable enough to be a public part of the
public interface of the std.

The current implementation in only fully utilized by the zig fmt
implementation, which could benefit by even tighter integration as
will be demonstrated in the next commit. Therefore, move the current
io.AutoIndentingStream to lib/std/zig/render.zig.

The C backend of the self hosted compiler also use this type currently,
but it does not require anywhere near its full complexity. Therefore,
implement a greatly simplified version of this interface in
src/codegen/c.zig.
2021-02-16 23:20:46 +01:00
Veikka Tuominen
13a9db2085
translate-c: begin implementing ast.render 2021-02-16 16:40:06 +02:00
Andrew Kelley
a9667b5a85 organize std lib concurrency primitives and add RwLock
* move concurrency primitives that always operate on kernel threads to
   the std.Thread namespace
 * remove std.SpinLock. Nobody should use this in a non-freestanding
   environment; the other primitives are always preferable. In
   freestanding, it will be necessary to put custom spin logic in there,
   so there are no use cases for a std lib version.
 * move some std lib files to the top level fields convention
 * add std.Thread.spinLoopHint
 * add std.Thread.Condition
 * add std.Thread.Semaphore
 * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux
 * add std.Thread.RwLock

Implementations provided by @kprotty
2021-01-14 20:41:37 -07:00
Andrew Kelley
d68adc5382 std.EarlyEOFReader: rename to LimitedReader 2021-01-11 16:51:56 -07:00
daurnimator
e873668d38 std: add LimitedReader: reader that returns EOF early 2021-01-11 16:48:30 -07:00
Jay Petacat
e72472d953 io: FindByteOutStream to FindByteWriter
See #4917
2021-01-08 16:54:56 -05:00
Andrew Kelley
2f58efcc1f std.SpinLock: flatten and remove init/deinit
structs which are intended to be directly initialized and support static
initialization should not have init/deinit methods.
2021-01-06 17:36:06 -07:00
Andrew Kelley
76870a2265
Merge pull request #7700 from FireFox317/more-stage2-stuff-llvm
stage2: improvements to LLVM backend
2021-01-06 16:06:32 -08:00
Timon Kruiper
b1cfa923be stage2: rename and move files related to LLVM backend 2021-01-06 10:52:20 +01:00
Andrew Kelley
3e39d0c44f minor fixups from moving identifiers and files around 2021-01-05 17:41:22 -07:00
Andrew Kelley
2fe8a48215 ci: omit stage2 backend from stage1 on Windows
to avoid out-of-memory on the CI runs.
2021-01-04 14:59:18 -07:00
Andrew Kelley
ec8c25fd8f Restore the reverted semantic versioning commits
restore "Comply with semantic versioning pre-release format"
restore "stage2: SemVer compliance for development builds"
restore "Remove 'g' prefix from commit hash in Zig semver"

This reverts commit d96d8639e5.
This reverts commit e8810f5794.
This reverts commit 9afe5859a3.
2021-01-01 21:02:32 -07:00
Andrew Kelley
d96d8639e5 Revert "Comply with semantic versioning pre-release format"
This reverts commit bbe2cca1ae.
2020-12-31 16:41:42 -07:00
Andrew Kelley
e8810f5794 Revert "stage2: SemVer compliance for development builds"
This reverts commit 4af763d401.
2020-12-31 16:41:35 -07:00
Andrew Kelley
9afe5859a3 Revert "Remove 'g' prefix from commit hash in Zig semver"
This reverts commit 02438aabe3.
2020-12-31 16:41:24 -07:00
Jay Petacat
02438aabe3 Remove 'g' prefix from commit hash in Zig semver 2020-12-30 20:57:50 -06:00
Jay Petacat
4af763d401 stage2: SemVer compliance for development builds
This matches the behavior of CMake builds. These changes should have
been in PR #6509, but were missed.
2020-12-29 23:25:58 -06:00
Jay Petacat
bbe2cca1ae Comply with semantic versioning pre-release format
Example version: 0.8.0-dev.460+g81b343a16

From a semantic versioning perspective, development builds will now be
considered distinct from a tagged release. The number of commits added
since the last tag is included in the pre-release component.

Updates #6466
2020-12-29 13:17:08 -08:00
Timon Kruiper
071417161d stage2: add initial impl of LLVM backend in self-hosted compiler 2020-12-28 21:19:40 +01:00
Timon Kruiper
4a0d64300b stage2: rename llvm.zig to llvm_bindings.zig
Putting functions in this file will create functions like
`llvm.function`, and the compiler thinks these are llvm intrinsics.
2020-12-28 21:15:13 +01:00