Commit graph

180 commits

Author SHA1 Message Date
Andrew Kelley
aef8bcf776 std.Build.Step.Compile: fine-grained system lib search control
For each library you can specify the preferred mode and search strategy.

The old way of setting global state is eliminated.
2023-08-03 09:52:15 -07:00
Fabio Arnold
31979b1006 Fix compile error in addVcpkgPaths 2023-08-03 09:37:26 -07:00
Mitchell Hashimoto
76f7b40e15 build: dupe library, rpath, and framework LazyPaths
Without duping, users could get some unexpected behavior if they used a
string with a lifetime that didn't persist throughout the full build,
i.e. if it wasn't heap allocated, or if it was explicitly freed.
2023-08-02 20:20:48 -07:00
Andrew Kelley
4d7dd1689f CLI: stop special-casing LLVM, LLD, and Clang
Before:

-fLLVM, -fLLD, -fClang, -flibLLVM
-fno-LLVM, -fno-LLD, -fno-Clang, -fno-libLLVM

After:

-fllvm, -flld, -fclang, -flibllvm
-fno-llvm, -fno-lld, -fno-clang, -fno-libllvm
2023-08-01 20:32:54 -07:00
GethDW
33e4cbb20f std.Build.Step.WriteFile: fix call to nonexistent function 2023-07-31 14:23:57 +02:00
Andrew Kelley
25a9487caa std.Build.LazyPath: fix resolution of cwd_relative
The callsites of getPath rely on the result being absolute so that they
can pass the path to a child process with the cwd set to the build root.
2023-07-30 18:42:08 -07:00
Andrew Kelley
bdbd617237 std.Build.Step.InstallArtifact: disable emit-h
This branch was not intended to introduce new test coverage on the
emit-h feature.

See #9698
2023-07-30 17:22:54 -07:00
Andrew Kelley
38840e2e58 build system: follow-up enhancements regarding LazyPath
* introduce LazyPath.cwd_relative variant and use it for --zig-lib-dir. closes #12685
* move overrideZigLibDir and setMainPkgPath to options fields set once
  and then never mutated.
* avoid introducing Build/util.zig
* use doc comments for deprecation notices so that they show up in
  generated documentation.
* introduce InstallArtifact.Options, accept it as a parameter to
  addInstallArtifact, and move override_dest_dir into it. Instead of
  configuring the installation via Compile step, configure the
  installation via the InstallArtifact step. In retrospect this is
  obvious.
* remove calls to pushInstalledFile in InstallArtifact. See #14943
* rewrite InstallArtifact to not incorrectly observe whether a Compile
  step has any generated outputs. InstallArtifact is meant to trigger
  output generation.
* fix child process evaluation code handling of `-fno-emit-bin`.
* don't store out_h_filename, out_ll_filename, etc., pointlessly. these
  are all just simple extensions appended to the root name.
* make emit_directory optional. It's possible to have nothing outputted,
  for example, if you're just type-checking.
* avoid passing -femit-foo/-fno-emit-foo when it is the default
* rename ConfigHeader.getTemplate to getOutput
* deprecate addOptionArtifact
* update the random number seed of Options step caching.
* avoid using `inline for` pointlessly
* avoid using `override_Dest_dir` pointlessly
* avoid emitting an executable pointlessly in test cases

Removes forceBuild and forceEmit. Let's consider these additions separately.
Nearly all of the usage sites were suspicious.
2023-07-30 11:19:32 -07:00
Felix "xq" Queißner
f8386de7ae Tries to fix Windows DLL linking. 2023-07-30 11:18:50 -07:00
Felix "xq" Queißner
35d0a49db9 Introduces Compile.forceBuild() and Compile.forceEmit(…) 2023-07-30 11:18:50 -07:00
Felix (xq) Queißner
5c01818410 Introduces Compile.getEmittedX() functions, drops Compile.emit_X. Resolves #14971 2023-07-30 11:18:50 -07:00
Felix (xq) Queißner
ce95a3b153 Build.zig rename orgy (aka: #16353). Renames FileSource to LazyPath and removes functions that take literal paths instead of LazyPath. 2023-07-30 11:18:50 -07:00
Jacob Young
e8e9a4ac66 Build: use optionals again
Closes #14952
2023-07-28 21:43:07 -07:00
kcbanner
8b9627f01d test: add a test that verifies no debug handlers get pulled into compiler_rt
build: fix CheckObject checkNotPresent only checking a single line of the haystack
2023-07-27 10:31:52 -04:00
Andrew Kelley
e8fa199602 std.Build.Step.Compile: getEmittedDocs API enhancements
* Allow calling it multiple times.
 * Rename it. Sorry, this is to coincide with #16353.
2023-07-24 02:37:25 -07:00
Andrew Kelley
575a7cccc0 CLI: delete dead option -femit-analysis
This used to do something with the old autodocs system. Now it does
nothing.
2023-07-24 02:37:25 -07:00
Jacob Young
c610cde1eb test: test for issues starting codegen on many targets
Specifically this is to make sure llvm data layout generation doesn't
regress.  The no emit bin is to allow testing targets that can't
currently be linked.  The commented out targets are ones that fail in
the linker anyway when no emit bin is passed.
2023-07-23 23:48:19 -04:00
Andrew Kelley
6e4fff6ba6 move installation logic to the build script where it belongs
* build.zig: introduce `-Dflat` option which makes the installation
  match what we want to ship for our download tarballs. This allows
  deleting a bunch of shell script logic from the CI.
  - for example it puts the executable directly in prefix/zig rather
    than prefix/bin/zig and it additionally includes prefix/LICENSE.
* build.zig: by default also install std lib documentation to doc/std/
  - this can be disabled by `-Dno-autodocs` similar to how there is
    already `-Dno-langref`.
* build.zig: add `std-docs` and `langref` steps which build and install
  the std lib autodocs and langref to prefix/doc/std and
  prefix/doc/langref.html, respectively.

* std.Build: implement proper handling of `-femit-docs` using the
  LazyPath system. This is a breaking change.
  - this is a partial implementation of #16351
* frontend: fixed the handling of Autodocs with regards to caching and
  putting the artifacts in the proper location to integrate with the
  build system.
  - closes #15864

* CI: delete the logic for autodocs since it is now handled by build.zig
  and is enabled by default.
  - in the future we should strive to have nearly all the CI shell
    script logic deleted in favor of `zig build` commands.
* CI: pass `-DZIG_NO_LIB=ON`/`-Dno-lib` except for the one command where
  we want to actually generate the langref and autodocs. Generating the
  langref takes 14 minutes right now (why?!) so we don't want to do that
  more times than necessary.

* Autodoc: fixed use of a global variable. It works fine as a local
  variable instead.
  - note that in the future we will want to make Autodoc run
    simultaneously using the job system, but for now the principle of
    YAGNI dictates that we don't have an init()/deinit() API and instead
    simply call the function that does the things.
* Autodoc: only do it when there are no compile errors
2023-07-22 00:16:27 -07:00
Jakub Konka
c0260d39d5 check-object: allow for multiple extractions within one check 2023-07-20 22:12:06 +02:00
Jakub Konka
245f6553e6 check-object: format known OS-specific types before doing generic format 2023-07-20 20:01:06 +02:00
Jakub Konka
3b6200db41 check-object: dump PT flags when dumping program headers 2023-07-20 20:01:06 +02:00
Jakub Konka
e8b613783f check-object: remove wildcard matchers as they are too clunky
Instead, we now have a looser helper called `checkContains(...)`
that will match on any occurrence similarly to `std.mem.indexOf()`.

While at it, I have cleaned up other combinators to make the entire
API more consistent, and so:
* `checkStart(phrase)` is now `checkStart()` followed by
`checkExact(phrase)`
* `checkNext(phrase)` if matching exactly is now `checkExact(phrase)`
* `checkNext(phrase)` if matching loosely is now `checkContains(phrase)`
* `checkNext(phrase)` if matching exactly with var extractors is now
`checkExtract(phrase)`

Finally, `ElfDumper` is now dumping contents of `.symtab` and `.dynsym`
symbol tables. I have also removed dumping of symtabs as optional - they
are now always dumped which cleaned up the implementation even more.
2023-07-20 20:01:06 +02:00
Jakub Konka
5839054e85 check-object: dump contents of .dynamic section 2023-07-20 20:01:06 +02:00
Luuk de Gram
1a3304ed23
test/link: add shared-memory test for WebAssembly 2023-07-19 17:22:46 +02:00
Jakub Konka
546212ff7b
Merge pull request #16398 from ziglang/check-object-elf
std: add ELF parse'n'dump functionality to std.Build.Step.CheckObject
2023-07-14 06:38:33 +02:00
Jakub Konka
77026c67a4 check-object: dump info on PHDRs 2023-07-13 21:27:18 +02:00
Jakub Konka
33154b511c check-object: dump more info on SHDRs 2023-07-13 20:31:19 +02:00
Jakub Konka
76dc0d5160 check-object: dump some info on SHDRs 2023-07-13 17:01:26 +02:00
Jakub Konka
4c3625d745 check-object: dump ELF header 2023-07-13 14:33:33 +02:00
Xavier Bouchoux
cea8645423 build: avoid repeating objects when linking a static library
Don't pass the object files from a static library to the linker invocation.
The lib.a file already contains them.

Avoids "duplicate symbol" errors (and useless work by the linker)
2023-07-11 11:46:59 +02:00
Michael Buckley
6bc9c4f716 std.Build: Add methods for creating modules from a TranslateC object. 2023-07-11 01:38:04 -07:00
Krzysztof Wolicki
a755310734
Changed Step.Run's stdin to accept FileSource (#16358) 2023-07-09 15:51:41 -04:00
Jakub Konka
44df3a148b std: add prefixed versions of addFileSource and addDirectorySource to Step.Run 2023-07-06 17:03:28 -07:00
Andrew Kelley
8ae92fd17e std.Build.Step.Compile: fix clearing logic for empty cflags
Commit c0b774fbc6 originally added this
logic but it did not properly clear the C command line flags to empty
when a previous positional argument had command line flags, because it
never set the "previous" flag to true.

This fixes C compiler flags not being reset to empty when using the
build system and a second positional argument has no arguments after a
first positional argument has arguments.

Thanks to @squeek502 for finding this.
2023-07-04 10:53:35 -07:00
Ian Johnson
bbda053f9e Build: make InstallDirStep use a FileSource
Closes #16187
2023-06-26 15:59:53 -07:00
Jan200101
42ca357604 std.Build: omit newline from last line 2023-06-26 04:25:14 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Jan200101
1864ba2ccc
std.Build: implement variable substitution 2023-06-21 21:51:07 +02:00
Jan200101
5177068c88
std.Build: correctly implement cmakedefine and cmakedefine01 2023-06-21 21:51:06 +02:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
r00ster91
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
r00ster91
2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Isaac Freund
a2f54fce53 std.Build.Step.Run: add stdin to cache manifest 2023-06-16 05:35:30 +00:00
Andrew Kelley
38fc826a5a
Merge pull request #15957 from BratishkaErik/deprecated-
std.*: remove stuff that was deprecated in older versions
2023-06-13 14:53:41 -07:00
Lee Cannon
21c258acac allow run step to skip foreign binary execution if executor fails 2023-06-13 11:27:45 -07:00
Zapolsky Anton
c76ce25a61
Remove CheckObjectStep.runAndCompare (#15973)
Closes #14969
2023-06-13 14:09:24 -04:00
Eric Joldasov
6078781ae5
std.Build.Step.Compile: remove addSystemIncludeDir, addIncludeDir, addLibPath, and addFrameworkDir (deprecated in 0.10)
Followup to d3d24874c9.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Andrew Kelley
629f0d23b5
Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
xEgoist
ff57a264ad
Build: fix producesPdbFile logic (#15756)
Fixes bug causing ReleaseSmall to fail on Windows.

Due to the change in default behavior of ReleaseSmall, debug info are
stripped by default. However because `Compile.create` still defaults to
null, `producesPdbFile` will report true for
`lib/std/Build/Step/InstallArtifact.zig` causing it to fail on copying a
file that does not exist. This commit change the default of strip
depending on `optimize`.
2023-06-03 16:45:08 -04:00
kcbanner
9244e4fe2d cache: handle 0-length prefix paths in findPrefixResolved 2023-05-30 01:21:01 -07:00