Commit Graph

10818 Commits (d0a4110d34b8d80a9212a01f21d7be7629de8813)

Author SHA1 Message Date
LemonBoy cbbcf60968 stage1: Allow comparison with comptime-known vectors
Since comptime_{int,float} vectors are not allowed (thanks $DEITY) we
can use the element type infos to determine the minimum operand size.
2020-09-28 17:16:57 +02:00
LemonBoy 56b52dd0a3 stage1: Detect OOB access of vector value
Fixes #5710
2020-09-28 17:16:12 +02:00
kprotty 468a4bf0b4 address some review changes 2020-09-28 07:25:51 -05:00
Felix (xq) Queißner c2d60bc5b5 Follows @tadeokondrak remark about taking `[]const type`. 2020-09-28 12:24:22 +02:00
Felix (xq) Queißner 55dfe729b4 Changes comptime block to test. 2020-09-28 11:44:55 +02:00
Felix (xq) Queißner 9331466998 Changes comptime block to test. 2020-09-28 11:42:39 +02:00
Andrew Kelley 91a73a177b stage2: building mingw-w64 and COFF LDD linking
still TODO is the task of creating import .lib files for DLLs on the fly
both for -lfoo and for e.g. `extern "kernel32"`
2020-09-28 00:06:06 -07:00
Jakub Konka e60939bfaa
Merge pull request #6397 from suirad/fix-5537
Fix for Windows: std.os.windows.DeleteFile()
2020-09-27 21:59:29 +02:00
kprotty a31d9f92f2 new std.event.Lock implementation 2020-09-27 14:05:38 -05:00
Andrew Kelley 8794ce6f79
Merge pull request #6293 from LakeByTheWoods/fmt_fixes
zig fmt fixes
2020-09-27 05:49:38 -04:00
Ian Simonson eab51b7785 Make LinearFifo not crash when discarding from empty buffer
Previously if a LinearFifo was empty and discard was called
an unsigned overflow would occur. However it is safe to perform
this overflow as a bitwise & operation with 0xFFFFFFFFFFFFFF is a noop
2020-09-27 05:46:39 -04:00
Woze Parrrot ed357f9897 uefi system_table 2020-09-27 03:15:18 -04:00
Andrew Kelley a9082b4ec5 stage2: add CLI support for --subsystem 2020-09-26 22:37:19 -07:00
Andrew Kelley 4b403c7eac fix non-ELF linkAsArchive 2020-09-26 21:23:12 -07:00
Andrew Kelley b6556c944b fix another round of regressions in this branch
* std.log: still print error messages in ReleaseSmall builds.
   - when start code gets an error code from main, it uses std.log.err
     to report the error. this resulted in a test failure because
     ReleaseSmall wasn't printing `error: TheErrorCode` when an error
     was returned from main. But that seems like it should keep working.
     So I changed the std.log defaults. I plan to follow this up with a
     proposal to change the names of and reduce the quantity of the
     log levels.
 * warning emitted when using -femit-h when using stage1 backend; fatal
   log message when using -femit-h with self-hosted backend (because the
   feature is not yet available)
 * fix double `test-cli` build steps in zig's build.zig
 * update docgen to use new CLI
 * translate-c uses `-x c` and generates a temporary basename with a
   `.h` extension. Otherwise clang reports an error.
 * --show-builtin implies -fno-emit-bin
 * restore the compile error for using an extern "c" function without
   putting -lc on the build line. we have to know about the libc
   dependency up front.
 * Fix ReleaseFast and ReleaseSmall getting swapped when passing the
   value to the stage1 backend.
 * correct the zig0 CLI usage text.
 * update test harness code to the new CLI.
2020-09-26 21:03:38 -07:00
Andrew Kelley fe4c348f57 stage2: `zig translate-c` supports --enable-cache
This matches master branch behavior and makes the test-translate-c tests
pass.
2020-09-26 16:48:02 -07:00
Andrew Kelley 26f2f9bf1c stage2: implement -fno-emit-bin
we are now passing the cli tests
2020-09-26 12:42:07 -07:00
Andrew Kelley 9b83112a1f fix _fbsd suffix appended to lld LDM option twice 2020-09-26 11:26:46 -07:00
Frank Denis 99c5d2d590 Print the llvm-config path on configuration error
This is helpful on systems with multiple LLVM installations.

For example, OpenBSD ships with LLVM in the base system, but without
support for extra targets.

A full LLVM version can be installed using the ports system, but even
when it is, `cmake` is not going to pick it up unless `/usr/local` is
explicitly added to the `cmake` search paths.

Having the full `llvm-config` path printed on error is helpful to
understand that the detected LLVM version was not the expected one.
2020-09-26 17:10:33 +02:00
Andrew Kelley a23b1b4254 stage2: building musl: fix typo in replacing path separators 2020-09-26 02:34:57 -07:00
Andrew Kelley 1337f0bc6a move to stage1-specific cache manifest emission of extra stuff 2020-09-26 02:34:18 -07:00
Andrew Kelley 56086d11a4 stage0: update CLI to match stage2 2020-09-26 02:16:10 -07:00
Andrew Kelley 819625d274 fix logic for choosing when dynamic linking is required
When building object files or static libraries, link_mode can still be
static even if the OS needs libc for syscalls.
2020-09-26 01:58:16 -07:00
Andrew Kelley 6af2990549 implement -femit-asm, -femit-docs, -femit-llvm-ir, etc
These CLI options are now forwarded to the stage1 backend.

We're not going to support the -mllvm CLI option any longer. As a
compromise, we unconditionally tell LLVM to output intel x86 syntax when
using -femit-asm.

Simplify stage1 logic; it no longer has the concept of an output
directory. --output-dir is no longer a valid CLI option. cmake uses
the `-femit-bin=[path]` option.

Note the changes to test/cli.zig. This breaks the CLI API that Godbolt
is using so we're going to want to open a PR to help them upgrade to the
new CLI for the upcoming Zig 0.7.0 release.
2020-09-26 01:47:27 -07:00
Andrew Kelley a337046832 stage2: properly handle zig cc used as a preprocessor
This cleans up how the CLI parses and handles -E, -S, and -c.
Compilation explicitly acknowledges when it is being used to do C
preprocessing.

-S is properly translated to -fno-emit-bin -femit-asm but Compilation
does not yet handle -femit-asm.

There is not yet a mechanism for skipping the linking step when there is
only a single object file, and so to make this work we have to do a file
copy in link.flush() to copy the file from zig-cache into the output
directory.
2020-09-25 20:52:02 -07:00
Andrew Kelley aded86e690 std.ArrayHashMap: count and iterator are not deprecated
These APIs allow one to write code that is agnostic of whether it is
using an ArrayHashMap or a HashMap, which can be valuable. Specify
intent precisely: if you only need the count of the items, it makes
sense to have a function for that.
2020-09-25 20:50:40 -07:00
Andrew Kelley 21b407b17f update test case for init-exe with respect to new template
Now it uses std.log.info instead of std.debug.print
2020-09-25 18:21:21 -07:00
Andrew Kelley 70d7d7e919 stage2: disable lld caching when output dir is owned by user
Normally when using LLD to link, Zig uses a file named "lld.id" in the
same directory as the output binary which contains the hash of the link
operation, allowing Zig to skip linking when the hash would be unchanged.
In the case that the output binary is being emitted into a directory which
is externally modified - essentially anything other than zig-cache - then
this flag would be set to disable this machinery to avoid false positives.

 * Better defaults when using -fno-LLVM
 * Fix compiler_rt and libc static libraries were getting a .zig
   extension instead of .a extension.
 * when using the stage1 backend, put the object file next to the
   stage1.id file in the cache directory. this prevents an object file
   from polluting the cwd when using zig from the CLI.
2020-09-25 18:01:35 -07:00
Suirad 43cd9eb110 Add clarification comment 2020-09-25 18:11:31 -05:00
Suirad f78652484a Stdlib fix for os.windows.deleteFile to fail with
a proper error when attempting to delete a directory that isnt empty
2020-09-25 18:09:05 -05:00
Andrew Kelley 670e7d456c add some tracy calls 2020-09-25 14:47:09 -07:00
Andrew Kelley a502604702
Merge pull request #6412 from kristoff-it/generalize-event-loop
Make os.zig not depend on the event loop
2020-09-25 17:26:44 -04:00
Loris Cro dc01ef7388
Remove noop check
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-09-25 23:21:20 +02:00
Andrew Kelley 812e482bef ELF linking supports root src directory to be cwd 2020-09-25 13:37:10 -07:00
Tadeo Kondrak 236af776fd
std.fmt: add comptimePrint 2020-09-25 12:53:35 -06:00
Alexandros Naskos 288198e51d
Merge pull request #6413 from LemonBoy/fix-5116
Make ArenaAllocator try to resize first
2020-09-25 19:47:50 +03:00
Loris Cro 8d01133bd0 update doc comments
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-25 18:42:24 +02:00
LemonBoy bd9003ed5b std: ArenaAllocator tries to resize before allocating
Closes #5116
2020-09-25 10:58:07 +02:00
Felix (xq) Queißner 7f68b14377 Implements std.meta.Tuple(), implements #4607 in userland. 2020-09-25 09:27:00 +02:00
Felix (xq) Queißner 93291cc472 Implements std.meta.ArgsTuple. 2020-09-25 09:16:43 +02:00
Andrew Kelley 495d18a205 std.log: better default for printing logs
* prefix with the message level
 * if the scope is not default, also prefix with the scope

This makes the stack trace test pass, with no changes to the
test case, because errors returned from main() now print
`error: Foo` just like they do in master branch.
2020-09-25 00:02:52 -07:00
Andrew Kelley 30dfdfdbd0 fix a round of regressions in this branch
* Don't try to generate C header files yet since it will only cause a
   crash saying the feature is unimplemented.
 * Rename the CLI options for release modes to use the `-O` prefix to
   match C compiler precedent. Options are now `-ODebug`,
   `-OReleaseFast`, `-OReleaseSafe`, `-OReleaseSmall`. The optimization
   mode matches the enum tags of std.builtin.Mode. It is planned to, at
   some point, rename std.builtin.Mode to std.builtin.OptimizationMode
   and modify the tags to be lower case to match the style convention.
   - Update build.zig code to support this new CLI.
 * update std.zig.binNameAlloc to support an optional Version and update
   the implementation to correctly deal with dynamic library version
   suffixes.
2020-09-24 23:50:15 -07:00
Andrew Kelley f8b3543cab I think this test is still flakey
re-opens #4922
2020-09-24 22:57:03 -07:00
Josh Wolfe 1a8669eada build.zig: addBuildOptionArtifact 2020-09-25 01:53:38 -04:00
Andrew Kelley 7964341c76 zig build: update to use new --version flag instead of legacy flags 2020-09-24 22:18:53 -07:00
Andrew Kelley 5440ca8eb7 --main-pkg-path properly resolves the relative root src file path 2020-09-24 22:15:40 -07:00
Andrew Kelley 67463c4357 correct `@cImport` caching to handle "unhit" case
if you hit() you have to unhit() to get the same digest if you don't
end up treating it as a hit.
2020-09-24 21:52:37 -07:00
Andrew Kelley 4f0850fe28 don't delete C import .c source from zig-cache
preventing CacheUnavailable error when doing `@cImport`
2020-09-24 21:13:01 -07:00
Andrew Kelley 054fafd7d9 stage2: implement @cImport
Also rename Cache.CacheHash to Cache.Manifest
2020-09-24 16:22:45 -07:00
Loris Cro c196c27af8 recvfrom
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00