6442 Commits

Author SHA1 Message Date
Andrew Kelley
b92e30ff0b std.Build.ResolvedTarget: rename target field to result
This change is seemingly insignificant but I actually agonized over this
for three days. Some other things I considered:

* (status quo in master branch) make Compile step creation functions
  accept a Target.Query and delete the ResolvedTarget struct.
  - downside: redundantly resolve target queries many times
* same as before but additionally add a hash map to cache target query
  resolutions.
  - downside: now there is a hash map that doesn't actually need to
    exist, just to make the API more ergonomic.
* add is_native_os and is_native_abi fields to std.Target and use it
  directly as the result of resolving a target query.
  - downside: they really don't belong there. They would be available
    as comptime booleans via `@import("builtin")` but they should not
    be exposed that way.

With this change the downsides are:
* the option name of addExecutable and friends is `target` instead of
  `resolved_target` matching the type name.
  - upside: this does not break compatibility with existing build
    scripts
* you likely end up seeing `target.result.cpu.arch` rather than
  `target.cpu.arch`.
  - upside: this is an improvement over `target.target.cpu.arch` which
    it was before this commit.
  - downside: `b.host.target` is now `b.host.result`.
2024-01-01 17:51:18 -07:00
Andrew Kelley
8c44954bc6 std.Target.Query: remove deprecated API
These functions have been doomed for a long time. Finally I figured out
what the proper relationship between this API and std.Target is.
2024-01-01 17:51:18 -07:00
Andrew Kelley
dbdb87502d std.Target: add DynamicLinker 2024-01-01 17:51:18 -07:00
Andrew Kelley
3179f58c41 rename std.zig.CrossTarget to std.Target.Query 2024-01-01 17:51:18 -07:00
Andrew Kelley
f10b5268e8 fix windows-only test case not upgraded to new build API 2024-01-01 17:51:18 -07:00
Andrew Kelley
04480f72d8 fix linker test regressions
Caused by problems with transitive dependencies
2024-01-01 17:51:18 -07:00
Andrew Kelley
142471fcc4 zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.

The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.

* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
  std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
  std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
  `std.Build.Module.addCMacro` is provided.
  - remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
  - use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
  - use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
  Along with other fields, those unspecified options will be inherited
  from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
  to get the host target.
2024-01-01 17:51:18 -07:00
Andrew Kelley
2b58978360 Revert "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
This reverts commit 7161ed79c4abcaccdd56fe0b4fbd3d93472d41b8, reversing
changes made to 3f2a65594e1d3c0a4f4943a4ea522e8405db81e0.

Unfortunately, this sat in the PR queue too long and the merge broke the
zig1.wasm bootstrap process.
2024-01-01 17:49:57 -07:00
Andrew Kelley
7161ed79c4
Merge pull request #17824 from kcbanner/fixup_msvc_fmax
cbe: add a system for avoiding collisions with C compiler intrinsics
2024-01-01 15:36:16 -08:00
amp-59
27d4bf7534
Sema: Initialise want_safety for switch prong child block 2023-12-29 11:42:44 +00:00
Jacob Young
d312665803 Sema: ensure slice_ptr produces the correct type
Closes #18345
2023-12-23 02:08:58 -05:00
Stefan Su
42ddf592dd
use casted_rhs instead of rhs so icmp works correctly for airShlSat 2023-12-22 14:51:41 +00:00
Meghan Denny
cbf2b1fea4 test: add coverage for index into comptime-known vector is comptime-known 2023-12-22 04:44:15 +02:00
Jakub Konka
f26459e594 lib/std/Build/CheckObject: update all tests to new API 2023-12-13 12:06:25 +01:00
Andrew Kelley
3d23ba9c35 Revert "Sema: forbid @breakpoint from being called at comptime"
This reverts commit f88b523065fbb8afbd723fd6e803ace0334b713c.

Let's please go through the language proposal process for this change. I
don't see any justification for this breaking change even in the commit
message.
2023-12-11 12:24:15 -07:00
Bogdan Romanyuk
f88b523065
Sema: forbid @breakpoint from being called at comptime 2023-12-11 17:52:19 +02:00
Jakub Konka
5c0d58b71f
Merge pull request #18243 from ziglang/check-macho-more
lib/std/Build/CheckObject: dump more Mach-O info
2023-12-10 09:48:50 +01:00
Jakub Konka
eb70c8801e lib/std/Build/CheckObject: dump Mach-O symbol attributes 2023-12-09 09:38:23 +01:00
Veikka Tuominen
69195d0cd4 AstGen: add error for using inline loops in comptime only scopes 2023-12-08 16:54:32 -08:00
Jakub Konka
d05db52616 elf: copy out committed ZigObject to a buffer when creating static lib 2023-12-05 17:29:26 +01:00
Jakub Konka
ee1630beea elf: exit early with an error when parsing or init failed 2023-12-05 16:31:47 +01:00
Jakub Konka
297c39ff56 test/link/elf: adjust tests for new errors 2023-12-05 14:40:13 +01:00
Jacob Young
c70c333594 x86_64: fix packed struct field reuse 2023-12-04 13:31:54 -05:00
Jacob Young
bdb6546a8f x86_64: fix vector comparisions 2023-12-04 13:09:13 -05:00
Jacob Young
50993a8f08 x86_64: implement more operations on vectors with 1-bit elements 2023-12-04 01:29:07 -05:00
Jacob Young
485e20884c x86_64: implement movement for pointer vectors 2023-12-03 23:07:50 -05:00
Jacob Young
7c85ea65ba x86_64: "implement" aggregate_init for vectors 2023-12-03 13:55:31 -05:00
Jacob Young
e00f1397e3 x86_64: implement some todos 2023-12-03 10:24:03 -05:00
Jacob Young
014833b61f x86_64: implement more compliant vectors 2023-12-03 10:22:06 -05:00
Jacob Young
917b4ad5e0 x86_64: implement more atomic ops 2023-12-03 10:22:06 -05:00
Jacob Young
bf5ab54510 test: test with -fstrip and fix failures
Closes #17513
2023-12-01 04:34:50 +00:00
Veikka Tuominen
39a966b0a4 Sema: improve error location for array cat/mul 2023-11-30 13:15:40 +02:00
David Rubin
1e42a3de89
Remove all usages of std.mem.copy and remove std.mem.set (#18143) 2023-11-29 16:03:02 -05:00
Luuk de Gram
4115f70cd3
test/link: update wasm linker tests
Disable garbage-collection for certain tests to ensure the tested
sections are being emitted.
2023-11-28 18:32:31 +01:00
Bogdan Romanyuk
7fbbeae617
value: handle lazy_align and lazy_size in writeToPackedMemory 2023-11-27 12:35:29 +00:00
Andrew Kelley
7103088e4a
Merge pull request #18105 from Vexu/translate-c
Use Aro's tokenizer in `translate-c`
2023-11-26 02:22:51 -05:00
Bogdan Romanyuk
2252dcc508
Compiler: move checking function-scope-only builtins to AstGen 2023-11-25 17:29:07 +00:00
Bogdan Romanyuk
bece97ef24
Sema: ensure tuple fields is resolved and fix internal out-of-bounds access 2023-11-25 14:05:51 +00:00
Tw
2fefc0b5c7
Zir: add missing extra index for linksection_or_addspace
Closes #18052
Closes #18104

Signed-off-by: Tw <tw19881113@gmail.com>
2023-11-25 11:39:37 +00:00
Veikka Tuominen
74010fecc7 translate-c: use Aro's tokenizer 2023-11-25 12:28:19 +02:00
Garrett
a277181c66
translate-c: use struct_init_one for empty struct initializer 2023-11-24 22:44:33 +00:00
Robin Voetter
28e1d82857
spirv: disable failing tests 2023-11-24 01:11:12 +01:00
Andrew Kelley
f4e426a06c
Merge pull request #18076 from ziglang/revert-iterable-dir
std.fs: Absorb `IterableDir` into `Dir`
2023-11-23 01:44:07 -05:00
Bogdan Romanyuk
aa31096cbd
Sema: disallow call to undefined function 2023-11-23 02:08:15 +00:00
Andrew Kelley
e357550610 update for the std.fs.Dir changes 2023-11-22 15:24:57 -07:00
Andrew Kelley
d5e21a4f1a std: remove meta.trait
In general, I don't like the idea of std.meta.trait, and so I am
providing some guidance by deleting the entire namespace from the
standard library and compiler codebase.

My main criticism is that it's overcomplicated machinery that bloats
compile times and is ultimately unnecessary given the existence of Zig's
strong type system and reference traces.

Users who want this can create a third party package that provides this
functionality.

closes #18051
2023-11-22 13:24:27 -05:00
Andrew Kelley
54d196bb30
Merge pull request #18057 from Vexu/fixes
Fix bad error location on field init with field access
2023-11-21 15:12:03 -05:00
Andrew Kelley
be6f76655f
Merge pull request #18055 from ziglang/zig-init 2023-11-21 11:59:24 -05:00
Garrett
40b8c993f5
translate-c: skip blank macros when translating defines 2023-11-21 13:54:46 +00:00
Carl Åstholm
8bf4b3c611 translate-c: translate 80/128-bit long double literals 2023-11-21 14:14:01 +02:00