Commit Graph

861 Commits

Author SHA1 Message Date
Andrew Kelley
f6392b9526 cmake: don't add an unnecessary curses static lib dependency 2024-11-25 15:05:42 -08:00
Alex Rønne Petersen
baf60426d4
std.Target: Rename amdgpu module to amdgcn.
This was an inconsistency left over from c825b567b2.
2024-11-02 10:44:14 +01:00
Andrew Kelley
ba2d006634 link.File.Wasm: remove the "files" abstraction
Removes the `files` field from the Wasm linker, storing the ZigObject
as its own field instead using a tagged union.

This removes a layer of indirection when accessing the ZigObject, and
untangles logic so that we can introduce a "pre-link" phase that
prepares the linker state to handle only incremental updates to the
ZigObject and then minimize logic inside flush().

Furthermore, don't make array elements store their own indexes, that's
always a waste.

Flattens some of the file system hierarchy and unifies variable names
for easier refactoring.

Introduces type safety for optional object indexes.
2024-10-30 19:34:58 -07:00
Alex Rønne Petersen
b5cafe223a Revert "cmake: Add a ZIG2_NO_RTLIB option for building zig2 without compiler-rt."
This reverts commit 3dd6456c0f.

We didn't end up using this after all.
2024-10-29 06:48:47 +01:00
Jakub Konka
56996a2809
link/Coff: simplify file structure by collapsing all files into Coff.zig (#21761)
* coff: collapse Coff/lld.zig logic into Coff.zig

* coff: rename std.coff uses to coff_util

* coff: rename self to coff for *Coff references

* coff: collapse Coff/Atom.zig logic into Coff.zig

* coff: collapse Coff/Relocation.zig logic into Coff.zig

* coff: collapse Coff/ImportTable.zig logic into Coff.zig

* coff: remove unused Coff/Object.zig

* link/Coff: fix rebase gone wrong
2024-10-24 13:50:02 +00:00
Andrew Kelley
5ca54036ca move linker input file parsing to the compilation pipeline 2024-10-23 16:27:38 -07:00
Andrew Kelley
1e785409bb move link.Elf.LdScript to link.LdScript 2024-10-23 16:27:38 -07:00
Andrew Kelley
7b69738a06 link.Elf: fix merge sections namespacing
`link.Elf.merge_section.MergeSection` -> `link.Elf.Merge.Section`
2024-10-11 10:33:54 -07:00
Jan200101
41dbd0d0da cmake: correct PIE support detection, add error output for debugging
`check_pie_supported` only uses the `OUTPUT_VARIABLE` to to signify errors
if PIE is actually supported is signaled by `CMAKE_<lang>_LINK_PIE_SUPPORTED`.

Checking if `OUTPUT_VARIABLE` is empty is not enough either since the check
is bypassed if its results are cached but the output variable is not cached.
2024-10-11 17:07:54 +02:00
Andrew Kelley
6294e65eeb compiler_rt does not need a build_options module 2024-09-19 18:20:22 -07:00
Alex Rønne Petersen
3dd6456c0f cmake: Add a ZIG2_NO_RTLIB option for building zig2 without compiler-rt. 2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
dd095e506a cmake: Update to LLVM 19.
Co-authored-by: David Rubin <daviru007@icloud.com>
2024-09-19 18:20:20 -07:00
Jakub Konka
516955dbdb elf: add AtomList.zig to CMakeLists.txt 2024-09-04 13:45:16 +02:00
mlugg
c62487da76
compiler: avoid field/decl name conflicts
Most of the required renames here are net wins for readaibility, I'd
say. The ones in `arch` are a little more verbose, but I think better. I
didn't bother renaming the non-conflicting functions in
`arch/arm/bits.zig` and `arch/aarch64/bits.zig`, since these backends
are pretty bit-rotted anyway AIUI.
2024-08-29 23:43:52 +01:00
YANG Xudong
a9b65b6fd4
std: add loongarch64 support (#20915)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 00:30:57 +00:00
Kyle Schwarz
a60810b5a3 cmake: add ZIG_EXTRA_BUILD_ARGS option 2024-08-06 19:28:48 -07:00
Jakub Konka
91c17979f1
Merge pull request #20807 from Rexicon226/riscv
riscv: more backend progress
2024-07-28 11:34:23 +02:00
Andrew Kelley
80269c1f53 remove deprecated --mod CLI now that a zig1.wasm update happened 2024-07-26 05:07:18 -07:00
David Rubin
1a7d89a84d
riscv: clean up and unify encoding logic 2024-07-26 04:19:13 -07:00
David Rubin
45443f9c37
cmake: update to reflect added riscv64 backend files 2024-07-26 04:05:43 -07:00
Jacob Young
4f742c4cfc dev: introduce dev environments that enable compiler feature sets 2024-07-19 22:35:33 -07:00
Andrew Kelley
e8c4e79499 std.c reorganization
It is now composed of these main sections:
* Declarations that are shared among all operating systems.
* Declarations that have the same name, but different type signatures
  depending on the operating system. Often multiple operating systems
  share the same type signatures however.
* Declarations that are specific to a single operating system.
  - These are imported one per line so you can see where they come from,
    protected by a comptime block to prevent accessing the wrong one.

Closes #19352 by changing the convention to making types `void` and
functions `{}`, so that it becomes possible to update `@hasDecl` sites
to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up
removing some duplicate logic and update some bitrotted feature
detection checks.

A handful of types have been modified to gain namespacing and type
safety. This is a breaking change.

Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-19 00:30:32 -07:00
Raed Rizqie
9356cb1475 Allocate enough memory when building zig2 2024-07-16 00:41:24 -07:00
Jacob Young
525f341f33 Zcu: introduce PerThread and pass to all the functions 2024-07-07 22:59:52 -04:00
mlugg
2f0f1efa6f
compiler: type.zig -> Type.zig 2024-07-04 21:01:42 +01:00
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