From 52402138c5af70b96812775887ae9c4584a9c4ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 12 May 2014 10:16:08 -0400 Subject: [PATCH] nitg/pnacl: automate option no_main MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- src/abstract_compiler.nit | 4 +++- src/platform.nit | 3 +++ src/pnacl_platform.nit | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/abstract_compiler.nit b/src/abstract_compiler.nit index a19af3e..831311d 100644 --- a/src/abstract_compiler.nit +++ b/src/abstract_compiler.nit @@ -540,9 +540,9 @@ abstract class AbstractCompiler var v = self.new_visitor v.add_decl("#include ") var ost = modelbuilder.toolcontext.opt_stacktrace.value + var platform = mainmodule.target_platform if ost == null then - var platform = mainmodule.target_platform if platform != null and not platform.supports_libunwind then ost = "none" else @@ -551,6 +551,8 @@ abstract class AbstractCompiler modelbuilder.toolcontext.opt_stacktrace.value = ost end + if platform != null and platform.no_main then modelbuilder.toolcontext.opt_no_main.value = true + if ost == "nitstack" or ost == "libunwind" then v.add_decl("#define UNW_LOCAL_ONLY") v.add_decl("#include ") diff --git a/src/platform.nit b/src/platform.nit index ccb506d..17257f5 100644 --- a/src/platform.nit +++ b/src/platform.nit @@ -112,4 +112,7 @@ end # Services will be added to this class in other modules. abstract class Platform fun supports_libunwind: Bool do return true + + # Does this platform declare its own main function? If so, we won't generate one in Nit. + fun no_main: Bool do return false end diff --git a/src/pnacl_platform.nit b/src/pnacl_platform.nit index e05c5c6..9add122 100644 --- a/src/pnacl_platform.nit +++ b/src/pnacl_platform.nit @@ -31,6 +31,10 @@ end class PnaclPlatform super Platform + redef fun supports_libunwind do return false + + redef fun no_main do return true + redef fun toolchain(toolcontext) do return new PnaclToolchain(toolcontext) end -- 1.7.9.5