Commit Graph

182 Commits

Author SHA1 Message Date
Jacob Young
7e0c6d7edc Sema: fix empty infinite loops
Closes #15284
2023-04-17 02:30:10 +03:00
Andrew Kelley
3c3cee2cfa fix build logic due to state mutations and break the API accordingly
* remove setName, setFilter, and setTestRunner. Please set these
   options directly when creating the CompileStep.
 * removed unused field
 * remove computeOutFileNames and inline the logic, making clear the
   goal of avoiding state mutations after the build step is created.
2023-04-11 08:42:14 -07:00
Andrew Kelley
60eabc0eca std.Build.CompileStep: remove run() and install()
These functions are problematic in light of dependencies because they
run and install, respectively, for the *owner* package rather than for
the *user* package. By removing these functions, the build script is
forced to provide the *Build object to associate the new step with,
making everything less surprising.

Unfortunately, this is a widely breaking change.

see #15079
2023-04-10 18:35:14 -07:00
Andrew Kelley
f289277599 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-05 22:05:31 -07:00
dweiller
ff97bd21c3 tests: enable test_runner_module_imports standalone test 2023-03-30 11:53:07 +03:00
Andrew Kelley
8f481dfc3c fix std.Build.OptionsStep
* use the same hash function as the rest of the steps
 * fix race condition due to a macOS oddity.
 * fix race condition due to file truncation (rename into place instead)
 * integrate with marking Step.result_cached. check if the file already
   exists with fs.access before doing anything else.
 * use a directory so that the file basename can be "options.zig"
   instead of a hash digest.
 * better error reporting in case of file system failures.
2023-03-19 00:39:29 -04:00
Andrew Kelley
5c913fb2bc disable failing standalone test on windows
See tracking issue #14800
2023-03-16 22:02:06 -07:00
Andrew Kelley
4d7e77cb17 remove standalone test "issue_9812"
This test has a few problems:

 * I don't want to vendor third party projects into the main compiler
   repository such as kuba-zip just for test cases. If we want to test
   third party projects, that should be a separate repository dedicated
   to that purpose.

 * Ideally tests would be isolated to test a particular thing, rather
   than have a lot of unrelated logic that is not what is primarily
   being tested.

 * Ideally tests will not be named after GitHub issues, but named after
   the thing that is being tested. And not testing for the absence of a
   bug, but for the existence of correct behavior.

Aside from these issues, it's also failing in the LLVM 16 branch:

```
kuba-zip/zip.c:276:16: error: call to undeclared function 'fileno'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kuba-zip/zip.c:277:14: error: call to undeclared function 'ftruncate'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kuba-zip/zip.c:364:11: error: call to undeclared function 'symlink'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
```

These are not interesting failures related to the thing actually being
tested; this is busywork related to the fact that we vendor third party
code. So, that is why I chose to delete this test case instead of repair
it.
2023-03-16 21:51:58 -07:00
Andrew Kelley
1a70ea0576 windows_spawn standalone test: test on native OS
In master branch this test tests native Windows. In this branch, I
accidentally made aarch64-windows test x86_64-windows which caused some
subtle behavior that we aren't ready to add test coverage for yet.
2023-03-15 10:48:15 -07:00
Andrew Kelley
fa9108c3d4 add skip_foreign_checks=true on a standalone test 2023-03-15 10:48:15 -07:00
Andrew Kelley
c5cdc0262b add the new extern test to standalone tests
This was from master branch commit
c93e0d8618. Since standalone test are
completely reworked, I had to resolve the merge conflict later, in this
commit.
2023-03-15 10:48:15 -07:00
Andrew Kelley
ede5dcffea make the build runner and test runner talk to each other
std.Build.addTest creates a CompileStep as before, however, this kind of
step no longer actually runs the unit tests. Instead it only compiles
it, and one must additionally create a RunStep from the CompileStep in
order to actually run the tests.

RunStep gains integration with the default test runner, which now
supports the standard --listen=- argument in order to communicate over
stdin and stdout. It also reports test statistics; how many passed,
failed, and leaked, as well as directly associating the relevant stderr
with the particular test name that failed.

This separation of CompileStep and RunStep means that
`CompileStep.Kind.test_exe` is no longer needed, and therefore has been
removed in this commit.

 * build runner: show unit test statistics in build summary
 * added Step.writeManifest since many steps want to treat it as a
   warning and emit the same message if it fails.
 * RunStep: fixed error message that prints the failed command printing
   the original argv and not the adjusted argv in case an interpreter
   was used.
 * RunStep: fixed not passing the command line arguments to the
   interpreter.
 * move src/Server.zig to std.zig.Server so that the default test runner
   can use it.
 * the simpler test runner function which is used by work-in-progress
   backends now no longer prints to stderr, which is necessary in order
   for the build runner to not print the stderr as a warning message.
2023-03-15 10:48:14 -07:00
Andrew Kelley
030742f1f7 re-enable standalone tests based on build.zig 2023-03-15 10:48:14 -07:00
Andrew Kelley
0322e292e8 update test/standalone/sigpipe build.zig script to latest API 2023-03-15 10:48:13 -07:00
mlugg
c93e0d8618 Sema: @extern fixes
* There was an edge case where the arena could be destroyed twice on
  error: once from the arena itself and once from the decl destruction.

* The type of the created decl was incorrect (it should have been the
  pointer child type), but it's not required anyway, so it's now just
  initialized to anyopaque (which more accurately reflects what's
  actually at that memory, since e.g. [*]T may correspond to nothing).

* A runtime bitcast of the pointer was performed, meaning @extern didn't
  work at comptime. This is unnecessary: the decl_ref can just be
  initialized with the correct pointer type.
2023-03-12 18:55:23 +02:00
Andrew Kelley
26196be344 rename std.Build.InstallRawStep to ObjCopyStep
And make it not do any installation, only objcopying. We already have
install steps for doing installation.

This commit also makes ObjCopyStep properly integrate with caching.
2023-02-24 23:48:03 -05:00
mlugg
f94cbab3ac
Add test coverage for some module structures 2023-02-21 02:05:36 +00:00
Andrew Kelley
adfc019d60
Merge pull request #11982 from marler8997/ignoreSigpipe
ignore SIGPIPE by default
2023-02-19 13:55:12 -05:00
Andrew Kelley
f0530385b5 update existing behavior tests and std lib to new for loop semantics 2023-02-18 19:17:21 -07:00
Jonathan Marler
dafefe9c9d use std_options for keep_sigpipe and existence of SIG.PIPE to check for support 2023-02-18 11:49:15 -07:00
Jonathan Marler
0a8fe34b11 add test to ignore sigpipe 2023-02-17 15:25:36 -07:00
dweiller
edc0e84270 allow custom test runners to import modules 2023-02-08 16:35:32 +11:00
dweiller
1f7390f399 fix custom test runner package path resolution
Fixes #13970.

This fix makes test runners resolve package paths relative to the
directory the test runner is in. This means it is not possible to import
a file from outside the file tree root at the directory containing the
test runner.
2023-02-08 14:30:37 +11:00
Andrew Kelley
11cc1c16fa make @embedFile support module-mapped names the same way as @import
closes #14553
2023-02-05 03:25:43 -05:00
Andrew Kelley
693b12f8e1 std.Build: support exposing and depending on zig modules
New API introduced: std.Build.addModule

This function exposes a zig module with the given name, which can be
used by packages that depend on this one via std.Build.Dependency.module.

std.Build.Pkg and related functionality is deleted. Every use case has a
straightforward upgrade path using the new Module struct.

std.Build.OptionsStep.getPackage is replaced by
std.Build.OptionsStep.createModule.

std.Build.CompileStep.addPackagePath is replaced by
std.Build.CompileStep.addAnonymousModule.

This partially addresses #14307 by renaming some of the instances of
"package" to "module".

Closes #14278
2023-02-04 01:55:39 -05:00
Andrew Kelley
36e2d992dd combine std.build and std.build.Builder into std.Build
I've been wanting to do this for along time.
2023-01-31 15:09:35 -07:00
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