compiler: add `Platform::supports_linker_script`
authorJean Privat <jean@pryen.org>
Sat, 10 Jan 2015 20:28:00 +0000 (15:28 -0500)
committerJean Privat <jean@pryen.org>
Mon, 12 Jan 2015 20:01:42 +0000 (15:01 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/compiler/android_platform.nit
src/compiler/emscripten_platform.nit
src/compiler/separate_compiler.nit
src/platform.nit

index 5d6d312..950125d 100644 (file)
@@ -36,6 +36,8 @@ class AndroidPlatform
 
        redef fun supports_libunwind do return false
 
+       redef fun supports_linker_script do return false
+
        redef fun toolchain(toolcontext) do return new AndroidToolchain(toolcontext)
 end
 
index 0a262fc..6332098 100644 (file)
@@ -33,6 +33,7 @@ class EmscriptenPlatform
 
        redef fun supports_libunwind do return false
        redef fun supports_libgc do return false
+       redef fun supports_linker_script do return false
        redef fun toolchain(toolcontext) do return new EnscriptenToolchain(toolcontext)
 end
 
index cf6a516..2d98fb6 100644 (file)
@@ -258,7 +258,7 @@ class SeparateCompiler
                if m isa MEntity then
                        if modelbuilder.toolcontext.opt_inline_coloring_numbers.value then
                                self.provide_declaration(m.const_color, "#define {m.const_color} {color}")
-                       else if not modelbuilder.toolcontext.opt_colors_are_symbols.value then
+                       else if not modelbuilder.toolcontext.opt_colors_are_symbols.value or not v.compiler.target_platform.supports_linker_script then
                                self.provide_declaration(m.const_color, "extern const int {m.const_color};")
                                v.add("const int {m.const_color} = {color};")
                        else
index 54a9eaa..5b7f7a5 100644 (file)
@@ -112,4 +112,7 @@ class Platform
 
        # Does this platform declare its own main function? If so, we won't generate one in Nit.
        fun no_main: Bool do return false
+
+       # Does the platform accepts linker scripts?
+       fun supports_linker_script: Bool do return true
 end