Commit Graph

67 Commits

Author SHA1 Message Date
Andrew Kelley 105db13536 std.Build: implement --host-target, --host-cpu, --host-dynamic-linker
This also makes a long-overdue change of extracting common state from
Build into a shared Graph object.

Getting the semantics right for these flags turned out to be quite
tricky. In the end it works like this:
* The override only happens when the target is fully native, with no
  additional query parameters, such as versions or CPU features added.
* The override affects the resolved Target but leaves the original Query
  unmodified.
* The "is native?" detection logic operates on the original, unmodified
  query. This makes it possible to provide invalid host target
  information, causing confusing errors to occur. Don't do that.

There are some minor breaking changes to std.Build API such as the fact
that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful
of other similar flags.
2024-02-02 20:43:01 -07:00
Veikka Tuominen 828d23956d std.heap: add runtime safety for calling stackFallback(N).get multiple times
Closes #16344
2024-01-09 17:18:20 -08:00
Carl Åstholm c8fa767f08 Work around stage1 not yet returning null-terminated @typeInfo strings
These changes can be reverted the next time stage1 is updated.
2024-01-07 16:21:08 +01: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 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
Veikka Tuominen 69195d0cd4 AstGen: add error for using inline loops in comptime only scopes 2023-12-08 16:54:32 -08: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
Veikka Tuominen d2a8660d04 sync Aro dependency
ref: 9d538ea0253bb63c0b35ec907a3a734d1e22fc32
2023-11-25 04:52:21 +02:00
Andrew Kelley a34a51ef6e aro: use ArrayList in GCCDetector instead of BoundedArray
These arrays don't really all have an upper bound of 16; in fact they
have different upper bounds. Presumably the reason 16 was used for all
of them was to avoid code bloat with BoundedArray. Well, now even more
code bloat has been eliminated because now it's using
`ArrayList([]const u8)` which is certainly instantiated elsewhere.
Furthermore, the different corrected upper bounds can be specified at
each instance of the array list.
2023-11-22 11:33:34 -07:00
Andrew Kelley 44ae978523 aro: avoid BoundedArray in text_literal
I consider this change to be neutral. It inlines a bit of logic that
previously was abstracted, however, it also eliminates an instance of
`catch unreachable` as well as a clumsy failed pop / append in favor of
writing directly to the appropriate array element.
2023-11-22 11:33:34 -07:00
Andrew Kelley 9393a83323 aro: use std.fmt.bufPrint rather than BoundedArray
This simplifies the logic. For example, in generateExactWidthType, it no
longer has to save a previous length and then use defer to reset the
length after mutating it.
2023-11-22 11:33:34 -07:00
Veikka Tuominen 145ddb8104 sync Aro dependency
ref: 0c8c251e336148413ceca7b345c0b6f7255b009b
2023-11-15 11:26:49 +02:00
Evan Haas e6b9312bd0 aro: Add stub definitions to enable bootstrapping
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-11-03 22:18:40 +02:00
Evan Haas 9ea0c3b4c6 sync Aro dependency
ref: 45eb8a700bfa885af7144a54ffd01f291c6f598f
2023-11-02 22:45:58 -07:00
Andrew Kelley 3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Veikka Tuominen 58b07ea14f sync Aro dependency
ref: 482951b0e0eb99ec5dd122e7f893a007586f83f4
2023-10-17 11:55:01 +03:00
Veikka Tuominen 5792570197 add Aro sources as a dependency
ref: 5688dbccfb58216468267a0f46b96bed7013715a
2023-10-01 23:51:54 +03:00
Andrew Kelley 3ba916584d actually remove stage1 2022-12-06 12:15:04 -07:00
Cody Tapscott aedafb20cf stage2: Fix softfloat support for PPC64(LE)
Stage 2's softfloat support still had a couple of gaps, which were
preventing us from lowering `f16` on this target. With any luck,
this is enough to get PPC64 working as a Tier 2 target again.
2022-10-13 12:53:20 -07:00
Cody Tapscott 319b5cbce5 Do not detect byte-order using _BIG/_LITTLE_ENDIAN
These defines are present on some FreeBSD systems, regardless of
whether the system is big- or little- endian. This was causing the
FreeBSD CI to be incorrectly flagged as big-endian.

Resolves https://github.com/ziglang/zig/issues/11391
2022-04-12 11:14:33 -07:00
Andrew Kelley 1c23321d03 stage1: fix softfloat not getting correct endianness
needed to include platform.h in more places so that LITTLEENDIAN will be
defined appropriately.

closes #10860
2022-02-12 11:18:23 +01:00
Tadeo Kondrak 26546af1b8 Revert "Include dbg.h to third-party libs"
This reverts commit c8b4cc2ff9.

This includes many C++ standard library headers:

  #include <algorithm>
  #include <chrono>
  #include <ctime>
  #include <iomanip>
  #include <ios>
  #include <iostream>
  #include <memory>
  #include <sstream>
  #include <string>
  #include <tuple>
  #include <type_traits>
  #include <vector>

which adds more than a second of compile time for each file that
includes the header:

  ir.cpp before: 8.041s
  ir.cpp after: 6.847s
2020-10-03 21:29:29 -04:00
daurnimator f5167f73e8 deps/SoftFloat-3e/: commit with LF line endings
`git add --renormalize .`

For text files, git expects that all files are commited with LF line endings,
it then (optionally) swaps to CRLF on checkout depending on .gitattributes and
git config.
2020-05-31 12:18:31 -04:00
data-man c8b4cc2ff9 Include dbg.h to third-party libs 2020-05-02 18:29:02 -04:00
Andrew Kelley ba4cc03b4f remove embedded LLD
we no longer have any patches against upstream LLD
2020-01-16 13:09:45 -05:00
Andrew Kelley e92d74958c lld: apply patch: [mach-o] Extend LC_DATA_IN_CODE support to x86_64
This applies 91864f82c7d7bd1a151fdfd076a3a67a2893b868 from LLVM trunk to
the embedded LLD.

Once Zig upgrades to LLD 10, there will be no difference between Zig's
fork and upstream, and Zig's fork can be dropped.
2019-09-10 13:25:20 -04:00
Andrew Kelley 016a59e3a1 update embedded LLD to 9.0.0rc4 2019-09-10 13:10:12 -04:00
Andrew Kelley 2f3ad48c9b LLD patch: workaround for buggy MACH-O code
This reapplies 5ce1a965e0
to the embedded LLD.
2019-08-20 19:42:41 -04:00
Andrew Kelley 37a06f4dcf update embedded LLD to 9.0.0-rc2
upstream commit 67a4a12d61bfb10b2410b53c5a43ef9b4a03de7d
2019-08-20 19:33:58 -04:00
Andrew Kelley 5ce1a965e0 LLD patch: workaround for buggy MACH-O code
This reapplies 182cd0e4c0
to the embedded LLD.
2019-08-03 12:56:35 -04:00
Andrew Kelley ffab950e0c update embedded LLD to 9.0.0rc1 2019-08-03 12:56:35 -04:00
Andrew Kelley c8b60538ed add patch to LLD to fix deadlock race condition in wasm linker
Patch is getting upstreamed here: https://reviews.llvm.org/D60757
And so this patch can be removed with LLVM 9.0.0.
2019-04-16 03:56:46 -04:00
Andrew Kelley 182cd0e4c0 LLD patch: workaround for buggy MACH-O code
This reapplies 00902ff9b0
to the embedded LLD.
2019-02-28 12:54:11 -05:00
Andrew Kelley 5768fcb085 update embedded LLD to 8.0.0rc3 2019-02-28 12:53:08 -05:00
Andrew Kelley 00902ff9b0 LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2019-02-07 17:08:25 -05:00
Andrew Kelley 3e08b3a4f8 update embedded LLD to 8.0.0rc2 2019-02-07 17:07:18 -05:00
Andrew Kelley 9ac838c8e3 LLD patch: allow non-allocated sections to go into allocated sections
Patch submitted upstream: https://reviews.llvm.org/D55276
2018-12-04 11:42:22 -05:00
Andrew Kelley e077d765fe LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2018-09-10 15:54:51 -04:00
Andrew Kelley 54e470f936 update embedded LLD to 7.0.0rc3 2018-09-10 15:54:16 -04:00
Andrew Kelley 20810e0a79 LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2018-08-25 22:11:32 -04:00
Andrew Kelley 95dbba046d update LLD fork to 7.0.0rc2 2018-08-25 22:10:32 -04:00
Andrew Kelley ee68f28bba LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2018-08-04 18:19:26 -04:00
Andrew Kelley cfb29f18e4 update embedded LLD to 7.0.0rc1 2018-08-04 17:47:16 -04:00
Andrew Kelley 95f45cfc34 patch LLD to fix COFF crashing when linking twice in same process
closes #1289
2018-07-25 02:36:29 -04:00
Andrew Kelley 2b86ffe34a LLD patch: Do not keep shared symbols to garbage...
-collected eliminated DSOs.

This applies https://reviews.llvm.org/D45536 to the embedded
LLD.

Closes #883
2018-04-11 18:15:33 -04:00
Andrew Kelley 5a7a0e8518 update to SoftFloat-3e
closes #823
2018-03-09 15:06:06 -05:00
Andrew Kelley 1ba6e1641a LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2018-02-23 13:05:17 -05:00
Andrew Kelley a33b689f2c update embedded LLD to 6.0.0rc3 2018-02-23 13:04:47 -05:00
Andrew Kelley 5d9e3cb77f LLD patch: workaround for buggy MACH-O code
This reapplies 1a1414fc42
to the embedded LLD.
2018-02-07 17:38:33 -05:00
Andrew Kelley 38aed5af8b update embedded LLD to 6.0.0rc2 2018-02-07 17:38:02 -05:00