summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--script-overrides/stable-1.29.0-windows/build_compiler_builtins.txt1
-rw-r--r--script-overrides/stable-1.29.0-windows/build_libc.txt2
-rw-r--r--script-overrides/stable-1.29.0-windows/build_rustc_asan.txt0
-rw-r--r--script-overrides/stable-1.29.0-windows/build_rustc_lsan.txt0
-rw-r--r--script-overrides/stable-1.29.0-windows/build_rustc_msan.txt0
-rw-r--r--script-overrides/stable-1.29.0-windows/build_rustc_tsan.txt0
-rw-r--r--script-overrides/stable-1.29.0-windows/build_std.txt5
-rw-r--r--script-overrides/stable-1.29.0-windows/build_unwind.txt1
-rw-r--r--src/expand/asm.cpp2
-rw-r--r--src/hir/from_ast.cpp4
-rw-r--r--src/trans/codegen_c.cpp57
-rw-r--r--vsproject/build_cargo_minicargo.cmd11
-rw-r--r--vsproject/build_std.cmd21
-rw-r--r--vsproject/run_hello.cmd13
15 files changed, 43 insertions, 75 deletions
diff --git a/.gitignore b/.gitignore
index e6040167..85e154ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@
/vsproject/*/*.opendb
/vsproject/*/*.user
/vsproject/output
+/vsproject/output-*
/vsproject/output_mmir
/vsproject/*.obj
/vsproject/*.pdb
diff --git a/script-overrides/stable-1.29.0-windows/build_compiler_builtins.txt b/script-overrides/stable-1.29.0-windows/build_compiler_builtins.txt
new file mode 100644
index 00000000..06ae3dbf
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_compiler_builtins.txt
@@ -0,0 +1 @@
+# NOTE: mrustc doesn't need this built fully \ No newline at end of file
diff --git a/script-overrides/stable-1.29.0-windows/build_libc.txt b/script-overrides/stable-1.29.0-windows/build_libc.txt
new file mode 100644
index 00000000..aa2eb983
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_libc.txt
@@ -0,0 +1,2 @@
+cargo:rustc-cfg=stdbuild
+cargo:rerun-if-changed=build.rs \ No newline at end of file
diff --git a/script-overrides/stable-1.29.0-windows/build_rustc_asan.txt b/script-overrides/stable-1.29.0-windows/build_rustc_asan.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_rustc_asan.txt
diff --git a/script-overrides/stable-1.29.0-windows/build_rustc_lsan.txt b/script-overrides/stable-1.29.0-windows/build_rustc_lsan.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_rustc_lsan.txt
diff --git a/script-overrides/stable-1.29.0-windows/build_rustc_msan.txt b/script-overrides/stable-1.29.0-windows/build_rustc_msan.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_rustc_msan.txt
diff --git a/script-overrides/stable-1.29.0-windows/build_rustc_tsan.txt b/script-overrides/stable-1.29.0-windows/build_rustc_tsan.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_rustc_tsan.txt
diff --git a/script-overrides/stable-1.29.0-windows/build_std.txt b/script-overrides/stable-1.29.0-windows/build_std.txt
new file mode 100644
index 00000000..062afd95
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_std.txt
@@ -0,0 +1,5 @@
+# TODO: THis is the windows set
+cargo:rustc-link-lib=advapi32
+cargo:rustc-link-lib=ws2_32
+cargo:rustc-link-lib=userenv
+cargo:rustc-link-lib=shell32 \ No newline at end of file
diff --git a/script-overrides/stable-1.29.0-windows/build_unwind.txt b/script-overrides/stable-1.29.0-windows/build_unwind.txt
new file mode 100644
index 00000000..aba1574a
--- /dev/null
+++ b/script-overrides/stable-1.29.0-windows/build_unwind.txt
@@ -0,0 +1 @@
+# On both windows (MSVC) and linux (glibc), nothing is needed \ No newline at end of file
diff --git a/src/expand/asm.cpp b/src/expand/asm.cpp
index f8b3984d..90612758 100644
--- a/src/expand/asm.cpp
+++ b/src/expand/asm.cpp
@@ -166,7 +166,7 @@ class CAsmExpander:
{
GET_TOK(tok, lex);
- if( GET_TOK(tok, lex) == TOK_IDENT && tok.str() == "volatile" )
+ if( GET_TOK(tok, lex) == TOK_IDENT && tok.istr() == "volatile" )
{
flags.push_back( "volatile" );
}
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 4cde40fc..e3cba9e9 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -959,8 +959,8 @@ namespace {
}
else if( repr_str == "align" ) {
//ASSERT_BUG(a.span(), a.has_string(), "#[repr(aligned)] attribute malformed, " << *attr_repr);
- ASSERT_BUG(a.span(), rv.m_repr == ::HIR::Struct::Repr::Rust, "Conflicting #[repr] attributes - " << rv.m_repr << ", " << repr_str);
- rv.m_repr = ::HIR::Struct::Repr::Aligned;
+ ASSERT_BUG(a.span(), rv.m_repr != ::HIR::Struct::Repr::Packed, "Conflicting #[repr] attributes - " << rv.m_repr << ", " << repr_str);
+ //rv.m_repr = ::HIR::Struct::Repr::Aligned;
//rv.m_forced_alignment = ::std::stol(a.string());
}
else {
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index dc7f0fee..4131c820 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -416,6 +416,7 @@ namespace {
<< "static inline uint8_t InterlockedExchangeNoFence8(volatile uint8_t* v, uint8_t n){ return InterlockedExchange8(v, n); }\n"
<< "static inline uint8_t InterlockedExchangeAcquire8(volatile uint8_t* v, uint8_t n){ return InterlockedExchange8(v, n); }\n"
<< "static inline uint8_t InterlockedExchangeRelease8(volatile uint8_t* v, uint8_t n){ return InterlockedExchange8(v, n); }\n"
+ << "static inline uint8_t InterlockedCompareExchange32(volatile uint32_t* v, uint32_t n, uint32_t e){ return InterlockedCompareExchange(v, n, e); }\n"
;
// Atomic hackery
for(int sz = 8; sz <= 64; sz *= 2)
@@ -717,7 +718,7 @@ namespace {
H::ty_args(args, method.args[j]);
H::emit_proto(m_of, method, "__rust_", args); m_of << " {\n";
m_of << "\textern "; H::emit_proto(m_of, method, alloc_prefix, args); m_of << ";\n";
- m_of << "\t" << alloc_prefix << method.name << "(";
+ m_of << "\treturn " << alloc_prefix << method.name << "(";
for(size_t j = 0; j < args.size(); j ++)
{
if( j != 0 )
@@ -938,6 +939,8 @@ namespace {
{
case CodegenOutput::Executable:
case CodegenOutput::DynamicLibrary:
+ args.push_back(FMT("/Fe" << m_outfile_path));
+
switch(out_ty)
{
case CodegenOutput::Executable:
@@ -950,8 +953,6 @@ namespace {
throw "bug";
}
- args.push_back(FMT("/Fe" << m_outfile_path));
-
for( const auto& crate : m_crate.m_ext_crates )
{
args.push_back(crate.second.m_path + ".obj");
@@ -1873,7 +1874,7 @@ namespace {
// Handled with asm() later
break;
case Compiler::Msvc:
- //m_of << "#pragma comment(linker, \"/alternatename:_" << Trans_Mangle(p) << "=" << item.m_linkage.name << "\")\n";
+ //m_of << "#pragma comment(linker, \"/alternatename:" << Trans_Mangle(p) << "=" << item.m_linkage.name << "\")\n";
m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n";
break;
//case Compiler::Std11:
@@ -2394,7 +2395,8 @@ namespace {
}
else if( item.m_linkage.name != "" && m_compiler == Compiler::Msvc )
{
- m_of << "static ";
+ m_of << "#pragma comment(linker, \"/alternatename:" << Trans_Mangle(p) << "=" << item.m_linkage.name << "\")\n";
+ m_of << "extern ";
}
else if( item.m_linkage.name == "_Unwind_RaiseException" )
{
@@ -2422,48 +2424,6 @@ namespace {
m_of << " asm(\"" << item.m_linkage.name << "\")";
break;
case Compiler::Msvc:
- m_of << " {\n";
- // A few hacky hard-coded signatures
- if( item.m_linkage.name == "SetFilePointerEx" )
- {
- // LARGE_INTEGER
- m_of << "\tLARGE_INTEGER arg1_v;\n";
- m_of << "\targ1_v.QuadPart = arg1;\n";
- m_of << "\treturn SetFilePointerEx(arg0, arg1_v, arg2, arg3);\n";
- }
- else if( item.m_linkage.name == "CopyFileExW" )
- {
- // Not field access to undo an Option<fn()>
- m_of << "\treturn CopyFileExW(arg0, arg1, arg2.DATA.var_1._0, arg3, arg4, arg5);\n";
- }
- // BUG: libtest defines this as returning an i32, but it's void
- else if( item.m_linkage.name == "GetSystemInfo" )
- {
- m_of << "\tGetSystemInfo(arg0);\n";
- m_of << "\treturn 0;\n";
- }
- else
- {
- m_of << "\t";
- if( TU_TEST1(item.m_return.m_data, Tuple, .size() == 0) )
- ;
- else if( item.m_return.m_data.is_Diverge() )
- ;
- else {
- m_of << "return ";
- if( item.m_return.m_data.is_Pointer() )
- m_of << "(void*)";
- }
- m_of << item.m_linkage.name << "(";
- for(size_t i = 0; i < item.m_args.size(); i ++ )
- {
- if( i > 0 )
- m_of << ", ";
- m_of << "arg" << i;
- }
- m_of << ");\n";
- }
- m_of << "}";
break;
}
}
@@ -2481,6 +2441,7 @@ namespace {
m_of << "// PROTO extern \"" << item.m_abi << "\" " << p << "\n";
if( item.m_linkage.name != "" )
{
+ // If this function is implementing an external ABI, just rename it (don't bother with per-compiler trickery).
m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n";
}
if( is_extern_def )
@@ -4123,7 +4084,7 @@ namespace {
}
else if( matches_template("pushq $0; popfq", /*input=*/{"r"}, /*output=*/{}) )
{
- m_of << indent << "__writeflags("; emit_lvalue(e.inputs[0].second); m_of << ");\n";
+ m_of << indent << "__writeeflags("; emit_lvalue(e.inputs[0].second); m_of << ");\n";
return ;
}
else if( matches_template("xgetbv", /*input=*/{"{ecx}"}, /*output=*/{"={eax}", "={edx}"}) )
diff --git a/vsproject/build_cargo_minicargo.cmd b/vsproject/build_cargo_minicargo.cmd
index 33725f4e..ce878e48 100644
--- a/vsproject/build_cargo_minicargo.cmd
+++ b/vsproject/build_cargo_minicargo.cmd
@@ -1,7 +1,6 @@
-@echo off
-call build_std.cmd
-if %errorlevel% neq 0 exit /b %errorlevel%
+@call build_std.cmd
+@if %errorlevel% neq 0 exit /b %errorlevel%
-mkdir output\cargo-build
-x64\Release\minicargo.exe ..\rustc-1.19.0-src\src\tools\cargo -L output --output-dir output\cargo-build --vendor-dir ..\rustc-1.19.0-src\src\vendor
-if %errorlevel% neq 0 exit /b %errorlevel% \ No newline at end of file
+@mkdir %OUTDIR%\cargo-build
+x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\tools\cargo -L %OUTDIR% --output-dir %OUTDIR%\cargo-build --vendor-dir ..\rustc-%RUSTC_VERSION%-src\src\vendor
+@if %errorlevel% neq 0 exit /b %errorlevel% \ No newline at end of file
diff --git a/vsproject/build_std.cmd b/vsproject/build_std.cmd
index 786648ec..ff09a0b6 100644
--- a/vsproject/build_std.cmd
+++ b/vsproject/build_std.cmd
@@ -1,12 +1,11 @@
-@echo off
-set RUSTC_VERSION=1.29.0
-set OUTDIR=output-%RUSTC_VERSION%
-mkdir %OUTDIR%
-x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libstd --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%
-if %errorlevel% neq 0 exit /b %errorlevel%
-x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libpanic_unwind --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%
-if %errorlevel% neq 0 exit /b %errorlevel%
-x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libtest --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%
-if %errorlevel% neq 0 exit /b %errorlevel%
+@set RUSTC_VERSION=1.29.0
+@set OUTDIR=output-%RUSTC_VERSION%
+@mkdir %OUTDIR%
+x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libstd --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%-windows
+@if %errorlevel% neq 0 exit /b %errorlevel%
+x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libpanic_unwind --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%-windows
+@if %errorlevel% neq 0 exit /b %errorlevel%
+x64\Release\minicargo.exe ..\rustc-%RUSTC_VERSION%-src\src\libtest --vendor-dir ..\rustc-%RUSTC_VERSION%-src\src\vendor --output-dir %OUTDIR% --script-overrides ..\script-overrides\stable-%RUSTC_VERSION%-windows
+@if %errorlevel% neq 0 exit /b %errorlevel%
x64\Release\minicargo.exe ..\lib\libproc_macro --output-dir %OUTDIR%
-if %errorlevel% neq 0 exit /b %errorlevel%
+@if %errorlevel% neq 0 exit /b %errorlevel%
diff --git a/vsproject/run_hello.cmd b/vsproject/run_hello.cmd
index b419bbc1..894e8240 100644
--- a/vsproject/run_hello.cmd
+++ b/vsproject/run_hello.cmd
@@ -1,8 +1,7 @@
-@echo off
-call build_std.cmd
-if %errorlevel% neq 0 exit /b %errorlevel%
+@call build_std.cmd
+@if %errorlevel% neq 0 exit /b %errorlevel%
-x64\Release\mrustc.exe ..\rustc-1.19.0-src\src\test\run-pass\hello.rs -L output -o output\hello.exe -g
-if %errorlevel% neq 0 exit /b %errorlevel%
-output\hello.exe
-if %errorlevel% neq 0 exit /b %errorlevel% \ No newline at end of file
+x64\Release\mrustc.exe ..\rustc-%RUSTC_VERSION%-src\src\test\run-pass\hello.rs -L %OUTDIR% -o %OUTDIR%\hello.exe -g
+@if %errorlevel% neq 0 exit /b %errorlevel%
+%OUTDIR%\hello.exe
+@if %errorlevel% neq 0 exit /b %errorlevel% \ No newline at end of file