10582 Commits

Author SHA1 Message Date
Andrew Kelley
64deb46859 stage2: capture LLD stderr into a buffer 2020-09-23 15:21:40 -07:00
Andrew Kelley
90b320d0e9 use ascii range for the --watch REPL prompt 2020-09-23 14:50:52 -07:00
Andrew Kelley
b183b612c9 stage2: don't build libunwind on OS's that don't need it 2020-09-23 11:15:27 -07:00
Andrew Kelley
f4dde4d109 test_runner: fix missing newline in log 2020-09-23 11:15:10 -07:00
Andrew Kelley
02886a8b93 stage2: support rpaths 2020-09-23 11:01:15 -07:00
Andrew Kelley
c0b774fbc6 stage2: support passing extra C flags to C source files
closes #3508
2020-09-23 10:22:44 -07:00
Andrew Kelley
d03fcc73fc stage2: implement --main-pkg-path 2020-09-23 09:56:30 -07:00
Andrew Kelley
15b2bae517 fix trying to link libc for static libs and objects 2020-09-23 09:41:55 -07:00
Andrew Kelley
800a4a6ceb eliminate dependency of libzigcpp.a on libzigstage1.a
This allows us to create a build of self-hosted with LLVM extensions
enabled but without the stage1 backend.
2020-09-23 00:00:24 -07:00
Andrew Kelley
fc88d36dae stage2: link_libc=true on OS's that require it for syscalls 2020-09-22 23:31:32 -07:00
Andrew Kelley
0638a020cf stage2: implement --pkg-begin and --pkg-end CLI args 2020-09-22 23:00:33 -07:00
Andrew Kelley
c2b1cd7c45 stage2: implement zig build
As part of this:

 * add std.process.cleanExit. closes #6395
   - use it in several places
 * adjust the alignment of text in `zig build --help` menu
 * Cache: support the concept of "unhit" so that we properly keep track
   of the cache when we find out using the secondary hash that the cache
   "hit" was actually a miss. Use this to fix false negatives of caching
   of stage1 build artifacts.
 * fix not deleting the symlink hash for stage1 build artifacts causing
   false positives.
 * implement support for Package arguments in stage1 build artifacts
 * update and add missing usage text
 * add --override-lib-dir and --enable-cache CLI options
   - `--enable-cache` takes the place of `--cache on`
 * CLI supports -femit-bin=foo combined with --enable-cache to do an
   "update file" operation. --enable-cache without that argument
   will build the output into a cache directory and then print the path
   to stdout (matching master branch behavior).
 * errors surfacing from main() now print "error: Foo" instead of
   "error: error.Foo".
2020-09-22 22:18:19 -07:00
Andrew Kelley
250664bea4 build runner: allow for a bit longer -D options
so they can display in the --help menu without getting squished.
2020-09-22 14:56:52 -07:00
Andrew Kelley
dacd36ca9b stage2: implement using the global cache dir 2020-09-22 14:08:08 -07:00
Andrew Kelley
bf9a16a037 stage2: implement zig init-lib and zig init-exe 2020-09-21 23:28:34 -07:00
Andrew Kelley
877e4248fc stage2: implement building & linking against libcxx and libcxxabi 2020-09-21 22:38:45 -07:00
Andrew Kelley
974333faaf stage2: fix linking libc trying to depend on itself 2020-09-21 21:42:27 -07:00
Andrew Kelley
0c70bb4fce Merge remote-tracking branch 'origin/master' into stage2-zig-cc 2020-09-21 21:16:46 -07:00
Andrew Kelley
afac5d2895 fix regressed stage2 test harness 2020-09-21 21:14:01 -07:00
Andrew Kelley
ead50ea665 stage2: implement zig run and zig test 2020-09-21 21:01:04 -07:00
Andrew Kelley
528832bd3a rename src-self-hosted/ to src/ 2020-09-21 18:38:55 -07:00
Andrew Kelley
b9f61d4015 stage1: resolve builtin.zig path when bootstrapping 2020-09-21 18:26:24 -07:00
Andrew Kelley
61c54b2d49 Cache integration for stage1 zig code compilation 2020-09-21 18:21:49 -07:00
Andrew Kelley
b8861a94dd stage2: building compiler_rt and libc static archive with stage1
* add CLI support for verbose debugging options
 * implement building compiler_rt and libc static archive using stage1
   C++ backend
 * add function_sections  and link_libcpp to root cache hash.
 * cleanups to use the new Directory.join method.
 * Package supports being initialized directly and cleaned up create()
   method.
 * fix classifyFileExt incorrectly saying .zir is .zig. Thanks
   @Rocknest!
 * unify updateSubCompilation implementations
2020-09-21 16:33:29 -07:00
Andrew Kelley
bd1465a3fe cmake: output better message when building self-hosted
Thanks @bfredl!
2020-09-21 16:32:56 -07:00
Andrew Kelley
561ed38f12 ci: drop the cmake patch for linux
hopefully they've solved the polly plugin thing by now on apt.llvm.org.
2020-09-21 12:40:19 -07:00
Vexu
ced061fcbf stage2: update uses of DepTokenizer 2020-09-21 15:23:41 -04:00
Vexu
b759308fb3 stage2: DepTokenizer print errors 2020-09-21 15:23:41 -04:00
Vexu
f27bc79121 stage2: DepTokenizer add target resolver 2020-09-21 15:23:41 -04:00
Vexu
302e156523 stage2: make DepTokenizer non-allocating 2020-09-21 15:23:41 -04:00
LemonBoy
58ee5f4e61 std: Fix metadata corruption in HeapAllocator
HeapAllocator stores the pointer returned by HeapAlloc right after the
data block and, after the recent allocator refactoring, the space for
this pointer was not taken into account in the calculation of the final
block size.

Fixes #5830
2020-09-20 01:21:29 -04:00
Andrew Kelley
2ef68631cb stage2 now supports using stage1 as a backend for compiling zig code
* move stage2.cpp code into zig0.cpp for simplicity
 * add -ftime-report and some more CLI options to stage2
 * stage2 compites the llvm cpu features string
 * classifyFileExt understands more file extensions
 * correction to generateBuiltinZigSource using the wrong allocator
   (thanks dbandstra!)
 * stage2 is now able to build hello.zig into hello.o using stage1 as a
   library however it fails linking due to missing compiler-rt
 * remove dead code
 * simplify zig0 builtin.zig source
 * fix not resolving builtin.zig source path causing duplicate imports
 * fix stage1.h not being valid C code
 * fix stage2.h not being valid C code
2020-09-18 22:48:28 -07:00
LemonBoy
f92d01c8a8 stage1: Fix edge case in casting between optional types
Closes #6370
2020-09-18 22:12:22 -04:00
zenith391
4fbf9f7f79 Add "emit_docs" field to LibExeObjStep. 2020-09-19 00:39:43 +03:00
Andrew Kelley
333b12a8f9 std: start: use std.log instead of stderr
When main returns an error code.
2020-09-18 01:58:16 -07:00
Andrew Kelley
dc79651e6a stage2: add CLI for zig translate-c 2020-09-18 01:33:32 -07:00
Andrew Kelley
a9b18023a4 stage2: implement --show-builtin
This takes the place of `zig builtin`. This is an improvement over the
command because now the generated source will correctly show LinkMode
and OutputMode, whereas before it was always stuck as Static and Obj,
respectively.
2020-09-17 23:27:24 -07:00
Andrew Kelley
dc478687d9 delete all stage1 c++ code not directly related to compiling stage2
Deleted 16,000+ lines of c++ code, including:
 * an implementation of blake hashing
 * the cache hash system
 * compiler.cpp
 * all the linking code, and everything having to do with building
   glibc, musl, and mingw-w64
 * much of the stage1 compiler internals got slimmed down since it
   now assumes it is always outputting an object file.

More stuff:
 * stage1 is now built with a different strategy: we have a tiny
   zig0.cpp which is a slimmed down version of what stage1 main.cpp used
   to be. Its only purpose is to build stage2 zig code into an object
   file, which is then linked by the host build system (cmake) into
   stage1. zig0.cpp uses the same C API that stage2 now has access to,
   so that stage2 zig code can call into stage1 c++ code.
   - stage1.h is
   - stage2.h is
   - stage1.zig is the main entry point for the Zig/C++
     hybrid compiler. It has the functions exported from Zig, called
     in C++, and bindings for the functions exported from C++, called
     from Zig.
 * removed the memory profiling instrumentation from stage1.
   Abandon ship!
 * Re-added the sections to the README about how to build stage2 and
   stage3.
 * stage2 now knows as a comptime boolean whether it is being compiled
   as part of stage1 or as stage2.
   - TODO use this flag to call into stage1 for compiling zig code.
 * introduce -fdll-export-fns and -fno-dll-export-fns and clarify
   its relationship to link_mode (static/dynamic)
 * implement depending on LLVM to detect native target cpu features when
   LLVM extensions are enabled and zig lacks CPU feature detection for
   that target architecture.
 * C importing is broken, will need some stage2 support to function
   again.
2020-09-17 18:29:38 -07:00
Ryan Liptak
fbde15fdf4 Fix compile error in os.renameatW
Introduced in 5e3fa0e94f947c632aa584b9e13bfa2fe241fae1

Whoops!
2020-09-17 18:49:06 -04:00
Andrew Kelley
f125288c9b
Merge pull request #6336 from Rocknest/pbkdf2
Some changes to #6326 (pbkdf2)
2020-09-17 17:31:58 -04:00
Ryan Liptak
5e3fa0e94f Add rename to std.fs API
- Moves fs.rename functions to fs.renameAbsolute to match other functions outside of fs.Dir
- Adds fs.Dir.rename that takes two paths relative to the given Dir
- Adds fs.rename that takes two separate Dir's that the given paths are relative to (for renaming across directories without having to make the second path relative to a single directory)
- Fixes FileNotFound error return in std.os.windows.MoveFileExW
- Returns error.RenameAcrossMountPoints from renameatW
  + Matches the RenameAcrossMountPoints error return in renameatWasi/renameatZ
2020-09-17 17:22:26 -04:00
Andrew Kelley
3672a18799
Merge pull request #6360 from LemonBoy/some-fmt-fixes
Two std.fmt fixes
2020-09-17 16:17:15 -04:00
LemonBoy
b7f9f779af translate-c: Fix formatting of non-printable chars
The two octets in hex notation must be aligned to the right and padded
on the left, not the other way around.
2020-09-17 09:27:24 +02:00
Andrew Kelley
bc01887376 stage2: verify -Wl zig cc behavior 2020-09-16 20:28:51 -07:00
Andrew Kelley
01a7affb87 stage2: ask for a higher open fd limit
Here's the doc comment from the commit:

For one example of why this is handy, consider the case of building musl libc.
We keep a lock open for each of the object files in the form of a file descriptor
until they are finally put into an archive file. This is to allow a zig-cache
garbage collector to run concurrently to zig processes, and to allow multiple
zig processes to run concurrently with each other, without clobbering each other.

This code is disabled until #6361 is implemented (getrlimit/setrlimit
are not yet added to the standard library).
2020-09-16 20:18:06 -07:00
Andrew Kelley
07eb2c65f6 stage2: don't add unused args to assembly compilations 2020-09-16 19:24:09 -07:00
Andrew Kelley
17d40ecb49 stage2: building libunwind.a
and put glibc shared objects on the elf linker line
2020-09-16 17:18:13 -07:00
LemonBoy
27adb82fda std: Respect user-specified alignment when formatting ints
This implementation tries to do the right thing (TM) by treating the
sign as part of the number itself, therefore the alignment parameter
applies to both the sign and the digits.

In other words the format string `{:>4}` with -1 as input will not
output `-  1` but `  -1`.

And let's default to right alignment for everything as that's what users
want, especially when printing numbers. Many implementations use
different defaults for numeric vs non-numeric types, let's strive for a
consistent behaviour here.
2020-09-17 00:53:08 +02:00
Andrew Kelley
17f094ec5b stage2: build glibc shared objects using assembly files
closes #6358
2020-09-16 14:33:13 -07:00
Andrew Kelley
3256b3c485 stage2: glibc shared objects use ok file to detect cache hits 2020-09-16 13:41:53 -07:00