diff --git a/README.md b/README.md index 6b5c1b12..dbfbc13c 100644 --- a/README.md +++ b/README.md @@ -88,22 +88,15 @@ It is possible to change the compiler optimization level, for the Pallene compil Here are some examples: ```sh -# execute no optimization (Pallene and C compiler) +# disable Pallene optimization passes pallenec test.pln -O0 -# execute Pallene compiler optimizations and C compiler level 3 optimizations -pallenec test.pln -O3 - -# execute no optimizations for Pallene compiler but executes C compiler level 2 optimizations -env CFLAGS="-O2" pallenec test.pln -O0 - -# execute all default optimizations (same as -O2) +# disable C compiler optimization +export CFLAGS='-O0' pallenec test.pln ``` -**Note**: For the C compiler only, the setting set using `CFLAGS` overrides the setting set by flag `-O`. - -For more compiler options, see `pallenec --help` +For more compiler options, see `./pallenec --help` ## Developing Pallene diff --git a/run-tests b/run-tests index 125e01d7..e804cbe1 100755 --- a/run-tests +++ b/run-tests @@ -17,9 +17,9 @@ echo "--- Test Suite ---" # need to press Ctrl-C once and busted usually gets to exit gracefully. FLAGS=(--verbose --no-keep-going) -# To speed things up, we tell the C compiler to skip optimizations. -# Don't worry, the continuous integration server still tests with optimizations. -export CFLAGS=-O0 +# To speed things up, we tell the C compiler to skip optimizations. (It's OK, the CI still uses -O2) +# Also, add some compiler flags to verify standard compliance. +export CFLAGS='-O0 -std=c99 -Wall -Werror -Wundef -Wpedantic -Wno-unused' if [ "$#" -eq 0 ]; then if command -v parallel >/dev/null; then diff --git a/src/pallene/c_compiler.lua b/src/pallene/c_compiler.lua index c80294a8..ca204b66 100644 --- a/src/pallene/c_compiler.lua +++ b/src/pallene/c_compiler.lua @@ -16,11 +16,8 @@ local util = require "pallene.util" local c_compiler = {} -local CC = "cc" -local CPPFLAGS = "" -local CFLAGS_BASE = "-std=c99 -g -fPIC" -local CFLAGS_WARN = "-Wall -Wundef -Wpedantic -Wno-unused" -local USER_CFlAGS = os.getenv("CFLAGS") or "" +local CC = os.getenv("CC") or "cc" +local CFLAGS = os.getenv("CFLAGS") or "-O2" local function get_uname() local ok, err, uname = util.outputs_of_execute("uname -s") @@ -47,14 +44,10 @@ local function run_cc(args) return true, {} end --- The third argument is the mod_name, which is not used by this -function c_compiler.compile_c_to_o(in_filename, out_filename, _, opt_level) +function c_compiler.compile_c_to_o(in_filename, out_filename) return run_cc({ - CPPFLAGS, - CFLAGS_BASE, - CFLAGS_WARN, - opt_level and "-O"..opt_level or "", - USER_CFlAGS, + "-fPIC", + CFLAGS, "-x c", "-o", util.shell_quote(out_filename), "-c", util.shell_quote(in_filename),