| author | |
| committer | |
| log | bd7b2cc4b49127474a028e6726fce33c5db3df12 |
| tree | 01e71492173186830a10157adfcc118a1e83806c |
| parent | fba618a6c9ae4f70dc8a7879975adf31d3a44d4d |
| parent | c31871065394c78d7d316b2a1709077437d29ccf |
| signature |
Fixes for bootrapping with MSVC4 files changed, 99 insertions(+), 42 deletions(-)
lib/std/Build/Step/Compile.zig+9-2| ... | ... | @@ -1635,9 +1635,16 @@ fn getZigArgs(compile: *Compile) ![][]const u8 { |
| 1635 | 1635 | }); |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | if (compile.zig_lib_dir) |dir| { | |
| 1638 | const opt_zig_lib_dir = if (compile.zig_lib_dir) |dir| | |
| 1639 | dir.getPath2(b, step) | |
| 1640 | else if (b.graph.zig_lib_directory.path) |_| | |
| 1641 | b.fmt("{}", .{b.graph.zig_lib_directory}) | |
| 1642 | else | |
| 1643 | null; | |
| 1644 | ||
| 1645 | if (opt_zig_lib_dir) |zig_lib_dir| { | |
| 1639 | 1646 | try zig_args.append("--zig-lib-dir"); |
| 1640 | try zig_args.append(dir.getPath2(b, step)); | |
| 1647 | try zig_args.append(zig_lib_dir); | |
| 1641 | 1648 | } |
| 1642 | 1649 | |
| 1643 | 1650 | try addFlag(&zig_args, "PIE", compile.pie); |
lib/zig.h+42-17| ... | ... | @@ -3636,7 +3636,7 @@ typedef int zig_memory_order; |
| 3636 | 3636 | #define zig_atomicrmw_min(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_min_ ##Type(obj, arg) |
| 3637 | 3637 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) |
| 3638 | 3638 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##Type(obj) | |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) | |
| 3640 | 3640 | #if _M_X64 |
| 3641 | 3641 | #define zig_fence(order) __faststorefence() |
| 3642 | 3642 | #else |
| ... | ... | @@ -3670,7 +3670,7 @@ typedef int zig_memory_order; |
| 3670 | 3670 | |
| 3671 | 3671 | /* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */ |
| 3672 | 3672 | |
| 3673 | #define zig_msvc_atomics(ZigType, Type, SigType, suffix) \ | |
| 3673 | #define zig_msvc_atomics(ZigType, Type, SigType, suffix, iso_suffix) \ | |
| 3674 | 3674 | static inline bool zig_msvc_cmpxchg_##ZigType(Type volatile* obj, Type* expected, Type desired) { \ |
| 3675 | 3675 | Type comparand = *expected; \ |
| 3676 | 3676 | Type initial = _InterlockedCompareExchange##suffix((SigType volatile*)obj, (SigType)desired, (SigType)comparand); \ |
| ... | ... | @@ -3741,24 +3741,34 @@ typedef int zig_memory_order; |
| 3741 | 3741 | } \ |
| 3742 | 3742 | static inline void zig_msvc_atomic_store_##ZigType(Type volatile* obj, Type value) { \ |
| 3743 | 3743 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, (SigType)value); \ |
| 3744 | } \ | |
| 3745 | static inline Type zig_msvc_atomic_load_zig_memory_order_relaxed_##ZigType(Type volatile* obj) { \ | |
| 3746 | return __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3744 | 3747 | } \ |
| 3745 | static inline Type zig_msvc_atomic_load_##ZigType(Type volatile* obj) { \ | |
| 3746 | return _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3748 | static inline Type zig_msvc_atomic_load_zig_memory_order_acquire_##ZigType(Type volatile* obj) { \ | |
| 3749 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3750 | _ReadWriteBarrier(); \ | |
| 3751 | return val; \ | |
| 3752 | } \ | |
| 3753 | static inline Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##ZigType(Type volatile* obj) { \ | |
| 3754 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3755 | _ReadWriteBarrier(); \ | |
| 3756 | return val; \ | |
| 3747 | 3757 | } |
| 3748 | 3758 | |
| 3749 | zig_msvc_atomics( u8, uint8_t, char, 8) | |
| 3750 | zig_msvc_atomics( i8, int8_t, char, 8) | |
| 3751 | zig_msvc_atomics(u16, uint16_t, short, 16) | |
| 3752 | zig_msvc_atomics(i16, int16_t, short, 16) | |
| 3753 | zig_msvc_atomics(u32, uint32_t, long, ) | |
| 3754 | zig_msvc_atomics(i32, int32_t, long, ) | |
| 3759 | zig_msvc_atomics( u8, uint8_t, char, 8, 8) | |
| 3760 | zig_msvc_atomics( i8, int8_t, char, 8, 8) | |
| 3761 | zig_msvc_atomics(u16, uint16_t, short, 16, 16) | |
| 3762 | zig_msvc_atomics(i16, int16_t, short, 16, 16) | |
| 3763 | zig_msvc_atomics(u32, uint32_t, long, , 32) | |
| 3764 | zig_msvc_atomics(i32, int32_t, long, , 32) | |
| 3755 | 3765 | |
| 3756 | 3766 | #if _M_X64 |
| 3757 | zig_msvc_atomics(u64, uint64_t, __int64, 64) | |
| 3758 | zig_msvc_atomics(i64, int64_t, __int64, 64) | |
| 3767 | zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) | |
| 3768 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) | |
| 3759 | 3769 | #endif |
| 3760 | 3770 | |
| 3761 | #define zig_msvc_flt_atomics(Type, SigType, suffix) \ | |
| 3771 | #define zig_msvc_flt_atomics(Type, SigType, suffix, iso_suffix) \ | |
| 3762 | 3772 | static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \ |
| 3763 | 3773 | SigType exchange; \ |
| 3764 | 3774 | SigType comparand; \ |
| ... | ... | @@ -3776,15 +3786,30 @@ zig_msvc_atomics(i64, int64_t, __int64, 64) |
| 3776 | 3786 | memcpy(&value, &arg, sizeof(value)); \ |
| 3777 | 3787 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, value); \ |
| 3778 | 3788 | } \ |
| 3779 | static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \ | |
| 3789 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_relaxed_##Type(zig_##Type volatile* obj) { \ | |
| 3780 | 3790 | zig_##Type result; \ |
| 3781 | SigType initial = _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3791 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3782 | 3792 | memcpy(&result, &initial, sizeof(result)); \ |
| 3783 | 3793 | return result; \ |
| 3794 | } \ | |
| 3795 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_acquire_##Type(zig_##Type volatile* obj) { \ | |
| 3796 | zig_##Type result; \ | |
| 3797 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3798 | _ReadWriteBarrier(); \ | |
| 3799 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3800 | return result; \ | |
| 3801 | } \ | |
| 3802 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##Type(zig_##Type volatile* obj) { \ | |
| 3803 | zig_##Type result; \ | |
| 3804 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3805 | _ReadWriteBarrier(); \ | |
| 3806 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3807 | return result; \ | |
| 3784 | 3808 | } |
| 3785 | zig_msvc_flt_atomics(f32, long, ) | |
| 3809 | ||
| 3810 | zig_msvc_flt_atomics(f32, long, , 32) | |
| 3786 | 3811 | #if _M_X64 |
| 3787 | zig_msvc_flt_atomics(f64, int64_t, 64) | |
| 3812 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) | |
| 3788 | 3813 | #endif |
| 3789 | 3814 | |
| 3790 | 3815 | #if _M_IX86 |
src/main.zig+2-2| ... | ... | @@ -2710,7 +2710,7 @@ fn buildOutputType( |
| 2710 | 2710 | break :d getWasiPreopen("/lib"); |
| 2711 | 2711 | } else if (self_exe_path) |p| { |
| 2712 | 2712 | break :d introspect.findZigLibDirFromSelfExe(arena, p) catch |err| { |
| 2713 | fatal("unable to find zig installation directory: {s}", .{@errorName(err)}); | |
| 2713 | fatal("unable to find zig installation directory '{s}': {s}", .{ p, @errorName(err) }); | |
| 2714 | 2714 | }; |
| 2715 | 2715 | } else { |
| 2716 | 2716 | unreachable; |
| ... | ... | @@ -7403,7 +7403,7 @@ fn findTemplates(gpa: Allocator, arena: Allocator) Templates { |
| 7403 | 7403 | fatal("unable to find self exe path: {s}", .{@errorName(err)}); |
| 7404 | 7404 | }; |
| 7405 | 7405 | var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| { |
| 7406 | fatal("unable to find zig installation directory: {s}", .{@errorName(err)}); | |
| 7406 | fatal("unable to find zig installation directory '{s}': {s}", .{ self_exe_path, @errorName(err) }); | |
| 7407 | 7407 | }; |
| 7408 | 7408 | |
| 7409 | 7409 | const s = fs.path.sep_str; |
stage1/zig.h+46-21| ... | ... | @@ -207,16 +207,16 @@ typedef char bool; |
| 207 | 207 | __asm(zig_mangle_c(name) " = " zig_mangle_c(symbol)) |
| 208 | 208 | #endif |
| 209 | 209 | |
| 210 | #define zig_mangled_tentative zig_mangled | |
| 211 | #define zig_mangled_final zig_mangled | |
| 210 | 212 | #if _MSC_VER |
| 211 | #define zig_mangled_tentative(mangled, unmangled) | |
| 212 | #define zig_mangled_final(mangled, unmangled) ; \ | |
| 213 | #define zig_mangled(mangled, unmangled) ; \ | |
| 213 | 214 | zig_export(#mangled, unmangled) |
| 214 | 215 | #define zig_mangled_export(mangled, unmangled, symbol) \ |
| 215 | 216 | zig_export(unmangled, #mangled) \ |
| 216 | 217 | zig_export(symbol, unmangled) |
| 217 | 218 | #else /* _MSC_VER */ |
| 218 | #define zig_mangled_tentative(mangled, unmangled) __asm(zig_mangle_c(unmangled)) | |
| 219 | #define zig_mangled_final(mangled, unmangled) zig_mangled_tentative(mangled, unmangled) | |
| 219 | #define zig_mangled(mangled, unmangled) __asm(zig_mangle_c(unmangled)) | |
| 220 | 220 | #define zig_mangled_export(mangled, unmangled, symbol) \ |
| 221 | 221 | zig_mangled_final(mangled, unmangled) \ |
| 222 | 222 | zig_export(symbol, unmangled) |
| ... | ... | @@ -3636,7 +3636,7 @@ typedef int zig_memory_order; |
| 3636 | 3636 | #define zig_atomicrmw_min(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_min_ ##Type(obj, arg) |
| 3637 | 3637 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) |
| 3638 | 3638 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##Type(obj) | |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) | |
| 3640 | 3640 | #if _M_X64 |
| 3641 | 3641 | #define zig_fence(order) __faststorefence() |
| 3642 | 3642 | #else |
| ... | ... | @@ -3670,7 +3670,7 @@ typedef int zig_memory_order; |
| 3670 | 3670 | |
| 3671 | 3671 | /* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */ |
| 3672 | 3672 | |
| 3673 | #define zig_msvc_atomics(ZigType, Type, SigType, suffix) \ | |
| 3673 | #define zig_msvc_atomics(ZigType, Type, SigType, suffix, iso_suffix) \ | |
| 3674 | 3674 | static inline bool zig_msvc_cmpxchg_##ZigType(Type volatile* obj, Type* expected, Type desired) { \ |
| 3675 | 3675 | Type comparand = *expected; \ |
| 3676 | 3676 | Type initial = _InterlockedCompareExchange##suffix((SigType volatile*)obj, (SigType)desired, (SigType)comparand); \ |
| ... | ... | @@ -3741,24 +3741,34 @@ typedef int zig_memory_order; |
| 3741 | 3741 | } \ |
| 3742 | 3742 | static inline void zig_msvc_atomic_store_##ZigType(Type volatile* obj, Type value) { \ |
| 3743 | 3743 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, (SigType)value); \ |
| 3744 | } \ | |
| 3745 | static inline Type zig_msvc_atomic_load_zig_memory_order_relaxed_##ZigType(Type volatile* obj) { \ | |
| 3746 | return __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3744 | 3747 | } \ |
| 3745 | static inline Type zig_msvc_atomic_load_##ZigType(Type volatile* obj) { \ | |
| 3746 | return _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3748 | static inline Type zig_msvc_atomic_load_zig_memory_order_acquire_##ZigType(Type volatile* obj) { \ | |
| 3749 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3750 | _ReadWriteBarrier(); \ | |
| 3751 | return val; \ | |
| 3752 | } \ | |
| 3753 | static inline Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##ZigType(Type volatile* obj) { \ | |
| 3754 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3755 | _ReadWriteBarrier(); \ | |
| 3756 | return val; \ | |
| 3747 | 3757 | } |
| 3748 | 3758 | |
| 3749 | zig_msvc_atomics( u8, uint8_t, char, 8) | |
| 3750 | zig_msvc_atomics( i8, int8_t, char, 8) | |
| 3751 | zig_msvc_atomics(u16, uint16_t, short, 16) | |
| 3752 | zig_msvc_atomics(i16, int16_t, short, 16) | |
| 3753 | zig_msvc_atomics(u32, uint32_t, long, ) | |
| 3754 | zig_msvc_atomics(i32, int32_t, long, ) | |
| 3759 | zig_msvc_atomics( u8, uint8_t, char, 8, 8) | |
| 3760 | zig_msvc_atomics( i8, int8_t, char, 8, 8) | |
| 3761 | zig_msvc_atomics(u16, uint16_t, short, 16, 16) | |
| 3762 | zig_msvc_atomics(i16, int16_t, short, 16, 16) | |
| 3763 | zig_msvc_atomics(u32, uint32_t, long, , 32) | |
| 3764 | zig_msvc_atomics(i32, int32_t, long, , 32) | |
| 3755 | 3765 | |
| 3756 | 3766 | #if _M_X64 |
| 3757 | zig_msvc_atomics(u64, uint64_t, __int64, 64) | |
| 3758 | zig_msvc_atomics(i64, int64_t, __int64, 64) | |
| 3767 | zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) | |
| 3768 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) | |
| 3759 | 3769 | #endif |
| 3760 | 3770 | |
| 3761 | #define zig_msvc_flt_atomics(Type, SigType, suffix) \ | |
| 3771 | #define zig_msvc_flt_atomics(Type, SigType, suffix, iso_suffix) \ | |
| 3762 | 3772 | static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \ |
| 3763 | 3773 | SigType exchange; \ |
| 3764 | 3774 | SigType comparand; \ |
| ... | ... | @@ -3776,15 +3786,30 @@ zig_msvc_atomics(i64, int64_t, __int64, 64) |
| 3776 | 3786 | memcpy(&value, &arg, sizeof(value)); \ |
| 3777 | 3787 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, value); \ |
| 3778 | 3788 | } \ |
| 3779 | static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \ | |
| 3789 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_relaxed_##Type(zig_##Type volatile* obj) { \ | |
| 3780 | 3790 | zig_##Type result; \ |
| 3781 | SigType initial = _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3791 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3782 | 3792 | memcpy(&result, &initial, sizeof(result)); \ |
| 3783 | 3793 | return result; \ |
| 3794 | } \ | |
| 3795 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_acquire_##Type(zig_##Type volatile* obj) { \ | |
| 3796 | zig_##Type result; \ | |
| 3797 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3798 | _ReadWriteBarrier(); \ | |
| 3799 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3800 | return result; \ | |
| 3801 | } \ | |
| 3802 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##Type(zig_##Type volatile* obj) { \ | |
| 3803 | zig_##Type result; \ | |
| 3804 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3805 | _ReadWriteBarrier(); \ | |
| 3806 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3807 | return result; \ | |
| 3784 | 3808 | } |
| 3785 | zig_msvc_flt_atomics(f32, long, ) | |
| 3809 | ||
| 3810 | zig_msvc_flt_atomics(f32, long, , 32) | |
| 3786 | 3811 | #if _M_X64 |
| 3787 | zig_msvc_flt_atomics(f64, int64_t, 64) | |
| 3812 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) | |
| 3788 | 3813 | #endif |
| 3789 | 3814 | |
| 3790 | 3815 | #if _M_IX86 |