pnacl: compile each compilation unit before linking
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 3 May 2014 12:02:35 +0000 (08:02 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 20 May 2014 18:16:31 +0000 (14:16 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/pnacl_platform.nit

index adac73e..6fc7073 100644 (file)
@@ -61,6 +61,9 @@ class PnaclToolchain
                var outname = toolcontext.opt_output.value
                if outname == null then outname = "{compiler.mainmodule.name}"
 
+               var ofiles = new Array[String]
+               for cfile in cfiles do ofiles.add(cfile.substring(0, cfile.length-2) + ".o")
+
                ## Generate makefile
                var file = "{dir}/Makefile"
                """
@@ -77,6 +80,9 @@ NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../../../..)
 WARNINGS := -Wall -pedantic -Werror -Wno-long-long -Wno-unused-value -Wno-unused-label -Wno-duplicate-decl-specifier -Wno-switch -Wno-embedded-directive
 CXXFLAGS := -pthread $(WARNINGS)
 
+CXXFLAGS += -g -O0 # Debug
+# CXXFLAGS += -O3  # Release
+
 #
 # Compute tool paths
 #
@@ -99,9 +105,11 @@ export CYGWIN
 # Declare the ALL target first, to make the 'all' target the default build
 all: ../{{{outname}}}/{{{app_name}}}.pexe
 
-{{{app_name}}}.pexe: src/{{{cfiles.join(" src/")}}}
-       $(PNACL_CXX) -o $@ $^ -g -O0 $(CXXFLAGS) $(LDFLAGS) # For Debug
-       # $(PNACL_CXX) -o $@ $^ -O3 $(CXXFLAGS) $(LDFLAGS) # For Release
+.c.o:
+       $(PNACL_CXX) -c $< -g -O0 $(CXXFLAGS)
+
+{{{app_name}}}.pexe: {{{ofiles.join(" ")}}}
+       $(PNACL_CXX) -o $@ $^ $(LDFLAGS)
 
 ../{{{outname}}}/{{{app_name}}}.pexe: {{{app_name}}}.pexe
        $(PNACL_FINALIZE) -o $@ $<