Commit Graph

156 Commits

Author SHA1 Message Date
Andrew Kelley
73cf7b6429 update build.zig API usage 2023-01-31 15:09:35 -07:00
Veikka Tuominen
f83834993e std: collect all options under one namespace 2023-01-05 02:31:29 -07:00
Ryan Liptak
3db8cffa3b spawnWindows: Fix PATH searching when cwd is absolute
Fixes a regression caused by https://github.com/ziglang/zig/pull/13983

From the added comment:

We still search the path if the cwd is absolute because of the
"cwd set in ChildProcess is in effect when choosing the executable path
to match posix semantics" behavior--we don't want to skip searching
the PATH just because we were trying to set the cwd of the child process.
2022-12-19 04:12:46 -05:00
Ryan Liptak
0cbc59f227 standalone tests: Add windows spawn test
Tests a decent amount of edge cases dealing with how PATH and PATHEXT searching is handled.
2022-12-18 03:55:28 -08:00
Andrew Kelley
b1793c2b52 add test coverage for zig build CLI and options API 2022-11-30 13:22:43 -07:00
dweiller
ae0f12885b test: add test_runner_path test 2022-11-02 22:41:20 +11:00
Jacob Young
c7f9833238 Module: fix early exit conditions during compilation
* `--verbose-llvm-ir` should trigger analysis and codegen
 * `-femit-asm` etc should trigger codegen even with `-fno-emit-bin`

Closes #12588
2022-10-15 14:18:35 -04:00
Jacob Young
9b45dc1608 stage2: fix emitting asm and bin at the same time
This logic is copied from stage1.

Fixes #12800
2022-10-14 14:46:50 -04:00
Cody Tapscott
05915b85dd compiler-rt: Implement mulXc3 and divXc3 functions
These are the standard complex multiplication/division functions
required by the C standard (Annex G).

Don't get me started on the standard's handling of complex-infinity...
2022-10-09 11:09:41 -07:00
Jacob Young
9cad44770a test/standalone: remove unneeded FnPtr
The behavior of this test is not affected by an extra level of
indirection.
2022-10-03 10:28:30 -04:00
Jacob Young
b7bd44a654 Sema: ensure builtin.StackTrace fields are analyzed
When encountering a fn type that returns an error (union), a backend
that supports error return tracing will want the StackTrace struct and
its fields to be analyzed.
2022-10-01 08:09:43 -04:00
Jacob Young
8b66443d50 llvm: avoid undefined values by ensuring the StackTrace decl is analyzed
The test builds an object file to prevent StackTrace from already having
been analyzed by other code.

Fixes #13030
2022-10-01 04:02:09 -04:00
Veikka Tuominen
694fab4848 std: add return address parameter to panic fn 2022-09-20 19:05:00 -07:00
Veikka Tuominen
db54cd247d Sema: do not emit dbg_inline_end after NoReturn
Closes #12698
2022-09-02 17:57:10 +03:00
Veikka Tuominen
2cd3989cb3 Sema: add more validation to coerceVarArgParam
Closes #12706
2022-09-01 13:16:33 +03:00
Evan Haas
bcaa9df5b4 translate-c: Don't add self-defined macros to global name table
A self-defined macro is one of the form `#define FOO FOO`

Those types of macros have never been translated; this change will cause
any macros which refer to them to be translated as `@compileError` instead
of referring to a non-existent identifier.

Closes #12471
2022-08-26 11:24:57 +03:00
Veikka Tuominen
a463dc7d6c AstGen: disable null bytes and empty stings in some places
Namely:
 * test names
 * identifiers
 * library names
 * import strings
2022-07-26 12:14:59 +03:00
Andrew Kelley
be294e3744 CI stage3 test coverage for test-standalone 2022-07-24 15:02:05 -07:00
Ali Chraghi
0b4a3ec950 std: compile error on invalid testing allocator usage 2022-07-24 11:57:00 +03:00
Andrew Kelley
3114978389 update standalone test cases for stage2 2022-07-21 22:51:17 -07:00
Andrew Kelley
8e07b0c4b9 Merge remote-tracking branch 'origin/master' into llvm14 2022-07-07 14:01:54 -07:00
r00ster91
6f17be063d
std.log: give friendly error to freestanding users 2022-07-07 21:40:31 +03:00
Andrew Kelley
6164801efb update install_raw_hex test case
LLVM 14 optimizes differently, so it's reasonable to have there be a
binary difference here.
2022-07-06 11:52:21 -07:00
Jakub Konka
38edef35bf test: introduce link(er) tests - builds on standalone tests 2022-06-20 17:59:17 +02:00
Andrew Kelley
45415093c6 reduce the scope of this branch
* back out the changes to RunStep
 * move the disabled test to the .cpp code and avoid a confusing
   name-collision with the _LIBCPP macro prefix
 * fix merge conflict with the edits to the same test that ensure global
   initializers are called.

Now this branch is only concerned with single-threaded targets and
passing the correct macro defines to libc++.
2022-05-10 17:31:54 -07:00
Alexander Slesarev
3997828a61 Added _LIBCPP_HAS_NO_THREADS for single_threaded binaries linked with libcxx.
Fixed single-threaded mode for Windows.
2022-05-10 16:40:48 -07:00
Evan Haas
94b9bcd034 stdlib: escape backslashes and double quotes in Builder response file
Fixes #11595
2022-05-09 18:42:42 +03:00
Andrew Kelley
5aa35f62c3 Revert "reduce build error noise"
This reverts commit baead472d7.

Let's go through the proposal process on this one. I want to push back
on this. My position is that, at the very least, a full trace of command
lines of sub-processes should be printed on failure, with the exception
of opt-in flags such as `--prominent-compile-errors`.
2022-02-17 14:30:12 -07:00
Jonathan Marler
baead472d7 reduce build error noise
Address https://github.com/ziglang/zig/issues/3477
This provides a mechanism for builds to fully report an error to the user and prevent zig from piling on extra noise.
2022-02-17 14:48:22 +02:00
Jonathan Marler
3f341bdc26
Normalize some build function names
An attempt to normalize some of the function names in build.zig.  Normalize add*Dir to add*Path.  Also use "Library" instead of the "Lib" abbreviation.

The PR does not remove the old names, only adds the new normalized ones to faciliate a transition period.
2022-01-24 20:15:32 +02:00
xavier
3f52132a8f tests: include global initializers in c++ compiler test 2022-01-14 11:48:38 -07:00
Meghan
c08b190c69
lint: duplicate import (#10519) 2022-01-07 00:06:06 -05:00
Jakub Konka
bd926e5ea0 add standalone tests for the new linker bug fixes
This is just a temp addition until I figure out how to tweak
the stage2 test harness to add the ability to test the linker too.
2021-12-15 10:31:29 +01:00
Jonathan Marler
7659229edc std.build.InstallRawStep: allow custom dest_dir
I'm working on a build.zig file where I'm leveraging InstallRawStep but I'd like to change the install dir.  This allows the install dir to be changd and also enhances InstallRawStep to add more options in the future by putting them into a struct with default values.  This also removes the need for an extra addInstallStepWithFormat function in build.zig.
2021-12-03 12:56:49 -08:00
Lee Cannon
80bbf234e0
allocgate: fix failing tests 2021-11-30 23:32:48 +00:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00:00
Andrew Kelley
20cc7af8e6 stage2: support LLD -O flags on ELF
In 7e23b3245a I made -O flags to the
linker emit a warning that the argument does nothing. That was not
correct however; LLD does have some logic that does different things
depending on -O0, -O1, and -O2. It defaults to -O1, and it does less
optimizations with -O0 and more with -O2.

With this commit, e.g. `-Wl,-O1` is supported by the `zig cc` frontend,
and by default we pass `-O0` to LLD in debug mode, and `-O3` in release
modes.

I also fixed a bug in the LLD ELF linker line which was incorrectly
passing `-O` flags instead of `--lto-O` flags for LTO.
2021-11-24 18:46:32 -07:00
Stephen Gutekanst
9836f1b2f9
add support for compiling Objective-C++ code (#10096)
* add support for compiling Objective-C++ code

Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions
(`.mm`) would result in an error due to Zig not being aware of that extension.
Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use
if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to
workaround Zig being unaware of the extension.

This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation
of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using
a `build.zig` file only.

Helps hexops/mach#21

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>

* test/standalone: add ObjC++ compilation/linking test

Based on the existing objc example, just tweaked for ObjC++.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-22 08:44:49 +01:00
Andrew Kelley
fb99808008 tests: disable LTO for windows until issues can be resolved
See #8531
2021-11-16 12:44:44 -07:00
Andrew Kelley
08c768ad82 pre-merge cleanups
* Annotate workarounds with their corresponding GitHub issue links.
 * Enable test coverage for LTO on Windows with the added c_compiler test.
2021-11-15 16:32:15 -07:00
xavier
353c19468d test: add a standalone test for mixing c, zig, threadlocal and build modes.
based on https://github.com/ziglang/zig/issues/8531
2021-11-15 16:15:39 -07:00
Jakub Konka
6cf5305e47 macho: remove unresolved ref in the correct place
* without this, when an included relocatable references a common symbol
  from another translation unit would not be correctly removed from
  the unresolved lookup table triggering a misleading assertion down
  the line
* assert upon removal that we indeed removed a ref instead of silently
  ignoring in debug
* add test case that covers this issue
2021-10-24 21:01:04 +02:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
3eb729b442 Merge remote-tracking branch 'origin/master' into llvm13 2021-09-30 21:38:04 -07:00
Jakub Konka
affd8f8b59 macho: fix incorrect segment/section growth calculation
Otherwise, for last sections in segments it could happen we would
not expand the segment when actually required thus exceeding the
segment's size and causing data clobbering and dyld runtime errors.
2021-09-21 20:22:52 +02:00
Andrew Kelley
1f653b7f8e update install_raw_hex standalone test for llvm13 2021-09-15 17:33:18 -07:00
Michal Ziulek
e06052f201
Added implementation for _fseeki64 and _ftelli64 from mingw-w64 9.0.0 (#9402). (#9766)
* Added fseeki64.c from mingw-w64 9.0.0. This file was missing in Zig distribution. This file contains implementation for _fseeki64 and _ftelli64 functions.
2021-09-15 13:38:00 -04:00
Andrew Kelley
d305ba7f2d
Merge pull request #9636 from ehaas/hexfiles
stdlib: Add Intel HEX support to InstallRawStep
2021-09-07 15:12:00 -04:00
Jacob G-W
107e3ba3cd add standalone test for issue #9693 2021-09-06 15:16:30 -04:00