From c8175361ebb5ae99c62d956c475d374a49f90402 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 12 Aug 2018 21:01:34 +0800 Subject: Target - Set alignment for u64/i64 to 4 on 32-bit platforms (fixes #78) --- src/trans/target.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/trans/target.cpp') diff --git a/src/trans/target.cpp b/src/trans/target.cpp index c1dce972..004b0bf1 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -684,13 +684,14 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve, case ::HIR::CoreType::U64: case ::HIR::CoreType::I64: out_size = 8; - out_align = 8; + // TODO: on x86, u64/i64 has an alignment of 4, while x86_64 has 8. What do other platforms have? + out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 8; return true; case ::HIR::CoreType::U128: case ::HIR::CoreType::I128: out_size = 16; - // TODO: If i128 is emulated, this can be 8 - out_align = 16; + // TODO: If i128 is emulated, this can be 8 (as it is on x86, where it's actually 4 due to the above comment) + out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 16; return true; case ::HIR::CoreType::Usize: case ::HIR::CoreType::Isize: -- cgit v1.2.3 From 74c2ec9d3c7eb09540a2a5de3127390fa8252179 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 20 Aug 2018 22:37:47 +0800 Subject: Trans - Fix size/alignment mismatches on x86 --- src/trans/codegen_c.cpp | 134 +++++++++++++++++++++++++++++++++++++++--------- src/trans/target.cpp | 6 +-- 2 files changed, 113 insertions(+), 27 deletions(-) (limited to 'src/trans/target.cpp') diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index fbf98806..836f9b25 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -1029,8 +1029,27 @@ namespace { TRACE_FUNCTION_F(p); auto item_ty = ::HIR::TypeRef::new_path(p.clone(), &item); const auto* repr = Target_GetTypeRepr(sp, m_resolve, item_ty); - bool has_unsized = false; + + ::std::vector fields; + for(const auto& ent : repr->fields) + { + (void)ent; + fields.push_back(fields.size()); + } + ::std::sort(fields.begin(), fields.end(), [&](auto a, auto b){ return repr->fields[a].offset < repr->fields[b].offset; }); + m_of << "// struct " << p << "\n"; + + // Determine if the type has an alignment hack + bool has_manual_align = false; + for(unsigned fld : fields ) + { + const auto& ty = repr->fields[fld].ty; + if( ty.m_data.is_Array() && ty.m_data.as_Array().size_val == 0 ) { + has_manual_align = true; + } + } + // For repr(packed), mark as packed if(is_packed) { @@ -1043,15 +1062,20 @@ namespace { break; } } - m_of << "struct s_" << Trans_Mangle(p) << " {\n"; - - ::std::vector fields; - for(const auto& ent : repr->fields) + if(has_manual_align) { - (void)ent; - fields.push_back(fields.size()); + switch(m_compiler) + { + case Compiler::Msvc: + m_of << "#pragma align(push, " << repr->align << ")\n"; + break; + case Compiler::Gcc: + break; + } } - ::std::sort(fields.begin(), fields.end(), [&](auto a, auto b){ return repr->fields[a].offset < repr->fields[b].offset; }); + m_of << "struct s_" << Trans_Mangle(p) << " {\n"; + + bool has_unsized = false; size_t sized_fields = 0; for(unsigned fld : fields) { @@ -1078,9 +1102,12 @@ namespace { continue ; } else { + // TODO: Nested unsized? emit_ctype( ty, FMT_CB(ss, ss << "_" << fld) ); sized_fields ++; + + has_unsized |= (s == SIZE_MAX); } } m_of << ";\n"; @@ -1090,15 +1117,23 @@ namespace { m_of << "\tchar _d;\n"; } m_of << "}"; - if(is_packed) + if(is_packed || has_manual_align) { switch(m_compiler) { case Compiler::Msvc: - m_of << ";\n#pragma pack(pop)\n"; + if( is_packed ) + m_of << ";\n#pragma pack(pop)\n"; + if( has_manual_align ) + m_of << ";\n#pragma align(pop)\n"; break; case Compiler::Gcc: - m_of << " __attribute__((packed));\n"; + m_of << " __attribute__(("; + if( is_packed ) + m_of << "packed,"; + if( has_manual_align ) + m_of << "__aligned__(" << repr->align << "),"; + m_of << "));\n"; break; } } @@ -1107,6 +1142,12 @@ namespace { m_of << ";\n"; } (void)has_unsized; + if( true && repr->size > 0 && !has_unsized ) + { + // TODO: Handle unsized (should check the size of the fixed-size region) + m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct s_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n"; + //m_of << "typedef char alignof_assert_" << Trans_Mangle(p) << "[ (ALIGNOF(struct s_" << Trans_Mangle(p) << ") == " << repr->align << ") ? 1 : -1 ];\n"; + } auto struct_ty = ::HIR::TypeRef(p.clone(), &item); auto drop_glue_path = ::HIR::Path(struct_ty.clone(), "#drop_glue"); @@ -1174,6 +1215,10 @@ namespace { m_of << "\t"; emit_ctype( repr->fields[i].ty, FMT_CB(ss, ss << "var_" << i;) ); m_of << ";\n"; } m_of << "};\n"; + if( true && repr->size > 0 ) + { + m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(union u_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n"; + } // Drop glue (calls destructor if there is one) auto drop_glue_path = ::HIR::Path(item_ty.clone(), "#drop_glue"); @@ -1272,16 +1317,32 @@ namespace { // NOTE: The way the structure generation works is that enum variants are always first, so the field index = the variant index m_of << "\tunion {\n"; // > First field - m_of << "\t\t"; - emit_ctype(repr->fields[0].ty, FMT_CB(os, os << "var_0")); - m_of << ";\n"; + { + m_of << "\t\t"; + const auto& ty = repr->fields[0].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_0") ); + m_of << ";\n"; + //sized_fields ++; + } + } // > All others for(auto idx : union_fields) { - // TODO: if the compiler doesn't allow zero-sized types, don't emit zero-sized fields. m_of << "\t\t"; - emit_ctype(repr->fields[idx].ty, FMT_CB(os, os << "var_" << idx)); - m_of << ";\n"; + + const auto& ty = repr->fields[idx].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_" << idx) ); + m_of << ";\n"; + //sized_fields ++; + } } m_of << "\t} DATA;\n"; @@ -1336,6 +1397,10 @@ namespace { } m_of << "};\n"; + if( true && repr->size > 0 ) + { + m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct e_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n"; + } // --- // - Drop Glue @@ -1724,9 +1789,15 @@ namespace { else { m_of << "{"; - m_of << " { .var_" << e.idx << " = "; - emit_literal(get_inner_type(e.idx, 0), *e.val, params); - m_of << " }"; + const auto& ity = get_inner_type(e.idx, 0); + if( this->type_is_bad_zst(ity) ) { + m_of << " {}"; + } + else { + m_of << " { .var_" << e.idx << " = "; + emit_literal(ity, *e.val, params); + m_of << " }"; + } m_of << ", .TAG = "; emit_enum_variant_val(repr, e.idx); m_of << "}"; } @@ -2739,7 +2810,11 @@ namespace { m_of << " = "; // If the index is zero, then the best option is to borrow the source - if( val_fp->field_index == 0 ) + if( val_fp->val->is_Downcast() ) + { + m_of << "(void*)& "; emit_lvalue(*val_fp->val->as_Downcast().val); + } + else if( val_fp->field_index == 0 ) { m_of << "(void*)& "; emit_lvalue(*val_fp->val); } @@ -3058,9 +3133,20 @@ namespace { } else { - emit_lvalue(e.dst); m_of << ".TAG = "; emit_enum_variant_val(repr, ve.index); m_of << ";\n" << indent; - emit_lvalue(e.dst); m_of << ".DATA"; - m_of << ".var_" << ve.index << " = "; emit_param(ve.val); + emit_lvalue(e.dst); m_of << ".TAG = "; emit_enum_variant_val(repr, ve.index); + + ::HIR::TypeRef tmp; + const auto& vty = mir_res.get_param_type(tmp, ve.val); + if( this->type_is_bad_zst(vty) ) + { + m_of << "/* ZST field */"; + } + else + { + m_of << ";\n" << indent; + emit_lvalue(e.dst); m_of << ".DATA"; + m_of << ".var_" << ve.index << " = "; emit_param(ve.val); + } } } else diff --git a/src/trans/target.cpp b/src/trans/target.cpp index 004b0bf1..ea850937 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -685,13 +685,13 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve, case ::HIR::CoreType::I64: out_size = 8; // TODO: on x86, u64/i64 has an alignment of 4, while x86_64 has 8. What do other platforms have? - out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 8; + out_align = g_target.m_arch.m_name == "x86" ? 4 : 8; return true; case ::HIR::CoreType::U128: case ::HIR::CoreType::I128: out_size = 16; // TODO: If i128 is emulated, this can be 8 (as it is on x86, where it's actually 4 due to the above comment) - out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 16; + out_align = g_target.m_arch.m_name == "x86" ? 4 : 16; return true; case ::HIR::CoreType::Usize: case ::HIR::CoreType::Isize: @@ -704,7 +704,7 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve, return true; case ::HIR::CoreType::F64: out_size = 8; - out_align = 8; + out_align = g_target.m_arch.m_name == "x86" ? 4 : 8; return true; case ::HIR::CoreType::Str: DEBUG("sizeof on a `str` - unsized"); -- cgit v1.2.3 From d85ac84278fa0322f1df0b16a45a1cdde83cba57 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 9 Sep 2018 22:19:40 +0800 Subject: Msvc compile fixes --- src/ast/attrs.hpp | 2 +- src/hir/deserialise.cpp | 4 +- src/span.cpp | 4 ++ src/trans/codegen_c.cpp | 70 +++++++++++++--------- src/trans/target.cpp | 7 ++- src/version.cpp | 8 +++ tools/minicargo/build.cpp | 2 +- tools/minicargo/main.cpp | 1 + tools/standalone_miri/miri.cpp | 34 +++++++---- tools/standalone_miri/value.cpp | 10 ++-- tools/testrunner/main.cpp | 6 +- vsproject/mrustc.vcxproj | 2 +- vsproject/mrustc.vcxproj.filters | 6 +- vsproject/standalone_miri/standalone_miri.vcxproj | 1 + .../standalone_miri.vcxproj.filters | 3 + 15 files changed, 105 insertions(+), 55 deletions(-) (limited to 'src/trans/target.cpp') diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp index 1926e96a..0e1c8149 100644 --- a/src/ast/attrs.hpp +++ b/src/ast/attrs.hpp @@ -113,7 +113,7 @@ public: ) ) } - Attribute& operator=(const Attribute&& ) = delete; + Attribute& operator=(const Attribute& ) = delete; Attribute(Attribute&& ) = default; Attribute& operator=(Attribute&& ) = default; Attribute clone() const; diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index 17a93730..afce2fe4 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -734,7 +734,9 @@ ::HIR::LifetimeRef HirDeserialiser::deserialise_lifetimeref() { - return { static_cast(m_in.read_count()) }; + ::HIR::LifetimeRef rv; + rv.binding = static_cast(m_in.read_count()); + return rv; } ::HIR::TypeRef HirDeserialiser::deserialise_type() diff --git a/src/span.cpp b/src/span.cpp index 3d4d1ceb..eacdc7aa 100644 --- a/src/span.cpp +++ b/src/span.cpp @@ -59,7 +59,11 @@ namespace { void Span::bug(::std::function msg) const { print_span_message(*this, [](auto& os){os << "BUG";}, msg); +#ifndef _WIN32 abort(); +#else + exit(1); +#endif } void Span::error(ErrorType tag, ::std::function msg) const { diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index ca038230..322846e8 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -955,6 +955,7 @@ namespace { if( te.size() > 0 ) { m_of << "typedef struct "; emit_ctype(ty); m_of << " {\n"; + unsigned n_fields = 0; for(unsigned int i = 0; i < te.size(); i++) { m_of << "\t"; @@ -967,8 +968,13 @@ namespace { else { emit_ctype(te[i], FMT_CB(ss, ss << "_" << i;)); m_of << ";\n"; + n_fields += 1; } } + if( n_fields == 0 && m_options.disallow_empty_structs ) + { + m_of << "\tchar _d;\n"; + } m_of << "} "; emit_ctype(ty); m_of << ";\n"; } @@ -1315,36 +1321,40 @@ namespace { assert(1 + union_fields.size() + 1 >= repr->fields.size()); // Make the union! // NOTE: The way the structure generation works is that enum variants are always first, so the field index = the variant index - m_of << "\tunion {\n"; - // > First field + // TODO: + if( !this->type_is_bad_zst(repr->fields[0].ty) || ::std::any_of(union_fields.begin(), union_fields.end(), [this,repr](auto x){ return !this->type_is_bad_zst(repr->fields[x].ty); }) ) { - m_of << "\t\t"; - const auto& ty = repr->fields[0].ty; - if( this->type_is_bad_zst(ty) ) { - m_of << "// ZST: " << ty << "\n"; - } - else { - emit_ctype( ty, FMT_CB(ss, ss << "var_0") ); - m_of << ";\n"; - //sized_fields ++; + m_of << "\tunion {\n"; + // > First field + { + m_of << "\t\t"; + const auto& ty = repr->fields[0].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_0") ); + m_of << ";\n"; + //sized_fields ++; + } } - } - // > All others - for(auto idx : union_fields) - { - m_of << "\t\t"; + // > All others + for(auto idx : union_fields) + { + m_of << "\t\t"; - const auto& ty = repr->fields[idx].ty; - if( this->type_is_bad_zst(ty) ) { - m_of << "// ZST: " << ty << "\n"; - } - else { - emit_ctype( ty, FMT_CB(ss, ss << "var_" << idx) ); - m_of << ";\n"; - //sized_fields ++; + const auto& ty = repr->fields[idx].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_" << idx) ); + m_of << ";\n"; + //sized_fields ++; + } } + m_of << "\t} DATA;\n"; } - m_of << "\t} DATA;\n"; if( repr->fields.size() == 1 + union_fields.size() ) { @@ -1791,14 +1801,14 @@ namespace { m_of << "{"; const auto& ity = get_inner_type(e.idx, 0); if( this->type_is_bad_zst(ity) ) { - m_of << " {}"; + //m_of << " {}"; } else { m_of << " { .var_" << e.idx << " = "; emit_literal(ity, *e.val, params); - m_of << " }"; + m_of << " }, "; } - m_of << ", .TAG = "; emit_enum_variant_val(repr, e.idx); + m_of << ".TAG = "; emit_enum_variant_val(repr, e.idx); m_of << "}"; } ), @@ -3991,13 +4001,15 @@ namespace { m_of << name << o_before << "8" << o_after << "("; break; case ::HIR::CoreType::U16: + case ::HIR::CoreType::I16: m_of << name << o_before << "16" << o_after << "("; break; case ::HIR::CoreType::U32: + case ::HIR::CoreType::I32: m_of << name << o_before << o_after << "("; break; case ::HIR::CoreType::U64: - //case ::HIR::CoreType::I64: + case ::HIR::CoreType::I64: m_of << name << o_before << "64" << o_after << "("; break; case ::HIR::CoreType::Usize: diff --git a/src/trans/target.cpp b/src/trans/target.cpp index ea850937..f91b679a 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -691,7 +691,12 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve, case ::HIR::CoreType::I128: out_size = 16; // TODO: If i128 is emulated, this can be 8 (as it is on x86, where it's actually 4 due to the above comment) - out_align = g_target.m_arch.m_name == "x86" ? 4 : 16; + if( g_target.m_arch.m_name == "x86" ) + out_align = 4; + else if( /*g_target.m_arch.m_name == "x86_64" && */g_target.m_backend_c.m_codegen_mode == CodegenMode::Msvc ) + out_align = 8; + else + out_align = 16; return true; case ::HIR::CoreType::Usize: case ::HIR::CoreType::Isize: diff --git a/src/version.cpp b/src/version.cpp index d6307618..b40196ff 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -12,6 +12,14 @@ #define VERSION_MINOR 8 #define VERSION_PATCH 0 +#ifdef _WIN32 +# define VERSION_GIT_ISDIRTY 1 +# define VERSION_GIT_FULLHASH "" +# define VERSION_GIT_SHORTHASH "" +# define VERSION_BUILDTIME "" +# define VERSION_GIT_BRANCH "" +#endif + unsigned int giVersion_Major = VERSION_MAJOR; unsigned int giVersion_Minor = VERSION_MINOR; unsigned int giVersion_Patch = VERSION_PATCH; diff --git a/tools/minicargo/build.cpp b/tools/minicargo/build.cpp index 2f8fafe4..35c64f3b 100644 --- a/tools/minicargo/build.cpp +++ b/tools/minicargo/build.cpp @@ -945,7 +945,7 @@ bool Builder::spawn_process(const char* exe_name, const StringList& args, const auto cmdline_str = cmdline.str(); if(true) { - ::std::cout << "> " << cmdline_str << ::std::end;; + ::std::cout << "> " << cmdline_str << ::std::endl; } else { diff --git a/tools/minicargo/main.cpp b/tools/minicargo/main.cpp index b96a8a03..d7312d48 100644 --- a/tools/minicargo/main.cpp +++ b/tools/minicargo/main.cpp @@ -5,6 +5,7 @@ * main.cpp * - Entrypoint */ +#define _CRT_SECURE_NO_WARNINGS #include #include // strcmp #include diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp index f4179b5d..8231f2c5 100644 --- a/tools/standalone_miri/miri.cpp +++ b/tools/standalone_miri/miri.cpp @@ -12,6 +12,7 @@ #include #include "debug.hpp" #include "miri.hpp" +#include // memrchr #ifdef _WIN32 # define NOMINMAX # include @@ -953,10 +954,10 @@ bool InterpreterThread::step_one(Value& out_thread_result) int res = 0; // TODO: Handle comparison of the relocations too - const auto& alloc_l = v_l.m_value ? v_l.m_value->allocation : v_l.m_alloc; - const auto& alloc_r = v_r.m_value ? v_r.m_value->allocation : v_r.m_alloc; - auto reloc_l = alloc_l ? v_l.get_relocation(v_l.m_offset) : RelocationPtr(); - auto reloc_r = alloc_r ? v_r.get_relocation(v_r.m_offset) : RelocationPtr(); + //const auto& alloc_l = v_l.m_value ? v_l.m_value->allocation : v_l.m_alloc; + //const auto& alloc_r = v_r.m_value ? v_r.m_value->allocation : v_r.m_alloc; + auto reloc_l = /*alloc_l ? */v_l.get_relocation(v_l.m_offset)/* : RelocationPtr()*/; + auto reloc_r = /*alloc_r ? */v_r.get_relocation(v_r.m_offset)/* : RelocationPtr()*/; if( reloc_l != reloc_r ) { @@ -1578,10 +1579,23 @@ bool InterpreterThread::call_path(Value& ret, const ::HIR::Path& path, ::std::ve return false; } +#ifdef _WIN32 +const char* memrchr(const void* p, int c, size_t s) { + const char* p2 = reinterpret_cast(p); + while( s > 0 ) + { + s -= 1; + if( p2[s] == c ) + return &p2[s]; + } + return nullptr; +} +#else extern "C" { long sysconf(int); ssize_t write(int, const void*, size_t); } +#endif bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, const ::std::string& abi, ::std::vector args) { if( link_name == "__rust_allocate" ) @@ -1673,8 +1687,8 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c } else if( link_name == "GetModuleHandleW" ) { - LOG_ASSERT(args.at(0).allocation.is_alloc(), ""); - const auto& tgt_alloc = args.at(0).allocation.alloc().get_relocation(0); + LOG_ASSERT(args.at(0).allocation, ""); + const auto& tgt_alloc = args.at(0).get_relocation(0); const void* arg0 = (tgt_alloc ? tgt_alloc.alloc().data_ptr() : nullptr); //extern void* GetModuleHandleW(const void* s); if(arg0) { @@ -1698,10 +1712,8 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c } else if( link_name == "GetProcAddress" ) { - LOG_ASSERT(args.at(0).allocation.is_alloc(), ""); - const auto& handle_alloc = args.at(0).allocation.alloc().get_relocation(0); - LOG_ASSERT(args.at(1).allocation.is_alloc(), ""); - const auto& sym_alloc = args.at(1).allocation.alloc().get_relocation(0); + const auto& handle_alloc = args.at(0).get_relocation(0); + const auto& sym_alloc = args.at(1).get_relocation(0); // TODO: Ensure that first arg is a FFI pointer with offset+size of zero void* handle = handle_alloc.ffi().ptr_value; @@ -2204,7 +2216,7 @@ bool InterpreterThread::call_intrinsic(Value& rv, const ::std::string& name, con LOG_ASSERT(src_ofs <= src_alloc.ffi().size, ""); LOG_ASSERT(byte_count <= src_alloc.ffi().size, ""); LOG_ASSERT(src_ofs + byte_count <= src_alloc.ffi().size, ""); - dst_alloc.alloc().write_bytes(dst_ofs, src_alloc.ffi().ptr_value + src_ofs, byte_count); + dst_alloc.alloc().write_bytes(dst_ofs, reinterpret_cast(src_alloc.ffi().ptr_value) + src_ofs, byte_count); break; } } diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp index cf378077..849d3a64 100644 --- a/tools/standalone_miri/value.cpp +++ b/tools/standalone_miri/value.cpp @@ -239,7 +239,7 @@ void* ValueCommonRead::read_pointer_unsafe(size_t rd_ofs, size_t req_valid, size // TODO: Have an idea of mutability and available size from FFI out_size = f.size - ofs; out_is_mut = false; - return reloc.ffi().ptr_value + ofs; + return reinterpret_cast(reloc.ffi().ptr_value) + ofs; } } throw ""; @@ -607,22 +607,22 @@ Value Value::new_pointer(::HIR::TypeRef ty, uint64_t v, RelocationPtr r) { return rv; } Value Value::new_usize(uint64_t v) { - Value rv( ::HIR::TypeRef(RawType::USize) ); + auto rv = Value( ::HIR::TypeRef(RawType::USize) ); rv.write_usize(0, v); return rv; } Value Value::new_isize(int64_t v) { - Value rv( ::HIR::TypeRef(RawType::ISize) ); + auto rv = Value( ::HIR::TypeRef(RawType::ISize) ); rv.write_isize(0, v); return rv; } Value Value::new_u32(uint32_t v) { - Value rv( ::HIR::TypeRef(RawType::U32) ); + auto rv = Value( ::HIR::TypeRef(RawType::U32) ); rv.write_u32(0, v); return rv; } Value Value::new_i32(int32_t v) { - Value rv( ::HIR::TypeRef(RawType::I32) ); + auto rv = Value( ::HIR::TypeRef(RawType::I32) ); rv.write_i32(0, v); return rv; } diff --git a/tools/testrunner/main.cpp b/tools/testrunner/main.cpp index 4dafe508..5c21937d 100644 --- a/tools/testrunner/main.cpp +++ b/tools/testrunner/main.cpp @@ -520,9 +520,8 @@ bool run_executable(const ::helpers::path& exe_name, const ::std::vector(cmdline_str.size()), &tmp, NULL); //WriteFile(si.hStdOutput, "\n", 1, &tmp, NULL); } + DuplicateHandle(NULL, si.hStdOutput, NULL, &si.hStdError, GENERIC_WRITE, FALSE, FILE_SHARE_READ); PROCESS_INFORMATION pi = { 0 }; + auto em = SetErrorMode(SEM_NOGPFAULTERRORBOX); CreateProcessA(exe_name.str().c_str(), (LPSTR)cmdline_str.c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); + SetErrorMode(em); CloseHandle(si.hStdOutput); WaitForSingleObject(pi.hProcess, INFINITE); DWORD status = 1; diff --git a/vsproject/mrustc.vcxproj b/vsproject/mrustc.vcxproj index 2096266a..13c4a23e 100644 --- a/vsproject/mrustc.vcxproj +++ b/vsproject/mrustc.vcxproj @@ -252,7 +252,6 @@ - @@ -264,6 +263,7 @@ + diff --git a/vsproject/mrustc.vcxproj.filters b/vsproject/mrustc.vcxproj.filters index 997e4849..755013af 100644 --- a/vsproject/mrustc.vcxproj.filters +++ b/vsproject/mrustc.vcxproj.filters @@ -80,9 +80,6 @@ Source Files - - Source Files - Source Files @@ -392,6 +389,9 @@ Source Files\trans + + Source Files + diff --git a/vsproject/standalone_miri/standalone_miri.vcxproj b/vsproject/standalone_miri/standalone_miri.vcxproj index 66f33ebd..5c235353 100644 --- a/vsproject/standalone_miri/standalone_miri.vcxproj +++ b/vsproject/standalone_miri/standalone_miri.vcxproj @@ -170,6 +170,7 @@ + diff --git a/vsproject/standalone_miri/standalone_miri.vcxproj.filters b/vsproject/standalone_miri/standalone_miri.vcxproj.filters index e26bbee5..3b25bbfb 100644 --- a/vsproject/standalone_miri/standalone_miri.vcxproj.filters +++ b/vsproject/standalone_miri/standalone_miri.vcxproj.filters @@ -59,5 +59,8 @@ Source Files + + Source Files + \ No newline at end of file -- cgit v1.2.3