Jacob Young
38dfa6537e
cbe: emit nonstring attribute
...
Closes #24545
2025-08-11 11:30:51 -07:00
Jacob Young
0bf8617d96
x86_64: add support for pie executables
2025-06-06 23:42:14 -07:00
Jacob Young
58d2bd601e
x86_64: rewrite scalar <<|
...
Closes #23035
2025-05-17 18:00:17 -04:00
dweiller
898ca82458
compiler: add @memmove builtin
2025-04-26 13:34:16 +10:00
Alex Rønne Petersen
e11ac02662
cbe: Implement support for -fno-builtin and @disableIntrinsics().
2025-02-23 04:08:58 +01:00
Alex Rønne Petersen
d7f9b5a661
zig.h: Add new zig_gcc macro to indicate GCC.
...
As opposed to "GNU C" (zig_gnuc) which includes Clang.
This addresses #22890 but does not fix it until a zig1.wasm update.
2025-02-16 00:21:51 +01:00
Jacob Young
5433e0438c
cbe: fix ub triggered by mulw overflowing the promoted type
...
Closes #21914
2025-02-10 17:22:16 -08:00
Vahur Sinijärv
c4445bc156
Fix issues in zig.h when building with clang-cl on Windows ( #20331 )
...
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-01-29 23:21:44 +00:00
Alex Rønne Petersen
aa37a5a0c4
zig.h: Add some casts to __atomic macros to shut Clang warnings up.
...
This is a stupid Clang-ism:
❯ cat test.c
int main() {
int value = 42;
int const *value_ptr = &value;
int location;
__atomic_store(&location, value_ptr, __ATOMIC_SEQ_CST);
}
❯ gcc test.c -fsyntax-only
❯ clang test.c -fsyntax-only
test.c:5:31: warning: passing 'const int *' to parameter of type 'int *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
5 | __atomic_store(&location, value_ptr, __ATOMIC_SEQ_CST);
| ^~~~~~~~~
1 warning generated.
I have no idea why Clang doesn't define these builtins as taking const pointers
for the parameters that are only read from. Anyway, after the next zig1.wasm
update, this change should shut up these warnings that we've been seeing in CI
during bootstrap for ages.
2025-01-28 13:01:35 +01:00
Alex Rønne Petersen
c27488a387
zig.h: Add zig_gnuc_asm macro to indicate availability of GNU-style inline asm.
2024-12-03 12:11:05 +01:00
Alex Rønne Petersen
f058b147d3
zig.h: Introduce operating system macros.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
084ec97811
zig.h: Introduce object format macros.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
ace8396076
zig.h: Move some macros and includes closer to where they're used.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
0e934c7df1
zig.h: Use C99/C11 headers if available regardless of language standard.
...
If present, these headers are usable even when compiling for older C language
versions.
Most notably, this enables zig.h atomics to work with slimcc and TinyCC in C99
mode (and earlier).
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
1c43c2c209
zig.h: Remove duplicate and unguarded stdint.h include.
...
We already do this for C99 only later in the file.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
125bf05c27
zig.h: Implement zig_unreachable() with __assume(0) for MSVC.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
062feb6c82
zig.h: Implement zig_frame_address() with _AddressOfReturnAddress() for MSVC.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
37538f19cd
zig.h: Use zig_*_windows_teb() inline assembly with TinyCC and slimcc.
2024-12-03 12:07:34 +01:00
Alex Rønne Petersen
204df19d79
zig.h: Avoid depending on cpuid.h for zig_x86_cpuid().
...
Just use inline assembly instead, which is what that header does. Also make sure
we have a dummy implementation when inline assembly is unavailable.
2024-12-03 12:07:32 +01:00
Alex Rønne Petersen
24b57f4d30
zig.h: Introduce architecture macros to simplify checks throughout.
2024-12-03 11:57:21 +01:00
Alex Rønne Petersen
ba66814185
zig.h: Don't use __debugbreak() for MinGW.
...
It seems like only Clang supports this in MinGW mode, and Clang will already
take the __builtin_debugtrap() path anyway.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
d19e1919da
zig.h: Define zig_gnuc for both GCC and Clang and stop using __GNUC__.
...
There's only one spot in the header where we want to handle GCC but not Clang,
so just add an extra check there.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
dd1d9cce3c
zig.h: Add a zig_msvc macro to be used instead of _MSC_VER.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
f29daebd90
zig.h: Use __thread for slimcc in pre-C11 mode.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
fa6946f645
zig.h: Add support for C23 keywords.
...
The old spellings from C11 are deprecated in C23.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
023a7fefb1
zig.h: Add TinyCC support where appropriate.
...
tcc doesn't have __has_attribute and __has_builtin, so we need to manually check
for tcc in these preprocessor paths.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
43a1b88bc8
zig.h: Use __BYTE_ORDER__ instead of __LITTLE_ENDIAN__ for endianness check.
...
The former is supported by most compilers while the latter is Clang-only.
2024-12-03 11:57:20 +01:00
Alex Rønne Petersen
aa19e71a27
zig.h: Add zig_trap() and zig_breakpoint() implementations for Hexagon.
2024-11-24 08:19:15 +01:00
Alex Rønne Petersen
6b2c8fc688
zig.h: Improve portability of zig_*_windows_teb() helpers.
...
* Make it work for thumb and aarch64.
* Clean up std.os.windows.teb() a bit.
I also updated stage1/zig.h since the changes are backwards-compatible and are
necessary due to the std.os.windows changes that call the newly-added functions.
2024-11-04 11:59:38 +01:00
David Rubin
043b1adb8d
remove @fence ( #21585 )
...
closes #11650
2024-10-04 22:21:27 +00:00
Alex Rønne Petersen
5daf47a212
zig.h: Improve portability of zig_trap() and zig_breakpoint().
2024-09-23 17:34:15 -07:00
kcbanner
2a0238e5e3
zig.h: fixup pointer atomic load definitions
2024-07-26 10:42:10 -04:00
kcbanner
c318710653
zig.h: expand zig_msvc_atomic_load_ into version for relaxed, acquire, and seq_cst
2024-07-13 19:45:45 -04:00
kcbanner
bc28454b43
zig.h: replace _InterlockedExchangeAdd with a plain volatile load
...
This was causing zig2.exe to crash during bootstrap, because there was an atomic
load of read-only memory, and the attempt to write to it as part of the (idempotent)
atomic exchange was invalid.
Aligned reads (of u32 / u64) are atomic on x86 / x64, so this is replaced with an
optimization-proof load (`__iso_volatile_load8*`) and a reordering barrier.
2024-07-13 17:46:24 -04:00
Jacob Young
00da182e68
cbe: fix for export changes
2024-07-04 21:01:42 +01:00
kcbanner
0d12caee29
- Fix ypedef -> typedef
2024-06-21 00:12:13 -04:00
Andrew Kelley
9be8a9000f
Revert "implement @expect builtin ( #19658 )"
...
This reverts commit a7de02e05216db9a04e438703ddf1b6b12f3fbef.
This did not implement the accepted proposal, and I did not sign off
on the changes. I would like a chance to review this, please.
2024-05-22 09:57:43 -07:00
David Rubin
a7de02e052
implement @expect builtin ( #19658 )
...
* implement `@expect`
* add docs
* add a second arg for expected bool
* fix typo
* move `expect` to use BinOp
* update to newer langref format
2024-05-22 10:51:16 -05:00
Jacob Young
e8dd79ca67
cbe: fix ub with integer @abs
2024-04-30 22:09:54 -07:00
Jacob Young
fb192df4f2
cbe: fix uncovered bugs
2024-03-30 20:50:48 -04:00
Jacob Young
6f10b11658
cbe: fix bugs revealed by an upcoming commit
...
Closes #18023
2024-03-30 20:50:48 -04:00
Jacob Young
047d6d996e
cbe: fix non-msvc externs and exports
...
Closes #17817
2024-01-03 02:52:25 -05:00
Jacob Young
98b633ff17
Reapply "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
...
This reverts commit 2b589783602c5428ecde9dbb3f41a81f85eb0f25.
2024-01-03 02:41:21 -05:00
Andrew Kelley
2b58978360
Revert "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
...
This reverts commit 7161ed79c4abcaccdd56fe0b4fbd3d93472d41b8, reversing
changes made to 3f2a65594e1d3c0a4f4943a4ea522e8405db81e0.
Unfortunately, this sat in the PR queue too long and the merge broke the
zig1.wasm bootstrap process.
2024-01-01 17:49:57 -07:00
Andrew Kelley
7161ed79c4
Merge pull request #17824 from kcbanner/fixup_msvc_fmax
...
cbe: add a system for avoiding collisions with C compiler intrinsics
2024-01-01 15:36:16 -08:00
Jacob Young
0dbaa8d3ae
zig.h: workaround for gcc f128 miscompilations
2023-11-12 17:30:24 -07:00
kcbanner
50e2fb8fd0
cbe: fixup __asm style exports, re-enable 12680 on macos now that alias isn't used
2023-11-05 23:36:11 -05:00
kcbanner
a4526d260b
cbe: fix builtins not being used by zig_import when they are available
2023-11-05 20:34:13 -05:00
kcbanner
26dabbf301
cbe: handle underscore prexfix on macos, don't mangle extern function names
2023-11-05 20:34:13 -05:00
kcbanner
192e9a315d
cbe: add DeclVisibility and zig_extern_mangled to handle exporting mangled symbols under a different name
2023-11-05 20:34:13 -05:00