Commit Graph

14285 Commits

Author SHA1 Message Date
Veikka Tuominen
e63ff4f1c1 add ast-check flag to zig fmt, fix found bugs 2021-06-14 00:16:40 +03:00
jacob gw
b9f07b7ac2 format zig files and add formatting check to ci 2021-06-13 22:33:39 +03:00
LemonBoy
ff79b87fa0 tools: Unbreak many tools
Many tools were broken after the recent hash-table refactorings, fix
them and ensure they won't silently break again.
2021-06-13 15:25:18 -04:00
Veikka Tuominen
37f36da391
Merge pull request #9092 from xackus/translate-c-type-parsing
translate-c: improve type parsing
2021-06-13 19:51:22 +03:00
Veikka Tuominen
f58fbb1004
Merge pull request #9074 from mattbork/parse-always-scratch
parse.zig: simplify parsing functions that build lists by always using scratch buffer
2021-06-13 19:49:41 +03:00
Veikka Tuominen
029fe6c9ab meta.cast: handle casts from negative ints to ptrs 2021-06-13 16:53:01 +03:00
xackus
e5750f8c7f translate-c: better numeric type parsing 2021-06-13 16:47:55 +03:00
xackus
aa83cbb697 translate-c: better typename parsing 2021-06-13 16:47:42 +03:00
Matthew Borkowski
483933d88d parse.zig: make parseForTypeExpr accept only a TypeExpr as body 2021-06-13 16:37:53 +03:00
Matthew Borkowski
3692fb039d parse.zig: simplify parseSwitchProng and make one item cases with trailing commas produce .switch_case_one nodes 2021-06-13 16:37:53 +03:00
Matthew Borkowski
51beb71480 parse.zig: simplify parsing functions that build lists by always using scratch buffer 2021-06-13 16:37:53 +03:00
joachimschmidt557
46b9e061e0 stage2 Sema: enable float multiplication and division 2021-06-13 15:24:28 +03:00
Veikka Tuominen
6664679c8c translate-c: don't bother with unwrapping pointers
Dereferencing a c pointer implicitly includes an unwrap,
manually adding it just causes bugs.
2021-06-13 15:23:31 +03:00
Jarred Sumner
540b52931a Improve error message when std.fmt.format is missing arguments
Use fmt in fmt so the number in the error message is fmt'd
2021-06-13 10:33:49 +03:00
viri
b2879825d7 std.windows: fix OVERLAPPED, add OVERLAPPED_ENTRY 2021-06-13 10:26:02 +03:00
Garrett Squire
a6d72fea06 Make std.ChildProcess exit code u8 to match std.process.exit
This patch adjusts the exit code for a child process to be a u8. Since
the WEXITSTATUS macro returns the lower eight bits, it's safe to assume
that we can truncate the returned u32.
2021-06-12 23:13:14 +03:00
Evan Haas
ea4a25287e translate-c: better support for static local variables
Don't move static local variables into the top-level scope since this
can cause name clashes if subsequently-defined variables or parameters
in different scopes share the name.

Instead, use a variable within a struct so that the variable's lexical
scope does not change. This solution was suggested by @LemonBoy

Note that a similar name-shadowing problem exists with `extern` variables
declared within block scope, but a different solution will be needed since
they do need to be moved to the top-level scope and we can't rename them.
2021-06-12 23:12:37 +03:00
LemonBoy
44cdafd9d4 std: Fix complex ldexp implementation
Two bugs in the implementation ported from musl made all the complex
functions relying on ldexp return incorrect results in some cases.

Spotted in #9047
2021-06-12 19:56:08 +03:00
Veikka Tuominen
0d022eb1d6 zig fmt: rewrite byteOffsetOf to offsetOf 2021-06-12 19:16:01 +03:00
Exonorid
f63338195d Renamed @byteOffsetOf to @offsetOf 2021-06-12 19:16:01 +03: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
Veikka Tuominen
2b2efa24d0 std.build: don't default to static linkage 2021-06-12 14:23:07 +03:00
Jakub Konka
05b5e49bc0
Merge pull request #9086 from ziglang/fix-9050
zig ld: act as linker for golang
2021-06-12 11:39:23 +02:00
xackus
b5c117d051 translate-c: fix enums that require c_uint type 2021-06-12 11:55:39 +03:00
LemonBoy
986a71234b std: Move PDB-related code into its own file
No functional changes are expected, this patch is only moving some code
in order to slim the huge bowl of spaghetti that is debug.zig.

The amount of memory leaked on error is much less than before but not
zero, some further work is required to smooth the edges of this old part
of the stdlib.
2021-06-12 10:51:43 +03:00
Andrew Kelley
caad5c4960 zig cc: recognize more pie flags
This is a bug fix.
2021-06-11 15:57:52 -07:00
Jakub Konka
6aa9c63f63 zld: throw an error if found unknown section in object
We will silently ignore expected section that are either won't take
part in linking such as any `__DWARF` section, or are known but are
not yet implemented such as `__TEXT,__eh_frame`. For any other
we will throw an error and exit.

Also, inform the caller that we currently are unable to handle
frameworks.
2021-06-12 00:03:47 +02:00
Jakub Konka
ac587744e3 zld: allow for existence of __DATA_CONST segments in objects
Up until now, we only expected old-fashioned objects which carried
two basic segments by name: __TEXT and __DATA. Since macOS 11.1,
there is a new segment __DATA_CONST, and we should expect and
correctly parse sections designated to that segment explicitly
as is the case in golang.
2021-06-11 23:06:43 +02:00
Andrew Kelley
f7361970b3
Merge pull request #8060 from DrDeano/feature/add-mcpu-to-target-options
Add CPU feature check to standardTargetOptions
2021-06-11 17:03:46 -04:00
Andrew Kelley
da4081fe21 cleanups to previous commit
* fix a merge conflict discovered upon rebasing latest master
 * rename Target.Cpu.Feature.Set.subSet to isSuperSetOf
 * convert a comment into an assert
2021-06-11 14:01:13 -07:00
Edward Dean
7ba175cd8b Add CPU feature check to standardTargetOptions
If there is a mismatch of CPU features provided
compared to the whitelist, then will fail the build and
print what the expected CPU model is and the feature
set for the model. Also prints what features need to be
removed.
2021-06-11 13:32:28 -07:00
Evan Haas
45212e3b33 translate-c: Implement flexible arrays
Fixes #8759
2021-06-11 21:31:39 +03:00
codic12
d8b133d733 c.zig: fix waitpid() definition 2021-06-11 20:43:14 +03:00
Ellis Trisk-Grove
ba7bfe949e std.build.InstallDir: make dupe() a public function
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-06-11 20:24:56 +03:00
Andrew Kelley
b6277a4b1c better awareness of unwind tables
* stage1 backend allows configuring the uwtables function attr
   via a flag rather than its own logic.
 * stage2 defaults to enabling uwtable attr when
   linking libunwind, or always on windows
 * stage2 makes link_eh_frame_hdr true automatically if uwtable
   attr is set to be on for zig functions
 * CLI: add -funwind-tables and -fno-unwind-tables to allow the user to
   override the defaults.
 * hook it up to `zig cc`

closes #9046
2021-06-11 13:23:00 -04:00
Asa Zeren
6cc8845802 Change defineCMacro to take separate name and value arugments
Before this change, when one or more of name or value are not known at
comptime, build.zig files must allocate and do the concatanation, which can be
cumbersome, and also adds a redundant allocation when name and value are
slices. The new version only does a single allocation directly in the builder's
allocator to concatonate name and value.

The origional behavior is available in defineCMacroRaw, for use in situations
such as parseing c compiler arguments.

Additionally, several places have been updated to use the new funtions.
2021-06-11 20:18:19 +03:00
Veikka Tuominen
0bde5ce369
Merge pull request #8330 from kivikakk/single-limb-bigint-overflow
bigint add failures with aliasing
2021-06-11 19:17:01 +03:00
Veikka Tuominen
c5d4122684
Merge pull request #7959 from MasterQ32/build_rewrite
Make build.zig ready for generated files
2021-06-11 19:13:14 +03:00
Jakub Konka
b93fd4bb73 zld: match all __DATA sections as __data except __const
Examples of such sections include:
* in Go, you will get `__DATA,__noptrdata` or `__DATA,__go_buildinfo`
  which should be mapped to `__DATA,__data`
2021-06-11 16:52:22 +02:00
codic12
1b3cc66334
c.zig: add sigfillset, alarm, sigwait
I've added these three functions to all switches except NetBSD, because I don't know what the function is named there. I've even added it on the .windows switch since all the posix functions seem to be there anyways.
2021-06-11 16:28:20 +03:00
Asherah Connor
e56ba4cee1 bigint: add ensureAdd(Scalar)Capacity, note aliasing requirements 2021-06-11 16:18:10 +03:00
Asherah Connor
b15e205438 bigint: use a stack local here to prevent aliasing issues 2021-06-11 16:18:10 +03:00
Asherah Connor
1db6018140 bigint: add failing tests for bigint carry 2021-06-11 16:18:06 +03:00
Veikka Tuominen
4b72b0560d make remaining enums in build.zig snake_case 2021-06-11 16:01:30 +03:00
LemonBoy
56c0a66ce3 std: Fix tanh for negative inputs
It turns out the code was not ported correctly from C and produced wrong
results for negative input values. As a bonus fix the NaN codepath by
adding yet another missing piece of code.

Spotted in #9047
2021-06-11 14:04:46 +03:00
viri
2ce033f415
std.os.windows: implement <timeapi.h> (#8801) 2021-06-11 12:19:35 +03:00
Jakub Konka
961d556570
Merge pull request #9069 from ziglang/zld-common-syms
zig ld: add common (tentative) symbols support
2021-06-11 10:18:43 +02:00
Felix (xq) Queißner
1c1ea2baa7 Code quality improvements to GeneratedFile, and manual implementation of Builder.addObjectSource. 2021-06-11 10:43:52 +03:00
Felix (xq) Queißner
98941cf27c Makes output path stuff more sane. 2021-06-11 10:43:38 +03:00
Felix (xq) Queißner
27bd0971bb Changes to .path instead of .getPathFn. Changes LibExeObjStep to also provide FileSource. 2021-06-11 10:39:50 +03:00