From 05a3c5c0f3967f676778f477c7f823af6bec6c2f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 22 Oct 2010 16:15:06 -0700 Subject: [PATCH] rustc: Add an "_" prefix to assembler-generated symbols on Mac --- src/comp/back/x86.rs | 5 +++++ src/lib/linux_os.rs | 3 +++ src/lib/macos_os.rs | 4 ++++ src/lib/win32_os.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index d4b76352ca2..86631e93bf1 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -2,6 +2,7 @@ import lib.llvm.llvm; import lib.llvm.llvm.ModuleRef; import std._str; import std._vec; +import std.os.target_os; import util.common.istr; const int wordsz = 4; @@ -128,7 +129,11 @@ fn decl_upcall_glue(int align, str prefix, uint n) -> str { fn get_module_asm() -> str { auto align = 4; + auto prefix = ""; + if (target_os() == "macos") { + prefix = "_"; + } auto glues = vec(decl_glue(align, prefix, diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index ce2c0f79aea..d5ef2a6b800 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -47,6 +47,9 @@ fn exec_suffix() -> str { ret ""; } +fn target_os() -> str { + ret "linux"; +} // Local Variables: // mode: rust; diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index 1d96a2339b9..53a66b56bec 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -47,6 +47,10 @@ fn exec_suffix() -> str { ret ""; } +fn target_os() -> str { + ret "macos"; +} + // Local Variables: // mode: rust; // fill-column: 78; diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index 6e1b9a9c8b1..9f9ec2c2b9e 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -38,6 +38,10 @@ fn exec_suffix() -> str { ret ".exe"; } +fn target_os() -> str { + ret "win32"; +} + // Local Variables: // mode: rust; // fill-column: 78;