lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [3/8] git commit: refs/heads/c-bindings-cfc - Add chaz_CC_set_optimization_level
Date Tue, 12 Feb 2013 20:11:52 GMT
Add chaz_CC_set_optimization_level


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/36f5753f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/36f5753f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/36f5753f

Branch: refs/heads/c-bindings-cfc
Commit: 36f5753fbb8fcae597d705c16772c88739739813
Parents: 5622ba3
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Feb 10 22:00:08 2013 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Feb 10 22:00:08 2013 +0100

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/Compiler.c |   19 +++++++++++++++++++
 charmonizer/src/Charmonizer/Core/Compiler.h |    5 +++++
 clownfish/compiler/common/charmonizer.main  |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/36f5753f/charmonizer/src/Charmonizer/Core/Compiler.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.c b/charmonizer/src/Charmonizer/Core/Compiler.c
index 28342ab..13bb0cd 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.c
+++ b/charmonizer/src/Charmonizer/Core/Compiler.c
@@ -351,6 +351,25 @@ chaz_CC_add_include_dir(const char *dir) {
     free(flag);
 }
 
+void
+chaz_CC_set_optimization_level(const char *level) {
+    const char *opt_flag;
+    char *flag;
+    size_t size;
+
+    if (chaz_CC.intval__MSC_VER) {
+        opt_flag = "/O";
+    }
+    else {
+        opt_flag = "-O";
+    }
+    size = strlen(opt_flag) + strlen(level) + 1;
+    flag = (char*)malloc(size);
+    sprintf(flag, "%s%s", opt_flag, level);
+    chaz_CC_add_extra_cflags(flag);
+    free(flag);
+}
+
 const char*
 chaz_CC_get_cc(void) {
     return chaz_CC.cc_command;

http://git-wip-us.apache.org/repos/asf/lucy/blob/36f5753f/charmonizer/src/Charmonizer/Core/Compiler.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.h b/charmonizer/src/Charmonizer/Core/Compiler.h
index 318ff62..69469e6 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.h
+++ b/charmonizer/src/Charmonizer/Core/Compiler.h
@@ -79,6 +79,11 @@ chaz_CC_add_extra_cflags(const char *);
 void
 chaz_CC_add_include_dir(const char *dir);
 
+/* Set optimization level.
+ */
+void
+chaz_CC_set_optimization_level(const char *level);
+
 /* Accessor for the compiler executable's string representation.
  */
 const char*

http://git-wip-us.apache.org/repos/asf/lucy/blob/36f5753f/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index 2dfb267..db2d3b9 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -135,6 +135,7 @@ S_write_makefile() {
     chaz_MakeFile_add_var(makefile, "LEMON_EXE",
                           "$(LEMON_DIR)" DIR_SEP "lemon$(EXE_EXT)");
 
+    chaz_CC_set_optimization_level("2");
     chaz_CC_add_include_dir(".");
     chaz_CC_add_include_dir("$(INCLUDE_DIR)");
     chaz_CC_add_include_dir("$(SRC_DIR)");


Mime
View raw message