Commit Graph

836 Commits

Author SHA1 Message Date
Andrew Kelley
0fcd59eada rename src/Module.zig to src/Zcu.zig
This patch is a pure rename plus only changing the file path in
`@import` sites, so it is expected to not create version control
conflicts, even when rebasing.
2024-06-22 22:59:56 -04:00
Andrew Kelley
0884a43411 CMake: remove -Dstd-docs=false flag when building stage3
This now defaults to false already since the autodocs rework.

The langref still cannot be enabled by default because the langref
contains doctests that exercise the `@cImport` feature which is disabled
in zig2 builds.
2024-06-07 12:42:14 -07:00
Andrew Kelley
aab5cccc78 start the 0.14.0 release cycle 2024-06-06 12:05:37 -07:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Jakub Konka
0b0625ccf4
Merge pull request #20062 from ziglang/macho-perf-bug
link/macho: fix perf bug in DWARF parsing
2024-05-25 06:25:46 +02:00
kcbanner
710d745a54 cmake: add /Zc:preprocessor to handle new OptTable macros
See: 12d8e7c6ad
See: 3f092f37b7

cmake: set MSVC_RUNTIME_LIBRARY for zigcpp
2024-05-24 10:58:05 -04:00
Jakub Konka
ed7073c630 link/macho: fix perf bug in DWARF parsing 2024-05-24 15:34:48 +02:00
Eric Joldasov
1e785984b0
CMake: try to fix CI failures
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-15 15:37:12 +05:00
Eric Joldasov
1079b5fe63
CMake: remove ZIG_USE_CCACHE option
Not really useful after old C++ compiler removal, and
zig build has own cache system. If someone still wants it,
`CMAKE_C_COMPILER_LAUNCHER` and `CMAKE_CXX_COMPILER_LAUNCHER` exist.

From CMake docs:

> RULE_LAUNCH_COMPILE
> Note: This property is intended for internal use by ctest(1).
> Projects and developers should use the <LANG>_COMPILER_LAUNCHER
> target properties or the associated CMAKE_<LANG>_COMPILER_LAUNCHER
> variables instead.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:42 +05:00
Eric Joldasov
34ed49c62d
CMake: refactor ZIG_PIE and ZIG_BUILD_ARGS
Set `ZIG_PIE` default to be same as `CMAKE_POSITION_INDEPENDENT_CODE`, and
add check for situation when `ZIG_PIE` is set to True but CMake does not
support compiling position independent code. CMake's support is needed
for "zigcpp" target.

Also remove temporary variables for constructing `ZIG_BUILD_ARGS`,
instead use `list(APPEND ...)` functions.

Also remove long unused `ZIG_NO_LANGREF` variable.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:42 +05:00
Eric Joldasov
b59c722a3f
CMake: clean CMAKE_{SOURCE,BUILD}_DIR
Replace `CMAKE_SOURCE_DIR` and `CMAKE_BUILD_DIR` with different variables,
or in some cases just remove them.

For some function arguments, prepended `CMAKE_SOURCE_DIR` was removed without
replacement. This includes:
 * Sources for `add_library` and `add_executable` (`ZIG_CPP_SOURCES` and `ZIG_WASM2C_SOURCES`)
 * Inputs for `configure_file` and `target_include_directory`
 * For arguments above, CMake already prepends
   `CMAKE_CURRENT_SOURCE_DIR` to them by default, if they are relative paths.
   Additionaly, it was removed from arguments of commands that have `WORKING_DIRECTORY` set to
   `PROJECT_SOURCE_DIR`, they will be similarly converted by CMake for us.

Also:
 * Move project declaration to the top so that these variables are
available earlier.
 * Avoid calling "git" executable if ".git" directory does not exist.
 * Swap "--prefix" and `ZIG_BUILD_ARGS` arguments in cmake/install.cmake
   to match same "zig2 build" command in CMakeLists.txt and allow
   overriding "--prefix" argument

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:41 +05:00
Eric Joldasov
c2ad0220e0
CMake: remove C/C++ flags override for static executable
They were introduced in https://github.com/ziglang/zig/pull/3467 and
5b51f41cee , and become obsolete since
C++-based compiler was removed: all C or C++ sources built by CMake
are just intermediate steps in bootstrapping.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:41 +05:00
Eric Joldasov
1f7ca6b2df
CMake: refactor "zigcpp" target logic
* Localize most of the global properties and functions, for some time
  they are only needed for "zigcpp" static library (sometimes with PUBLIC
  keyword, so that it will propagate to zig2): `CMAKE_*_OUTPUT_DIRECTORY`
  and two calls to `include_directories`. This removes useless flags when
  building other targets and cleans build log a bit.
* Remove `EXE_CXX_FLAGS` variable, instead use more appropriate specific
  properties and functions for this target. This gives better errors if
  compiler does not support some of them, and CMake also handles for us
  duplicate flags. It's also easier to read side-by-side with same
  flags from build.zig .
* Add some comments.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:41 +05:00
Eric Joldasov
1ffa6a0e79
CMake: remove unused variables EXE_LDFLAGS and ZIG_LIB_DIR
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:41 +05:00
Eric Joldasov
2380f6aadc
CMake: bump minimum required version to "3.15"
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-05-14 23:40:41 +05:00
Andrew Kelley
5f0a2f2a0c refresh cmake list of compiler source files 2024-05-08 19:37:29 -07:00
Andrew Kelley
62381011e0 apparently LLVM depends on ws2_32.dll now 2024-05-08 19:37:29 -07:00
Andrew Kelley
27a9240ccb suppress C++ type-limits warnings
Zig has no more C++ code; these warnings are being tripped by the Clang
code copy-pasted into Zig. No sense in detecting them.
2024-05-08 19:37:29 -07:00
Andrew Kelley
3ac8d37182 update CMake files to LLVM 18 2024-05-08 19:37:28 -07:00
Jacob Young
5c9eb40816 cmake: make static curses configurable
Not sure why this exists in the first place, but disabling it reduces
the required dependencies of a CI runner.
2024-05-07 11:35:44 -07:00
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
this patch renames ComptimeStringMap to StaticStringMap, makes it
accept only a single type parameter, and return a known struct type
instead of an anonymous struct.  initial motivation for these changes
was to reduce the 'very long type names' issue described here
https://github.com/ziglang/zig/pull/19682.

this breaks the previous API.  users will now need to write:
`const map = std.StaticStringMap(T).initComptime(kvs_list);`

* move `kvs_list` param from type param to an `initComptime()` param
* new public methods
  * `keys()`, `values()` helpers
  * `init(allocator)`, `deinit(allocator)` for runtime data
  * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure
     these belong but have left in for now incase they are deemed useful
* performance notes:
  * i posted some benchmarking results here:
    https://github.com/travisstaloch/comptime-string-map-revised/issues/1
  * i noticed a speedup reducing the size of the struct from 48 to 32
    bytes and thus use u32s instead of usize for all length fields
  * i noticed speedup storing KVs as a struct of arrays
  * latest benchmark shows these wall_time improvements for
    debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full
    output in link above.
2024-04-22 15:31:41 -07:00
Andrew Kelley
7c0e1cc913 start the 0.13.0 release cycle 2024-04-19 14:01:04 -07:00
Erik Arvstedt
130fb5cb0f cmake: support setting the dynamic linker 2024-04-18 12:16:24 -07:00
Jacob Young
5a41704f7e cbe: rewrite CType
Closes #14904
2024-03-30 20:50:48 -04:00
mlugg
2a245e3b78
compiler: eliminate TypedValue
The only logic which remained in this file was the Value printing logic.
This has been moved into a new `print_value.zig`.
2024-03-26 13:48:07 +00:00
Marc Tiehuis
31791ae15b rename ryu128 -> format_float
Symmetry with parse_float and to hide the implementation from the user.
Additionally, we expose the entire namespace and provide some aliases so
everything is available to a user.

Closes #19366
2024-03-21 17:10:41 +02:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Andrew Kelley
bd24e66379
Merge pull request #19229 from tiehuis/ryu-128
std.fmt: add ryu floating-point formatting implementation
2024-03-11 18:46:26 -07:00
Andrew Kelley
c19657d65c cmake: remove -Dno-autodocs
this is now the default
2024-03-10 17:51:07 -07:00
Jakub Konka
c1bda06c14
Merge pull request #19225 from ziglang/elf-aarch64
elf: port aarch64 support from zld
2024-03-10 15:32:58 +01:00
Marc Tiehuis
2e60d4d064 replace errol with ryu in CMakeLists.txt 2024-03-09 20:38:27 +13:00
Jakub Konka
859f9a22c4 elf+aarch64: implement basic thunk support 2024-03-08 22:46:18 +01:00
mlugg
265f42d472
std.os.linux: rework io_uring support
* `linux.IO_Uring` -> `linux.IoUring` to align with naming conventions.
* All functions `io_uring_prep_foo` are now methods `prep_foo` on `io_uring_sqe`, which is in a file of its own.
* `SubmissionQueue` and `CompletionQueue` are namespaced under `IoUring`.

This is a breaking change.

The new file and namespace layouts are more idiomatic, and allow us to
eliminate one more usage of `usingnamespace` from the standard library.
2 remain.
2024-03-08 08:02:45 +00:00
Andrew Kelley
240d0b68f6 make aro-based translate-c lazily built from source
Part of #19063.

Primarily, this moves Aro from deps/ to lib/compiler/ so that it can be
lazily compiled from source. src/aro_translate_c.zig is moved to
lib/compiler/aro_translate_c.zig and some of Zig CLI logic moved to a
main() function there.

aro_translate_c.zig becomes the "common" import for clang-based
translate-c.

Not all of the compiler was able to be detangled from Aro, however, so
it still, for now, remains being compiled with the main compiler
sources due to the clang-based translate-c depending on it. Once
aro-based translate-c achieves feature parity with the clang-based
translate-c implementation, the clang-based one can be removed from Zig.

Aro made it unnecessarily difficult to depend on with these .def files
and all these Zig module requirements. I looked at the .def files and
made these observations:

- The canonical source is llvm .def files.
- Therefore there is an update process to sync with llvm that involves
  regenerating the .def files in Aro.
- Therefore you might as well just regenerate the .zig files directly
  and check those into Aro.
- Also with a small amount of tinkering, the file size on disk of these
  generated .zig files can be made many times smaller, without
  compromising type safety in the usage of the data.

This would make things much easier on Zig as downstream project,
particularly we could remove those pesky stubs when bootstrapping.

I have gone ahead with these changes since they unblock me and I will
have a chat with Vexu to see what he thinks.
2024-02-28 13:21:05 -07:00
Andrew Kelley
a4380a30f5 move zig libc command to be lazily built
part of #19063

This is a prerequisite for doing the same for Resinator.
2024-02-27 22:55:00 -07:00
Andrew Kelley
b116063e02 move AstGen to std.zig.AstGen
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:51:19 -07:00
Andrew Kelley
7b37bc771b move Zir to std.zig.Zir
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
Jakub Konka
fc7dd3e285 elf: enable adding support for additional cpu archs 2024-02-16 21:54:43 +01:00
Jakub Konka
616a8f9853 elf: move code paths responsible for emitting object and archive into relocatable module 2024-02-12 23:37:51 +01:00
Andrew Kelley
32f30399e5
Merge pull request #18867 from e4m2/random
std.rand: Move to std.Random
2024-02-09 13:42:04 -08:00
Andrew Kelley
54bbc73f85
Merge pull request #18712 from Vexu/std.options
std: make options a struct instance instead of a namespace
2024-02-09 13:38:42 -08:00
e4m2
a9a5833f23 Update rand.zig source file name for CMake 2024-02-08 15:35:33 +01:00
Andrew Kelley
3122fd0ba0
Merge pull request #17634 from ianprime0509/type-erased-writer
Add type-erased writer and GenericWriter
2024-02-07 23:52:53 -08:00
Andrew Kelley
78f15bc714 compiler: rename value.zig to Value.zig
This commit only does the file rename to be friendlier to version
control conflicts.
2024-02-05 18:13:07 -07:00
Veikka Tuominen
b0bea72588 remove std.event 2024-02-01 15:22:36 +02:00
Ian Johnson
e392c1a0b3 Add type-erased writer and GenericWriter
This is a companion to #17344 to apply the same change to the
`std.io.Writer` interface.
2024-01-29 19:02:18 -05:00
Jakub Konka
6d0ba6dd10 macho: introduce ZigObject 2024-01-24 12:34:40 +01:00
Jakub Konka
2f94dc939e macho: copy over new implementation sources from zld 2024-01-24 12:34:38 +01:00
Andrew Kelley
8cf2cfc52c update bootstrap scripts to new zig CLI
Now they use the new --mod --dep parameters.
2024-01-01 17:51:21 -07:00
Andrew Kelley
12de7e3472 WIP: move many global settings to become per-Module
Much of the logic from Compilation.create() is extracted into
Compilation.Config.resolve() which accepts many optional settings and
produces concrete settings. This separate step is needed by API users of
Compilation so that they can pass the resolved global settings to the
Module creation function, which itself needs to resolve per-Module
settings.

Since the target and other things are no longer global settings, I did
not want them stored in link.File (in the `options` field). That options
field was already a kludge; those options should be resolved into
concrete settings. This commit also starts to work on that, deleting
link.Options, moving the fields into Compilation and
ObjectFormat-specific structs instead. Some fields were ephemeral and
should not have been stored at all, such as symbol_size_hint.

The link.File object of Compilation is now a `?*link.File` and `null`
when -fno-emit-bin is passed. It is now arena-allocated along with
Compilation itself, avoiding some messy cleanup code that was there
before.

On the command line, it is now possible to configure the standard
library itself by using `--mod std` just like any other module. This
meant that the CLI needed to create the standard library module rather
than having Compilation create it.

There are a lot of changes in this commit and it's still not done. I
didn't realize how quickly this changeset was going to balloon out of
control, and there are still many lines that need to be changed before
it even compiles successfully.

* introduce std.Build.Cache.HashHelper.oneShot
* add error_tracing to std.Build.Module
* extract build.zig file generation into src/Builtin.zig
* each CSourceFile and RcSourceFile now has a Module owner, which
  determines some of the C compiler flags.
2024-01-01 17:51:18 -07:00