diff options
author | John Hodge <tpg@mutabah.net> | 2017-07-09 14:24:39 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-07-09 14:24:39 +0800 |
commit | 13d10d2875c14d98e85a467f6777fa17395e17a5 (patch) | |
tree | 7729e946730d27440abac67e435ada3e1d4ed5ce | |
parent | 98f0fd1ca7576255ec65015f8bbbf1213b29c72d (diff) | |
download | mrust-13d10d2875c14d98e85a467f6777fa17395e17a5.tar.gz |
Codegen C - MSVC hackery.
-rw-r--r-- | src/trans/codegen_c.cpp | 27 | ||||
-rw-r--r-- | vsproject/test.nmake | 24 |
2 files changed, 40 insertions, 11 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 5803ddfe..71ae50a5 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -399,6 +399,7 @@ namespace { args.push_back(cache_str( detect_msvc().path_vcvarsall )); args.push_back("&"); args.push_back("cl.exe"); + args.push_back("/nologo"); args.push_back(m_outfile_path_c.c_str()); switch(opt.opt_level) { @@ -1125,7 +1126,18 @@ namespace { if( item.m_linkage.name != "" && m_compiler != Compiler::Gcc ) { - m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n"; + switch(m_compiler) + { + case Compiler::Gcc: + // Handled with asm() later + break; + case Compiler::Msvc: + m_of << "#pragma comment(linker, \"/alternatename:" << Trans_Mangle(p) << "=" << item.m_linkage.name << "\")\n"; + break; + //case Compiler::Std11: + // m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n"; + // break; + } } auto type = params.monomorph(m_resolve, item.m_type); @@ -1532,7 +1544,18 @@ namespace { if (item.m_linkage.name != "" && m_compiler != Compiler::Gcc) { - m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n"; + switch (m_compiler) + { + case Compiler::Gcc: + // Handled with asm() later + break; + case Compiler::Msvc: + m_of << "#pragma comment(linker, \"/alternatename:" << Trans_Mangle(p) << "=" << item.m_linkage.name << "\")\n"; + break; + //case Compiler::Std11: + // m_of << "#define " << Trans_Mangle(p) << " " << item.m_linkage.name << "\n"; + // break; + } } m_of << "// extern \"" << item.m_abi << "\" " << p << "\n"; diff --git a/vsproject/test.nmake b/vsproject/test.nmake index f6018763..544127ad 100644 --- a/vsproject/test.nmake +++ b/vsproject/test.nmake @@ -16,31 +16,37 @@ all: $(OUTDIR)hello-world.exe .exe.rs: $(MRUSTC) -o $@ $< -l ..\output -$(OUTDIR)libcore.hir : $(RUSTSRC)libcore\lib.rs +$(OUTDIR)libcore.hir : $(RUSTSRC)libcore\lib.rs $(MRUSTC) @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)libcore\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)liballoc.hir : $(RUSTSRC)liballoc\lib.rs $(OUTDIR)libcore.hir +$(OUTDIR)liballoc.hir : $(RUSTSRC)liballoc\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)liballoc\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)libstd_unicode.hir : $(RUSTSRC)libstd_unicode\lib.rs $(OUTDIR)libcore.hir +$(OUTDIR)libstd_unicode.hir : $(RUSTSRC)libstd_unicode\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)libstd_unicode\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)libcollections.hir: $(RUSTSRC)libcollections\lib.rs $(OUTDIR)liballoc.hir $(OUTDIR)libstd_unicode.hir +$(OUTDIR)libcollections.hir: $(RUSTSRC)libcollections\lib.rs $(MRUSTC) $(OUTDIR)liballoc.hir $(OUTDIR)libstd_unicode.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)libcollections\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)librand.hir: $(RUSTSRC)librand\lib.rs $(OUTDIR)libcore.hir +$(OUTDIR)librand.hir: $(RUSTSRC)librand\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)librand\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)liblibc.hir: $(RUSTSRC)liblibc\src\lib.rs $(OUTDIR)libcore.hir +$(OUTDIR)liblibc.hir: $(RUSTSRC)liblibc\src\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)liblibc\src\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)libstd.hir: $(RUSTSRC)libstd\lib.rs $(OUTDIR)libcore.hir $(OUTDIR)libcollections.hir $(OUTDIR)liblibc.hir $(OUTDIR)librand.hir +$(OUTDIR)libunwind.hir: $(RUSTSRC)libunwind\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir $(OUTDIR)liblibc.hir + @echo [MRUSTC] $@ + @$(MRUSTC) -o $@ $(RUSTSRC)libunwind\lib.rs -l ..\output > $@_dbg.txt +$(OUTDIR)libcompiler_builtins.hir: $(RUSTSRC)libcompiler_builtins\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir + @echo [MRUSTC] $@ + @$(MRUSTC) -o $@ $(RUSTSRC)libcompiler_builtins\lib.rs -l ..\output > $@_dbg.txt +$(OUTDIR)libstd.hir: $(RUSTSRC)libstd\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir $(OUTDIR)libcollections.hir $(OUTDIR)liblibc.hir $(OUTDIR)librand.hir $(OUTDIR)libunwind.hir $(OUTDIR)libcompiler_builtins.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)libstd\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)liballoc_system.hir: $(RUSTSRC)liballoc_system\lib.rs $(OUTDIR)libcore.hir +$(OUTDIR)liballoc_system.hir: $(RUSTSRC)liballoc_system\lib.rs $(MRUSTC) $(OUTDIR)libcore.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)liballoc_system\lib.rs -l ..\output > $@_dbg.txt -$(OUTDIR)hello-world.exe: $(RUSTSRC)test\run-pass\hello.rs $(OUTDIR)libstd.hir $(OUTDIR)liballoc_system.hir +$(OUTDIR)hello-world.exe: $(RUSTSRC)test\run-pass\hello.rs $(MRUSTC) $(OUTDIR)libstd.hir $(OUTDIR)liballoc_system.hir @echo [MRUSTC] $@ @$(MRUSTC) -o $@ $(RUSTSRC)test\run-pass\hello.rs -l ..\output > $@_dbg.txt
\ No newline at end of file |