| author | |
| committer | |
| log | f407109070be2a187c71cc2350ac6d9b7d64a3d0 |
| tree | 5e9c9130e0f14d20ea80f20911d05d1c64b7727b |
| parent | db17c0d88c44183b3060993d85657e7637b43d68 |
| signature | Commit is signed but in an unrecognized format. |
15 files changed, 199 insertions(+), 327 deletions(-)
lib/libc/mingw/misc/_create_locale.c created+33| ... | @@ -0,0 +1,33 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <windows.h> | ||
| 8 | #include <locale.h> | ||
| 9 | #include <msvcrt.h> | ||
| 10 | |||
| 11 | static _locale_t __cdecl init_func(int category, const char *locale); | ||
| 12 | _locale_t (__cdecl *__MINGW_IMP_SYMBOL(_create_locale))(int, const char *) = init_func; | ||
| 13 | |||
| 14 | static _locale_t __cdecl null_func(int category, const char *locale) | ||
| 15 | { | ||
| 16 | (void)category; | ||
| 17 | (void)locale; | ||
| 18 | return NULL; | ||
| 19 | } | ||
| 20 | |||
| 21 | static _locale_t __cdecl init_func(int category, const char *locale) | ||
| 22 | { | ||
| 23 | HMODULE msvcrt = __mingw_get_msvcrt_handle(); | ||
| 24 | _locale_t (__cdecl *func)(int, const char *) = NULL; | ||
| 25 | |||
| 26 | if (msvcrt) | ||
| 27 | func = (void*)GetProcAddress(msvcrt, "_create_locale"); | ||
| 28 | |||
| 29 | if (!func) | ||
| 30 | func = null_func; | ||
| 31 | |||
| 32 | return (__MINGW_IMP_SYMBOL(_create_locale) = func)(category, locale); | ||
| 33 | } | ||
lib/libc/mingw/misc/_free_locale.c created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <windows.h> | ||
| 8 | #include <locale.h> | ||
| 9 | #include <msvcrt.h> | ||
| 10 | |||
| 11 | static void __cdecl init_func(_locale_t locale); | ||
| 12 | void (__cdecl *__MINGW_IMP_SYMBOL(_free_locale))(_locale_t) = init_func; | ||
| 13 | |||
| 14 | static void __cdecl stub_func(_locale_t locale) | ||
| 15 | { | ||
| 16 | (void)locale; | ||
| 17 | } | ||
| 18 | |||
| 19 | static void __cdecl init_func(_locale_t locale) | ||
| 20 | { | ||
| 21 | HMODULE msvcrt = __mingw_get_msvcrt_handle(); | ||
| 22 | void (__cdecl *func)(_locale_t) = NULL; | ||
| 23 | |||
| 24 | if (msvcrt) | ||
| 25 | func = (void*)GetProcAddress(msvcrt, "_free_locale"); | ||
| 26 | |||
| 27 | if (!func) | ||
| 28 | func = stub_func; | ||
| 29 | |||
| 30 | (__MINGW_IMP_SYMBOL(_free_locale) = func)(locale); | ||
| 31 | } | ||
lib/libcxx/src/filesystem/int128_builtins.cpp deleted-54| ... | @@ -1,54 +0,0 @@ | ||
| 1 | /*===-- int128_builtins.cpp - Implement __muloti4 --------------------------=== | ||
| 2 | * | ||
| 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | * See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | * | ||
| 7 | * ===----------------------------------------------------------------------=== | ||
| 8 | * | ||
| 9 | * This file implements __muloti4, and is stolen from the compiler_rt library. | ||
| 10 | * | ||
| 11 | * FIXME: we steal and re-compile it into filesystem, which uses __int128_t, | ||
| 12 | * and requires this builtin when sanitized. See llvm.org/PR30643 | ||
| 13 | * | ||
| 14 | * ===----------------------------------------------------------------------=== | ||
| 15 | */ | ||
| 16 | #include "__config" | ||
| 17 | #include "climits" | ||
| 18 | |||
| 19 | #if !defined(_LIBCPP_HAS_NO_INT128) | ||
| 20 | |||
| 21 | extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_FUNC_VIS | ||
| 22 | __int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) { | ||
| 23 | const int N = (int)(sizeof(__int128_t) * CHAR_BIT); | ||
| 24 | const __int128_t MIN = (__int128_t)1 << (N - 1); | ||
| 25 | const __int128_t MAX = ~MIN; | ||
| 26 | *overflow = 0; | ||
| 27 | __int128_t result = a * b; | ||
| 28 | if (a == MIN) { | ||
| 29 | if (b != 0 && b != 1) | ||
| 30 | *overflow = 1; | ||
| 31 | return result; | ||
| 32 | } | ||
| 33 | if (b == MIN) { | ||
| 34 | if (a != 0 && a != 1) | ||
| 35 | *overflow = 1; | ||
| 36 | return result; | ||
| 37 | } | ||
| 38 | __int128_t sa = a >> (N - 1); | ||
| 39 | __int128_t abs_a = (a ^ sa) - sa; | ||
| 40 | __int128_t sb = b >> (N - 1); | ||
| 41 | __int128_t abs_b = (b ^ sb) - sb; | ||
| 42 | if (abs_a < 2 || abs_b < 2) | ||
| 43 | return result; | ||
| 44 | if (sa == sb) { | ||
| 45 | if (abs_a > MAX / abs_b) | ||
| 46 | *overflow = 1; | ||
| 47 | } else { | ||
| 48 | if (abs_a > MIN / -abs_b) | ||
| 49 | *overflow = 1; | ||
| 50 | } | ||
| 51 | return result; | ||
| 52 | } | ||
| 53 | |||
| 54 | #endif | ||
lib/libcxxabi/src/stdlib_new_delete.cpp deleted-262| ... | @@ -1,262 +0,0 @@ | ||
| 1 | //===--------------------- stdlib_new_delete.cpp --------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | // | ||
| 8 | // This file implements the new and delete operators. | ||
| 9 | //===----------------------------------------------------------------------===// | ||
| 10 | |||
| 11 | #define _LIBCPP_BUILDING_LIBRARY | ||
| 12 | #include "__cxxabi_config.h" | ||
| 13 | #include <new> | ||
| 14 | #include <cstdlib> | ||
| 15 | |||
| 16 | #if !defined(_THROW_BAD_ALLOC) || !defined(_NOEXCEPT) || !defined(_LIBCXXABI_WEAK) | ||
| 17 | #error The _THROW_BAD_ALLOC, _NOEXCEPT, and _LIBCXXABI_WEAK libc++ macros must \ | ||
| 18 | already be defined by libc++. | ||
| 19 | #endif | ||
| 20 | // Implement all new and delete operators as weak definitions | ||
| 21 | // in this shared library, so that they can be overridden by programs | ||
| 22 | // that define non-weak copies of the functions. | ||
| 23 | |||
| 24 | _LIBCXXABI_WEAK | ||
| 25 | void * | ||
| 26 | operator new(std::size_t size) _THROW_BAD_ALLOC | ||
| 27 | { | ||
| 28 | if (size == 0) | ||
| 29 | size = 1; | ||
| 30 | void* p; | ||
| 31 | while ((p = ::malloc(size)) == 0) | ||
| 32 | { | ||
| 33 | // If malloc fails and there is a new_handler, | ||
| 34 | // call it to try free up memory. | ||
| 35 | std::new_handler nh = std::get_new_handler(); | ||
| 36 | if (nh) | ||
| 37 | nh(); | ||
| 38 | else | ||
| 39 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 40 | throw std::bad_alloc(); | ||
| 41 | #else | ||
| 42 | break; | ||
| 43 | #endif | ||
| 44 | } | ||
| 45 | return p; | ||
| 46 | } | ||
| 47 | |||
| 48 | _LIBCXXABI_WEAK | ||
| 49 | void* | ||
| 50 | operator new(size_t size, const std::nothrow_t&) _NOEXCEPT | ||
| 51 | { | ||
| 52 | void* p = 0; | ||
| 53 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 54 | try | ||
| 55 | { | ||
| 56 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 57 | p = ::operator new(size); | ||
| 58 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 59 | } | ||
| 60 | catch (...) | ||
| 61 | { | ||
| 62 | } | ||
| 63 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 64 | return p; | ||
| 65 | } | ||
| 66 | |||
| 67 | _LIBCXXABI_WEAK | ||
| 68 | void* | ||
| 69 | operator new[](size_t size) _THROW_BAD_ALLOC | ||
| 70 | { | ||
| 71 | return ::operator new(size); | ||
| 72 | } | ||
| 73 | |||
| 74 | _LIBCXXABI_WEAK | ||
| 75 | void* | ||
| 76 | operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT | ||
| 77 | { | ||
| 78 | void* p = 0; | ||
| 79 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 80 | try | ||
| 81 | { | ||
| 82 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 83 | p = ::operator new[](size); | ||
| 84 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 85 | } | ||
| 86 | catch (...) | ||
| 87 | { | ||
| 88 | } | ||
| 89 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 90 | return p; | ||
| 91 | } | ||
| 92 | |||
| 93 | _LIBCXXABI_WEAK | ||
| 94 | void | ||
| 95 | operator delete(void* ptr) _NOEXCEPT | ||
| 96 | { | ||
| 97 | if (ptr) | ||
| 98 | ::free(ptr); | ||
| 99 | } | ||
| 100 | |||
| 101 | _LIBCXXABI_WEAK | ||
| 102 | void | ||
| 103 | operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT | ||
| 104 | { | ||
| 105 | ::operator delete(ptr); | ||
| 106 | } | ||
| 107 | |||
| 108 | _LIBCXXABI_WEAK | ||
| 109 | void | ||
| 110 | operator delete(void* ptr, size_t) _NOEXCEPT | ||
| 111 | { | ||
| 112 | ::operator delete(ptr); | ||
| 113 | } | ||
| 114 | |||
| 115 | _LIBCXXABI_WEAK | ||
| 116 | void | ||
| 117 | operator delete[] (void* ptr) _NOEXCEPT | ||
| 118 | { | ||
| 119 | ::operator delete(ptr); | ||
| 120 | } | ||
| 121 | |||
| 122 | _LIBCXXABI_WEAK | ||
| 123 | void | ||
| 124 | operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT | ||
| 125 | { | ||
| 126 | ::operator delete[](ptr); | ||
| 127 | } | ||
| 128 | |||
| 129 | _LIBCXXABI_WEAK | ||
| 130 | void | ||
| 131 | operator delete[] (void* ptr, size_t) _NOEXCEPT | ||
| 132 | { | ||
| 133 | ::operator delete[](ptr); | ||
| 134 | } | ||
| 135 | |||
| 136 | #if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) | ||
| 137 | |||
| 138 | _LIBCXXABI_WEAK | ||
| 139 | void * | ||
| 140 | operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC | ||
| 141 | { | ||
| 142 | if (size == 0) | ||
| 143 | size = 1; | ||
| 144 | if (static_cast<size_t>(alignment) < sizeof(void*)) | ||
| 145 | alignment = std::align_val_t(sizeof(void*)); | ||
| 146 | void* p; | ||
| 147 | #if defined(_LIBCPP_WIN32API) | ||
| 148 | while ((p = _aligned_malloc(size, static_cast<size_t>(alignment))) == nullptr) | ||
| 149 | #else | ||
| 150 | while (::posix_memalign(&p, static_cast<size_t>(alignment), size) != 0) | ||
| 151 | #endif | ||
| 152 | { | ||
| 153 | // If posix_memalign fails and there is a new_handler, | ||
| 154 | // call it to try free up memory. | ||
| 155 | std::new_handler nh = std::get_new_handler(); | ||
| 156 | if (nh) | ||
| 157 | nh(); | ||
| 158 | else { | ||
| 159 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 160 | throw std::bad_alloc(); | ||
| 161 | #else | ||
| 162 | p = nullptr; // posix_memalign doesn't initialize 'p' on failure | ||
| 163 | break; | ||
| 164 | #endif | ||
| 165 | } | ||
| 166 | } | ||
| 167 | return p; | ||
| 168 | } | ||
| 169 | |||
| 170 | _LIBCXXABI_WEAK | ||
| 171 | void* | ||
| 172 | operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT | ||
| 173 | { | ||
| 174 | void* p = 0; | ||
| 175 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 176 | try | ||
| 177 | { | ||
| 178 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 179 | p = ::operator new(size, alignment); | ||
| 180 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 181 | } | ||
| 182 | catch (...) | ||
| 183 | { | ||
| 184 | } | ||
| 185 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 186 | return p; | ||
| 187 | } | ||
| 188 | |||
| 189 | _LIBCXXABI_WEAK | ||
| 190 | void* | ||
| 191 | operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC | ||
| 192 | { | ||
| 193 | return ::operator new(size, alignment); | ||
| 194 | } | ||
| 195 | |||
| 196 | _LIBCXXABI_WEAK | ||
| 197 | void* | ||
| 198 | operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT | ||
| 199 | { | ||
| 200 | void* p = 0; | ||
| 201 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 202 | try | ||
| 203 | { | ||
| 204 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 205 | p = ::operator new[](size, alignment); | ||
| 206 | #ifndef _LIBCXXABI_NO_EXCEPTIONS | ||
| 207 | } | ||
| 208 | catch (...) | ||
| 209 | { | ||
| 210 | } | ||
| 211 | #endif // _LIBCXXABI_NO_EXCEPTIONS | ||
| 212 | return p; | ||
| 213 | } | ||
| 214 | |||
| 215 | _LIBCXXABI_WEAK | ||
| 216 | void | ||
| 217 | operator delete(void* ptr, std::align_val_t) _NOEXCEPT | ||
| 218 | { | ||
| 219 | if (ptr) | ||
| 220 | #if defined(_LIBCPP_WIN32API) | ||
| 221 | ::_aligned_free(ptr); | ||
| 222 | #else | ||
| 223 | ::free(ptr); | ||
| 224 | #endif | ||
| 225 | } | ||
| 226 | |||
| 227 | _LIBCXXABI_WEAK | ||
| 228 | void | ||
| 229 | operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT | ||
| 230 | { | ||
| 231 | ::operator delete(ptr, alignment); | ||
| 232 | } | ||
| 233 | |||
| 234 | _LIBCXXABI_WEAK | ||
| 235 | void | ||
| 236 | operator delete(void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT | ||
| 237 | { | ||
| 238 | ::operator delete(ptr, alignment); | ||
| 239 | } | ||
| 240 | |||
| 241 | _LIBCXXABI_WEAK | ||
| 242 | void | ||
| 243 | operator delete[] (void* ptr, std::align_val_t alignment) _NOEXCEPT | ||
| 244 | { | ||
| 245 | ::operator delete(ptr, alignment); | ||
| 246 | } | ||
| 247 | |||
| 248 | _LIBCXXABI_WEAK | ||
| 249 | void | ||
| 250 | operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT | ||
| 251 | { | ||
| 252 | ::operator delete[](ptr, alignment); | ||
| 253 | } | ||
| 254 | |||
| 255 | _LIBCXXABI_WEAK | ||
| 256 | void | ||
| 257 | operator delete[] (void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT | ||
| 258 | { | ||
| 259 | ::operator delete[](ptr, alignment); | ||
| 260 | } | ||
| 261 | |||
| 262 | #endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | ||
src-self-hosted/stage2.zig+4| ... | @@ -1283,6 +1283,10 @@ pub const ClangArgIterator = extern struct { | ... | @@ -1283,6 +1283,10 @@ pub const ClangArgIterator = extern struct { |
| 1283 | sanitize, | 1283 | sanitize, |
| 1284 | linker_script, | 1284 | linker_script, |
| 1285 | verbose_cmds, | 1285 | verbose_cmds, |
| 1286 | exceptions, | ||
| 1287 | no_exceptions, | ||
| 1288 | rtti, | ||
| 1289 | no_rtti, | ||
| 1286 | }; | 1290 | }; |
| 1287 | 1291 | ||
| 1288 | fn init(argv: []const [*:0]const u8) ClangArgIterator { | 1292 | fn init(argv: []const [*:0]const u8) ClangArgIterator { |
src/all_types.hpp+2| ... | @@ -2262,6 +2262,8 @@ struct CodeGen { | ... | @@ -2262,6 +2262,8 @@ struct CodeGen { |
| 2262 | bool emit_asm; | 2262 | bool emit_asm; |
| 2263 | bool emit_llvm_ir; | 2263 | bool emit_llvm_ir; |
| 2264 | bool test_is_evented; | 2264 | bool test_is_evented; |
| 2265 | bool cpp_rtti; | ||
| 2266 | bool cpp_exceptions; | ||
| 2265 | CodeModel code_model; | 2267 | CodeModel code_model; |
| 2266 | 2268 | ||
| 2267 | Buf *root_out_name; | 2269 | Buf *root_out_name; |
src/analyze.hpp+1| ... | @@ -260,6 +260,7 @@ ZigLLVMDIType *get_llvm_di_type(CodeGen *g, ZigType *type); | ... | @@ -260,6 +260,7 @@ ZigLLVMDIType *get_llvm_di_type(CodeGen *g, ZigType *type); |
| 260 | enum CSourceKind { | 260 | enum CSourceKind { |
| 261 | CSourceKindAsm, | 261 | CSourceKindAsm, |
| 262 | CSourceKindC, | 262 | CSourceKindC, |
| 263 | CSourceKindCpp, | ||
| 263 | }; | 264 | }; |
| 264 | 265 | ||
| 265 | void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_path, bool translate_c, | 266 | void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_path, bool translate_c, |
src/codegen.cpp+26-1| ... | @@ -8448,6 +8448,8 @@ static bool detect_dynamic_link(CodeGen *g) { | ... | @@ -8448,6 +8448,8 @@ static bool detect_dynamic_link(CodeGen *g) { |
| 8448 | LinkLib *link_lib = g->link_libs_list.at(i); | 8448 | LinkLib *link_lib = g->link_libs_list.at(i); |
| 8449 | if (target_is_libc_lib_name(g->zig_target, buf_ptr(link_lib->name))) | 8449 | if (target_is_libc_lib_name(g->zig_target, buf_ptr(link_lib->name))) |
| 8450 | continue; | 8450 | continue; |
| 8451 | if (target_is_libcpp_lib_name(g->zig_target, buf_ptr(link_lib->name))) | ||
| 8452 | continue; | ||
| 8451 | return true; | 8453 | return true; |
| 8452 | } | 8454 | } |
| 8453 | return false; | 8455 | return false; |
| ... | @@ -8782,6 +8784,8 @@ static Error define_builtin_compile_vars(CodeGen *g) { | ... | @@ -8782,6 +8784,8 @@ static Error define_builtin_compile_vars(CodeGen *g) { |
| 8782 | cache_bool(&cache_hash, g->is_test_build); | 8784 | cache_bool(&cache_hash, g->is_test_build); |
| 8783 | cache_bool(&cache_hash, g->is_single_threaded); | 8785 | cache_bool(&cache_hash, g->is_single_threaded); |
| 8784 | cache_bool(&cache_hash, g->test_is_evented); | 8786 | cache_bool(&cache_hash, g->test_is_evented); |
| 8787 | cache_bool(&cache_hash, g->cpp_rtti); | ||
| 8788 | cache_bool(&cache_hash, g->cpp_exceptions); | ||
| 8785 | cache_int(&cache_hash, g->code_model); | 8789 | cache_int(&cache_hash, g->code_model); |
| 8786 | cache_int(&cache_hash, g->zig_target->is_native_os); | 8790 | cache_int(&cache_hash, g->zig_target->is_native_os); |
| 8787 | cache_int(&cache_hash, g->zig_target->is_native_cpu); | 8791 | cache_int(&cache_hash, g->zig_target->is_native_cpu); |
| ... | @@ -9181,7 +9185,7 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa | ... | @@ -9181,7 +9185,7 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 9181 | } | 9185 | } |
| 9182 | 9186 | ||
| 9183 | if (translate_c) { | 9187 | if (translate_c) { |
| 9184 | if (source_kind == CSourceKindC) { | 9188 | if (source_kind != CSourceKindAsm) { |
| 9185 | // this gives us access to preprocessing entities, presumably at | 9189 | // this gives us access to preprocessing entities, presumably at |
| 9186 | // the cost of performance | 9190 | // the cost of performance |
| 9187 | args.append("-Xclang"); | 9191 | args.append("-Xclang"); |
| ... | @@ -9213,6 +9217,12 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa | ... | @@ -9213,6 +9217,12 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 9213 | 9217 | ||
| 9214 | args.append("-isystem"); | 9218 | args.append("-isystem"); |
| 9215 | args.append(libcxx_include_path); | 9219 | args.append(libcxx_include_path); |
| 9220 | |||
| 9221 | if (target_abi_is_musl(g->zig_target->abi)) { | ||
| 9222 | args.append("-D_LIBCPP_HAS_MUSL_LIBC"); | ||
| 9223 | } | ||
| 9224 | args.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 9225 | args.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 9216 | } | 9226 | } |
| 9217 | 9227 | ||
| 9218 | // According to Rich Felker libc headers are supposed to go before C language headers. | 9228 | // According to Rich Felker libc headers are supposed to go before C language headers. |
| ... | @@ -9232,6 +9242,7 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa | ... | @@ -9232,6 +9242,7 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 9232 | 9242 | ||
| 9233 | switch (source_kind) { | 9243 | switch (source_kind) { |
| 9234 | case CSourceKindC: | 9244 | case CSourceKindC: |
| 9245 | case CSourceKindCpp: | ||
| 9235 | if (g->zig_target->llvm_cpu_name != nullptr) { | 9246 | if (g->zig_target->llvm_cpu_name != nullptr) { |
| 9236 | args.append("-Xclang"); | 9247 | args.append("-Xclang"); |
| 9237 | args.append("-target-cpu"); | 9248 | args.append("-target-cpu"); |
| ... | @@ -9248,6 +9259,14 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa | ... | @@ -9248,6 +9259,14 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 9248 | case CSourceKindAsm: | 9259 | case CSourceKindAsm: |
| 9249 | break; | 9260 | break; |
| 9250 | } | 9261 | } |
| 9262 | if (source_kind == CSourceKindCpp) { | ||
| 9263 | if (!g->cpp_rtti) { | ||
| 9264 | args.append("-fno-rtti"); | ||
| 9265 | } | ||
| 9266 | if (!g->cpp_exceptions) { | ||
| 9267 | args.append("-fno-exceptions"); | ||
| 9268 | } | ||
| 9269 | } | ||
| 9251 | for (size_t i = 0; i < g->zig_target->llvm_cpu_features_asm_len; i += 1) { | 9270 | for (size_t i = 0; i < g->zig_target->llvm_cpu_features_asm_len; i += 1) { |
| 9252 | args.append(g->zig_target->llvm_cpu_features_asm_ptr[i]); | 9271 | args.append(g->zig_target->llvm_cpu_features_asm_ptr[i]); |
| 9253 | } | 9272 | } |
| ... | @@ -9695,6 +9714,8 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose | ... | @@ -9695,6 +9714,8 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose |
| 9695 | cache_bool(cache_hash, g->have_sanitize_c); | 9714 | cache_bool(cache_hash, g->have_sanitize_c); |
| 9696 | cache_bool(cache_hash, want_valgrind_support(g)); | 9715 | cache_bool(cache_hash, want_valgrind_support(g)); |
| 9697 | cache_bool(cache_hash, g->function_sections); | 9716 | cache_bool(cache_hash, g->function_sections); |
| 9717 | cache_bool(cache_hash, g->cpp_rtti); | ||
| 9718 | cache_bool(cache_hash, g->cpp_exceptions); | ||
| 9698 | cache_int(cache_hash, g->code_model); | 9719 | cache_int(cache_hash, g->code_model); |
| 9699 | 9720 | ||
| 9700 | for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) { | 9721 | for (size_t arg_i = 0; arg_i < g->clang_argv_len; arg_i += 1) { |
| ... | @@ -10529,6 +10550,8 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { | ... | @@ -10529,6 +10550,8 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 10529 | cache_bool(ch, g->emit_bin); | 10550 | cache_bool(ch, g->emit_bin); |
| 10530 | cache_bool(ch, g->emit_llvm_ir); | 10551 | cache_bool(ch, g->emit_llvm_ir); |
| 10531 | cache_bool(ch, g->emit_asm); | 10552 | cache_bool(ch, g->emit_asm); |
| 10553 | cache_bool(ch, g->cpp_rtti); | ||
| 10554 | cache_bool(ch, g->cpp_exceptions); | ||
| 10532 | cache_usize(ch, g->version_major); | 10555 | cache_usize(ch, g->version_major); |
| 10533 | cache_usize(ch, g->version_minor); | 10556 | cache_usize(ch, g->version_minor); |
| 10534 | cache_usize(ch, g->version_patch); | 10557 | cache_usize(ch, g->version_patch); |
| ... | @@ -10833,6 +10856,8 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o | ... | @@ -10833,6 +10856,8 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o |
| 10833 | parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_global_cache_dir(), false, child_progress_node); | 10856 | parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_global_cache_dir(), false, child_progress_node); |
| 10834 | child_gen->root_out_name = buf_create_from_str(name); | 10857 | child_gen->root_out_name = buf_create_from_str(name); |
| 10835 | child_gen->disable_gen_h = true; | 10858 | child_gen->disable_gen_h = true; |
| 10859 | child_gen->cpp_rtti = parent_gen->cpp_rtti; | ||
| 10860 | child_gen->cpp_exceptions = parent_gen->cpp_exceptions; | ||
| 10836 | child_gen->want_stack_check = WantStackCheckDisabled; | 10861 | child_gen->want_stack_check = WantStackCheckDisabled; |
| 10837 | child_gen->want_sanitize_c = WantCSanitizeDisabled; | 10862 | child_gen->want_sanitize_c = WantCSanitizeDisabled; |
| 10838 | child_gen->verbose_tokenize = parent_gen->verbose_tokenize; | 10863 | child_gen->verbose_tokenize = parent_gen->verbose_tokenize; |
src/install_files.h-2| ... | @@ -1859,7 +1859,6 @@ static const char *ZIG_LIBCXXABI_FILES[] = { | ... | @@ -1859,7 +1859,6 @@ static const char *ZIG_LIBCXXABI_FILES[] = { |
| 1859 | "src/fallback_malloc.cpp", | 1859 | "src/fallback_malloc.cpp", |
| 1860 | "src/private_typeinfo.cpp", | 1860 | "src/private_typeinfo.cpp", |
| 1861 | "src/stdlib_exception.cpp", | 1861 | "src/stdlib_exception.cpp", |
| 1862 | "src/stdlib_new_delete.cpp", | ||
| 1863 | "src/stdlib_stdexcept.cpp", | 1862 | "src/stdlib_stdexcept.cpp", |
| 1864 | "src/stdlib_typeinfo.cpp", | 1863 | "src/stdlib_typeinfo.cpp", |
| 1865 | }; | 1864 | }; |
| ... | @@ -1875,7 +1874,6 @@ static const char *ZIG_LIBCXX_FILES[] = { | ... | @@ -1875,7 +1874,6 @@ static const char *ZIG_LIBCXX_FILES[] = { |
| 1875 | "src/exception.cpp", | 1874 | "src/exception.cpp", |
| 1876 | "src/experimental/memory_resource.cpp", | 1875 | "src/experimental/memory_resource.cpp", |
| 1877 | "src/filesystem/directory_iterator.cpp", | 1876 | "src/filesystem/directory_iterator.cpp", |
| 1878 | "src/filesystem/int128_builtins.cpp", | ||
| 1879 | "src/filesystem/operations.cpp", | 1877 | "src/filesystem/operations.cpp", |
| 1880 | "src/functional.cpp", | 1878 | "src/functional.cpp", |
| 1881 | "src/future.cpp", | 1879 | "src/future.cpp", |
src/link.cpp+56-8| ... | @@ -14,6 +14,8 @@ | ... | @@ -14,6 +14,8 @@ |
| 14 | #include "glibc.hpp" | 14 | #include "glibc.hpp" |
| 15 | 15 | ||
| 16 | static const char *msvcrt_common_src[] = { | 16 | static const char *msvcrt_common_src[] = { |
| 17 | "misc" OS_SEP "_create_locale.c", | ||
| 18 | "misc" OS_SEP "_free_locale.c", | ||
| 17 | "misc" OS_SEP "onexit_table.c", | 19 | "misc" OS_SEP "onexit_table.c", |
| 18 | "misc" OS_SEP "register_tls_atexit.c", | 20 | "misc" OS_SEP "register_tls_atexit.c", |
| 19 | "stdio" OS_SEP "acrt_iob_func.c", | 21 | "stdio" OS_SEP "acrt_iob_func.c", |
| ... | @@ -632,12 +634,17 @@ static const char *build_libunwind(CodeGen *parent, Stage2ProgressNode *progress | ... | @@ -632,12 +634,17 @@ static const char *build_libunwind(CodeGen *parent, Stage2ProgressNode *progress |
| 632 | } | 634 | } |
| 633 | c_file->args.append("-I"); | 635 | c_file->args.append("-I"); |
| 634 | c_file->args.append(path_from_libunwind(parent, "include")); | 636 | c_file->args.append(path_from_libunwind(parent, "include")); |
| 635 | c_file->args.append("-fPIC"); | 637 | if (target_supports_fpic(parent->zig_target)) { |
| 638 | c_file->args.append("-fPIC"); | ||
| 639 | } | ||
| 636 | c_file->args.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); | 640 | c_file->args.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 637 | c_file->args.append("-Wa,--noexecstack"); | 641 | c_file->args.append("-Wa,--noexecstack"); |
| 638 | if (parent->zig_target->is_native_os && parent->zig_target->is_native_cpu) { | 642 | |
| 639 | c_file->args.append("-D_LIBUNWIND_IS_NATIVE_ONLY"); | 643 | // This is intentionally always defined because the macro definition means, should it only |
| 640 | } | 644 | // build for the target specified by compiler defines. Since we pass -target the compiler |
| 645 | // defines will be correct. | ||
| 646 | c_file->args.append("-D_LIBUNWIND_IS_NATIVE_ONLY"); | ||
| 647 | |||
| 641 | if (parent->build_mode == BuildModeDebug) { | 648 | if (parent->build_mode == BuildModeDebug) { |
| 642 | c_file->args.append("-D_DEBUG"); | 649 | c_file->args.append("-D_DEBUG"); |
| 643 | } | 650 | } |
| ... | @@ -1129,6 +1136,12 @@ static const char *build_libcxxabi(CodeGen *parent, Stage2ProgressNode *progress | ... | @@ -1129,6 +1136,12 @@ static const char *build_libcxxabi(CodeGen *parent, Stage2ProgressNode *progress |
| 1129 | c_file->args.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); | 1136 | c_file->args.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); |
| 1130 | c_file->args.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); | 1137 | c_file->args.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); |
| 1131 | c_file->args.append("-D_LIBCXXABI_BUILDING_LIBRARY"); | 1138 | c_file->args.append("-D_LIBCXXABI_BUILDING_LIBRARY"); |
| 1139 | c_file->args.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 1140 | c_file->args.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 1141 | |||
| 1142 | if (target_abi_is_musl(parent->zig_target->abi)) { | ||
| 1143 | c_file->args.append("-D_LIBCPP_HAS_MUSL_LIBC"); | ||
| 1144 | } | ||
| 1132 | 1145 | ||
| 1133 | c_file->args.append("-I"); | 1146 | c_file->args.append("-I"); |
| 1134 | c_file->args.append(cxxabi_include_path); | 1147 | c_file->args.append(cxxabi_include_path); |
| ... | @@ -1138,7 +1151,9 @@ static const char *build_libcxxabi(CodeGen *parent, Stage2ProgressNode *progress | ... | @@ -1138,7 +1151,9 @@ static const char *build_libcxxabi(CodeGen *parent, Stage2ProgressNode *progress |
| 1138 | 1151 | ||
| 1139 | c_file->args.append("-O3"); | 1152 | c_file->args.append("-O3"); |
| 1140 | c_file->args.append("-DNDEBUG"); | 1153 | c_file->args.append("-DNDEBUG"); |
| 1141 | c_file->args.append("-fPIC"); | 1154 | if (target_supports_fpic(parent->zig_target)) { |
| 1155 | c_file->args.append("-fPIC"); | ||
| 1156 | } | ||
| 1142 | c_file->args.append("-nostdinc++"); | 1157 | c_file->args.append("-nostdinc++"); |
| 1143 | c_file->args.append("-fstrict-aliasing"); | 1158 | c_file->args.append("-fstrict-aliasing"); |
| 1144 | c_file->args.append("-funwind-tables"); | 1159 | c_file->args.append("-funwind-tables"); |
| ... | @@ -1170,8 +1185,15 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no | ... | @@ -1170,8 +1185,15 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no |
| 1170 | const char *rel_src_path = ZIG_LIBCXX_FILES[i]; | 1185 | const char *rel_src_path = ZIG_LIBCXX_FILES[i]; |
| 1171 | 1186 | ||
| 1172 | Buf *src_path_buf = buf_create_from_str(rel_src_path); | 1187 | Buf *src_path_buf = buf_create_from_str(rel_src_path); |
| 1173 | if (buf_starts_with_str(src_path_buf, "src/support/win32") && parent->zig_target->os != OsWindows) { | 1188 | if (parent->zig_target->os == OsWindows) { |
| 1174 | continue; | 1189 | // filesystem stuff isn't supported on Windows |
| 1190 | if (buf_starts_with_str(src_path_buf, "src/filesystem/")) { | ||
| 1191 | continue; | ||
| 1192 | } | ||
| 1193 | } else { | ||
| 1194 | if (buf_starts_with_str(src_path_buf, "src/support/win32/")) { | ||
| 1195 | continue; | ||
| 1196 | } | ||
| 1175 | } | 1197 | } |
| 1176 | 1198 | ||
| 1177 | CFile *c_file = heap::c_allocator.create<CFile>(); | 1199 | CFile *c_file = heap::c_allocator.create<CFile>(); |
| ... | @@ -1182,6 +1204,12 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no | ... | @@ -1182,6 +1204,12 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no |
| 1182 | c_file->args.append("-D_LIBCPP_BUILDING_LIBRARY"); | 1204 | c_file->args.append("-D_LIBCPP_BUILDING_LIBRARY"); |
| 1183 | c_file->args.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER"); | 1205 | c_file->args.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER"); |
| 1184 | c_file->args.append("-DLIBCXX_BUILDING_LIBCXXABI"); | 1206 | c_file->args.append("-DLIBCXX_BUILDING_LIBCXXABI"); |
| 1207 | c_file->args.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 1208 | c_file->args.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | ||
| 1209 | |||
| 1210 | if (target_abi_is_musl(parent->zig_target->abi)) { | ||
| 1211 | c_file->args.append("-D_LIBCPP_HAS_MUSL_LIBC"); | ||
| 1212 | } | ||
| 1185 | 1213 | ||
| 1186 | c_file->args.append("-I"); | 1214 | c_file->args.append("-I"); |
| 1187 | c_file->args.append(cxx_include_path); | 1215 | c_file->args.append(cxx_include_path); |
| ... | @@ -1191,7 +1219,9 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no | ... | @@ -1191,7 +1219,9 @@ static const char *build_libcxx(CodeGen *parent, Stage2ProgressNode *progress_no |
| 1191 | 1219 | ||
| 1192 | c_file->args.append("-O3"); | 1220 | c_file->args.append("-O3"); |
| 1193 | c_file->args.append("-DNDEBUG"); | 1221 | c_file->args.append("-DNDEBUG"); |
| 1194 | c_file->args.append("-fPIC"); | 1222 | if (target_supports_fpic(parent->zig_target)) { |
| 1223 | c_file->args.append("-fPIC"); | ||
| 1224 | } | ||
| 1195 | c_file->args.append("-nostdinc++"); | 1225 | c_file->args.append("-nostdinc++"); |
| 1196 | c_file->args.append("-fvisibility-inlines-hidden"); | 1226 | c_file->args.append("-fvisibility-inlines-hidden"); |
| 1197 | c_file->args.append("-std=c++14"); | 1227 | c_file->args.append("-std=c++14"); |
| ... | @@ -1923,6 +1953,8 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -1923,6 +1953,8 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 1923 | lj->args.append(build_libunwind(g, lj->build_dep_prog_node)); | 1953 | lj->args.append(build_libunwind(g, lj->build_dep_prog_node)); |
| 1924 | } | 1954 | } |
| 1925 | lj->args.append(build_musl(g, lj->build_dep_prog_node)); | 1955 | lj->args.append(build_musl(g, lj->build_dep_prog_node)); |
| 1956 | } else if (g->libcpp_link_lib != nullptr) { | ||
| 1957 | lj->args.append(build_libunwind(g, lj->build_dep_prog_node)); | ||
| 1926 | } else { | 1958 | } else { |
| 1927 | zig_unreachable(); | 1959 | zig_unreachable(); |
| 1928 | } | 1960 | } |
| ... | @@ -2411,6 +2443,13 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -2411,6 +2443,13 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 2411 | break; | 2443 | break; |
| 2412 | } | 2444 | } |
| 2413 | 2445 | ||
| 2446 | // libc++ dep | ||
| 2447 | if (g->libcpp_link_lib != nullptr && g->out_type != OutTypeObj) { | ||
| 2448 | lj->args.append(build_libcxxabi(g, lj->build_dep_prog_node)); | ||
| 2449 | lj->args.append(build_libcxx(g, lj->build_dep_prog_node)); | ||
| 2450 | lj->args.append(build_libunwind(g, lj->build_dep_prog_node)); | ||
| 2451 | } | ||
| 2452 | |||
| 2414 | if (g->out_type == OutTypeExe || (g->out_type == OutTypeLib && g->is_dynamic)) { | 2453 | if (g->out_type == OutTypeExe || (g->out_type == OutTypeLib && g->is_dynamic)) { |
| 2415 | if (g->libc_link_lib == nullptr && !g->is_dummy_so) { | 2454 | if (g->libc_link_lib == nullptr && !g->is_dummy_so) { |
| 2416 | Buf *libc_a_path = build_c(g, OutTypeLib, lj->build_dep_prog_node); | 2455 | Buf *libc_a_path = build_c(g, OutTypeLib, lj->build_dep_prog_node); |
| ... | @@ -2427,6 +2466,9 @@ static void construct_linker_job_coff(LinkJob *lj) { | ... | @@ -2427,6 +2466,9 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 2427 | if (buf_eql_str(link_lib->name, "c")) { | 2466 | if (buf_eql_str(link_lib->name, "c")) { |
| 2428 | continue; | 2467 | continue; |
| 2429 | } | 2468 | } |
| 2469 | if (buf_eql_str(link_lib->name, "c++") || buf_eql_str(link_lib->name, "c++abi")) { | ||
| 2470 | continue; | ||
| 2471 | } | ||
| 2430 | bool is_sys_lib = is_mingw_link_lib(link_lib->name); | 2472 | bool is_sys_lib = is_mingw_link_lib(link_lib->name); |
| 2431 | if (have_windows_dll_import_libs && is_sys_lib) { | 2473 | if (have_windows_dll_import_libs && is_sys_lib) { |
| 2432 | continue; | 2474 | continue; |
| ... | @@ -2562,6 +2604,12 @@ static void construct_linker_job_macho(LinkJob *lj) { | ... | @@ -2562,6 +2604,12 @@ static void construct_linker_job_macho(LinkJob *lj) { |
| 2562 | lj->args.append((const char *)buf_ptr(g->link_objects.at(i))); | 2604 | lj->args.append((const char *)buf_ptr(g->link_objects.at(i))); |
| 2563 | } | 2605 | } |
| 2564 | 2606 | ||
| 2607 | // libc++ dep | ||
| 2608 | if (g->libcpp_link_lib != nullptr && g->out_type != OutTypeObj) { | ||
| 2609 | lj->args.append(build_libcxxabi(g, lj->build_dep_prog_node)); | ||
| 2610 | lj->args.append(build_libcxx(g, lj->build_dep_prog_node)); | ||
| 2611 | } | ||
| 2612 | |||
| 2565 | // compiler_rt on darwin is missing some stuff, so we still build it and rely on LinkOnce | 2613 | // compiler_rt on darwin is missing some stuff, so we still build it and rely on LinkOnce |
| 2566 | if (g->out_type == OutTypeExe || is_dyn_lib) { | 2614 | if (g->out_type == OutTypeExe || is_dyn_lib) { |
| 2567 | Buf *compiler_rt_o_path = build_compiler_rt(g, OutTypeLib, lj->build_dep_prog_node); | 2615 | Buf *compiler_rt_o_path = build_compiler_rt(g, OutTypeLib, lj->build_dep_prog_node); |
src/main.cpp+18| ... | @@ -458,6 +458,8 @@ static int main0(int argc, char **argv) { | ... | @@ -458,6 +458,8 @@ static int main0(int argc, char **argv) { |
| 458 | bool only_preprocess = false; | 458 | bool only_preprocess = false; |
| 459 | bool ensure_libc_on_non_freestanding = false; | 459 | bool ensure_libc_on_non_freestanding = false; |
| 460 | bool ensure_libcpp_on_non_freestanding = false; | 460 | bool ensure_libcpp_on_non_freestanding = false; |
| 461 | bool cpp_rtti = true; | ||
| 462 | bool cpp_exceptions = true; | ||
| 461 | 463 | ||
| 462 | ZigList<const char *> llvm_argv = {0}; | 464 | ZigList<const char *> llvm_argv = {0}; |
| 463 | llvm_argv.append("zig (LLVM option parsing)"); | 465 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | @@ -720,6 +722,18 @@ static int main0(int argc, char **argv) { | ... | @@ -720,6 +722,18 @@ static int main0(int argc, char **argv) { |
| 720 | verbose_cc = true; | 722 | verbose_cc = true; |
| 721 | verbose_link = true; | 723 | verbose_link = true; |
| 722 | break; | 724 | break; |
| 725 | case Stage2ClangArgExceptions: | ||
| 726 | cpp_exceptions = true; | ||
| 727 | break; | ||
| 728 | case Stage2ClangArgNoExceptions: | ||
| 729 | cpp_exceptions = false; | ||
| 730 | break; | ||
| 731 | case Stage2ClangArgRtti: | ||
| 732 | cpp_rtti = true; | ||
| 733 | break; | ||
| 734 | case Stage2ClangArgNoRtti: | ||
| 735 | cpp_rtti = false; | ||
| 736 | break; | ||
| 723 | } | 737 | } |
| 724 | } | 738 | } |
| 725 | // Parse linker args | 739 | // Parse linker args |
| ... | @@ -1303,6 +1317,8 @@ static int main0(int argc, char **argv) { | ... | @@ -1303,6 +1317,8 @@ static int main0(int argc, char **argv) { |
| 1303 | LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i))); | 1317 | LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i))); |
| 1304 | link_lib->provided_explicitly = true; | 1318 | link_lib->provided_explicitly = true; |
| 1305 | } | 1319 | } |
| 1320 | g->cpp_rtti = cpp_rtti; | ||
| 1321 | g->cpp_exceptions = cpp_exceptions; | ||
| 1306 | g->subsystem = subsystem; | 1322 | g->subsystem = subsystem; |
| 1307 | g->valgrind_support = valgrind_support; | 1323 | g->valgrind_support = valgrind_support; |
| 1308 | g->want_pic = want_pic; | 1324 | g->want_pic = want_pic; |
| ... | @@ -1449,6 +1465,8 @@ static int main0(int argc, char **argv) { | ... | @@ -1449,6 +1465,8 @@ static int main0(int argc, char **argv) { |
| 1449 | } | 1465 | } |
| 1450 | CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode, | 1466 | CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode, |
| 1451 | override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node); | 1467 | override_lib_dir, libc, cache_dir_buf, cmd == CmdTest, root_progress_node); |
| 1468 | g->cpp_rtti = cpp_rtti; | ||
| 1469 | g->cpp_exceptions = cpp_exceptions; | ||
| 1452 | if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2); | 1470 | if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2); |
| 1453 | g->valgrind_support = valgrind_support; | 1471 | g->valgrind_support = valgrind_support; |
| 1454 | g->link_eh_frame_hdr = link_eh_frame_hdr; | 1472 | g->link_eh_frame_hdr = link_eh_frame_hdr; |
src/stage2.h+4| ... | @@ -344,6 +344,10 @@ enum Stage2ClangArg { | ... | @@ -344,6 +344,10 @@ enum Stage2ClangArg { |
| 344 | Stage2ClangArgSanitize, | 344 | Stage2ClangArgSanitize, |
| 345 | Stage2ClangArgLinkerScript, | 345 | Stage2ClangArgLinkerScript, |
| 346 | Stage2ClangArgVerboseCmds, | 346 | Stage2ClangArgVerboseCmds, |
| 347 | Stage2ClangArgExceptions, | ||
| 348 | Stage2ClangArgNoExceptions, | ||
| 349 | Stage2ClangArgRtti, | ||
| 350 | Stage2ClangArgNoRtti, | ||
| 347 | }; | 351 | }; |
| 348 | 352 | ||
| 349 | // ABI warning | 353 | // ABI warning |
src/target.cpp+7| ... | @@ -1229,6 +1229,13 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) { | ... | @@ -1229,6 +1229,13 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) { |
| 1229 | return false; | 1229 | return false; |
| 1230 | } | 1230 | } |
| 1231 | 1231 | ||
| 1232 | bool target_is_libcpp_lib_name(const ZigTarget *target, const char *name) { | ||
| 1233 | if (strcmp(name, "c++") == 0 || strcmp(name, "c++abi") == 0) | ||
| 1234 | return true; | ||
| 1235 | |||
| 1236 | return false; | ||
| 1237 | } | ||
| 1238 | |||
| 1232 | size_t target_libc_count(void) { | 1239 | size_t target_libc_count(void) { |
| 1233 | return array_length(libcs_available); | 1240 | return array_length(libcs_available); |
| 1234 | } | 1241 | } |
src/target.hpp+1| ... | @@ -102,6 +102,7 @@ bool target_os_requires_libc(Os os); | ... | @@ -102,6 +102,7 @@ bool target_os_requires_libc(Os os); |
| 102 | bool target_can_build_libc(const ZigTarget *target); | 102 | bool target_can_build_libc(const ZigTarget *target); |
| 103 | const char *target_libc_generic_name(const ZigTarget *target); | 103 | const char *target_libc_generic_name(const ZigTarget *target); |
| 104 | bool target_is_libc_lib_name(const ZigTarget *target, const char *name); | 104 | bool target_is_libc_lib_name(const ZigTarget *target, const char *name); |
| 105 | bool target_is_libcpp_lib_name(const ZigTarget *target, const char *name); | ||
| 105 | bool target_supports_fpic(const ZigTarget *target); | 106 | bool target_supports_fpic(const ZigTarget *target); |
| 106 | bool target_supports_clang_march_native(const ZigTarget *target); | 107 | bool target_supports_clang_march_native(const ZigTarget *target); |
| 107 | bool target_requires_pic(const ZigTarget *target, bool linking_libc); | 108 | bool target_requires_pic(const ZigTarget *target, bool linking_libc); |
tools/update_clang_options.zig+16| ... | @@ -158,6 +158,22 @@ const known_options = [_]KnownOpt{ | ... | @@ -158,6 +158,22 @@ const known_options = [_]KnownOpt{ |
| 158 | .name = "###", | 158 | .name = "###", |
| 159 | .ident = "verbose_cmds", | 159 | .ident = "verbose_cmds", |
| 160 | }, | 160 | }, |
| 161 | .{ | ||
| 162 | .name = "fexceptions", | ||
| 163 | .ident = "exceptions", | ||
| 164 | }, | ||
| 165 | .{ | ||
| 166 | .name = "fno-exceptions", | ||
| 167 | .ident = "no_exceptions", | ||
| 168 | }, | ||
| 169 | .{ | ||
| 170 | .name = "frtti", | ||
| 171 | .ident = "rtti", | ||
| 172 | }, | ||
| 173 | .{ | ||
| 174 | .name = "fno-rtti", | ||
| 175 | .ident = "no_rtti", | ||
| 176 | }, | ||
| 161 | }; | 177 | }; |
| 162 | 178 | ||
| 163 | const blacklisted_options = [_][]const u8{}; | 179 | const blacklisted_options = [_][]const u8{}; |